Open BluebirdGreycoat opened 1 year ago
After putting some more logging statements into my code, I've found that al_get_display_width/height
do return the correct window dimensions at some point after the display is created and before the event loop begins (there being a delay, due to a lot of other work, of maybe a few milliseconds). This makes me think there is a race condition somewhere?
I am definitely not getting a ALLEGRO_EVENT_DISPLAY_RESIZE
to notify this, though.
No bones about it, this is going to require me to update my wrapper code around Allegro to poll al_get_display_width/height
at the beginning of every frame and manually synthesize an ALLEGRO_EVENT_DISPLAY_RESIZE
event if the returned values are changed from a previous poll.
It's bugged, Jim.
[EDIT] Yes, with this bug, I have to poll, because otherwise I won't know when to call al_acknowledge_resize
. Tested, and yes, although the display fills the desktop monitor, because I don't get an ALLEGRO_EVENT_DISPLAY_RESIZE
, I end up not calling al_acknowledge_resize
and thus the part of the display outside the initial 800x600 area remains black, nothing drawable there.
What OS is this?
And finally, for the future is it better to post my issues here instead of on allegro.cc?
It's always better to post them here. We also have a Discord/IRC, but those are ephemeral. If the issue isn't also posted here, it might as well not exist.
I'm using Linux, KDE.
I've noticed on Mac and Windows that the dimensions you give to al_create_display (windowd mode) will be what al_get_display_width/height return .... until you resize it! At that point, allegro seems to learn about the actual size of the content. For example, on Mac that size of the menu bar and the dock eat into the possible content height, yet that is only reflected on the allegro display object after a resize. I believe I found the same to be true on Windows.
I work around it by doing this right after creating a display:
al_resize_display(_a5_display, al_get_display_width(_a5_display), al_get_display_height(_a5_display));
After this call, the display has accurate dimensions.
I am seeing this behaviour with 5.2.8 on Linux with GNOME running on Wayland. al_get_display_width and al_get_display_height immediately after the call to al_set_display_flag report the window size rather than the full screen size for a few frames.
What I suspect is going on is that there is a brief animation to transition the windows to full screen and I think the correct size is reported once the animation is complete. The delay before the size updates is about 5-6 frames.
By Allegro 5.2.9 it is completely broken in that attempting to set ALLEGRO_FULLSCREEN_WINDOW to true returns false.
I copied the following from the allegro.cc forum where I first posted it, before seeing this github page:
Ok, so somewhere between a previous version of A5 and the current (5.2.8.0), something changed in regard to display dimensions immediately after creating a display.
Previously, I could
create a displayset up display flags with ALLEGRO_FULLSCREEN_WINDOW, then do al_create_display(800, 600), and the dimensions DIRECTLY after display creation would be the dimensions of my desktop [edit: as reported byal_get_display_width
, etc.]. I could then cache these dimensions and update them only when receiving a ALLEGRO_EVENT_DISPLAY_RESIZE, thus avoiding having to constantly poll with al_get_display_width, etc.However, now when I create my display, the display immediately fills the desktop monitor, but calling al_get_display_width immediately after creating the display returns 800! And I never get a ALLEGRO_EVENT_DISPLAY_RESIZE to represent the fact that the window changed size to fill the screen.
Should I just give up trying to cache the display dimensions and poll al_get_display_width, etc. on every frame?
And finally, for the future is it better to post my issues here instead of on allegro.cc? Just asking because the forum seemed a little slow ....