Open amb5l opened 3 years ago
Thank you for this excellent project which I am using to prove an embedded graphics controller in an FPGA. My hardware supports multiple display resolutions so the initialization of clip_window
needs to change for my application.
What can be gained by leaving the window_t clip_window
empty? It forces an initial call to hagl_set_clip_window()
which you probably want to do anyway after changing the resolution.
My framebuffer driver maintains the current display size as
uint16_t fb_width;
uint16_t fb_height;
So in my hagl_hal.h
I have
#define DISPLAY_WIDTH fb_width
#define DISPLAY_HEIGHT fb_height
This results in an error when compiling hagl.c
: initializer element is not constant
Yes the C preprocessor does not allow you to do that. Are you changing resolution runtime or do you configure the resolution when compiling? If the latter then you can use those configuration values as DISPLAY_WIDTH
and DISPLAY_HEIGHT
.
If you change resolution runtime you will run into other problems since code currently relies on DISPLAY_WIDTH
and DISPLAY_HEIGHT
to be defined on other places. Changing resolution runtime has not really been taken into account.
This could to be another reason why changing the API to include the surface in the API calls (see #43). Then one could do something like:
#include <hagl_hal.h>
#include <hagl.h>
surface_t s = hagl_init();
hagl_load_image(s, 0, 0, "/sdcard/foo.jpg");
hagl_hal_change_resolution(s, 320, 240);
hagl_set_clip_window(s, 0, 40, s.width, s.height - 40);
hagl_load_image(s, 0, 0, "/sdcard/bar.jpg");
hagl_close(s);
One thing to consider though is how often you have an embedded project where you to change display resolution on runtime.
I am changing the resolution at runtime. My CPU is testing my frame buffer hardware in various resolutions. My simple tests are running OK with the change to clip_window
initialization, so this is not a high priority. Let me get a more complete test working which I can show you, and which may suggest a better way forward, or perhaps that my application is an edge case not worth considering.
Sounds good!
Do not initialize clip_window if display width and height may be changed at runtime - rely on HAL to initialize instead.