Hi, I'm just wondering how to go about getting everything I've drawn onto a display's back buffer to line up after a resize event.
I'm a little un-sure how this works, but it seems to me that during a resize the buffer is stretched to match this display's new width/height (This is what I'd like to happen), but after the event completes the buffer is also re-sized so I end up with empty space on the right and bottom sides.
What I'm trying to do is, when the window is re-sized have whatever's drawn on the back buffer stretch to match the display.
I think this is all the relevant code:
Everything I draw throughout the project is based on SCREEN_W/SCREEN_H, so it would be a lot easier to leave them as is, and just alter the way the buffer is drawn on to the display. Sorry for needing spoon feeding.
If you want stretching, then you can use transformations. For your purposes I think this will be sufficient:
if(ev.type == ALLEGRO_EVENT_DISPLAY_RESIZE) { al_acknowledge_resize(ab.getDisplay()); ALLEGRO_TRANSFORMATION trans; al_identity_transform(&trans); al_scale_transform(al_get_display_width(ab.getDisplay()) / SCREEN_W, al_get_display_height(ab.getDisplay()) / SCREEN_H); al_use_transform(&trans); }
EDIT: Fixed fractions...
Thanks, I feel kind of bad. Now that transforms exist there's tonnes of questions with this exact answer. Thanks for the quick reply
SiegeLord, you also forgot the first argument to al_scale_transform. I'm not familiar with this function, but when I read the code I thought there was a magic global or something?!
SCREEN_W and SCREEN_H are the original window size (from the start of your program).
The compiler will remind me (or anyone using that code) of what I forgotten