|
This thread is locked; no one can reply to it. |
1
2
|
Reusing bitmaps after creating a new display |
Thomas Fjellstrom
Member #476
June 2000
|
Yeah, I don't know how likely it is that he's actually running out of video memory, unless he's leaking, or allegro is. -- |
torhu
Member #2,727
September 2002
|
I guess the question is: is Allegro leaking something? |
Thomas Fjellstrom
Member #476
June 2000
|
I don't think it is. Other people would have likely had problems by now. -- |
torhu
Member #2,727
September 2002
|
Guess I'll have to produce a test case then UPDATE: if (bitmap->locked) return NULL; Kind of embarrassing for me, don't you think? My collision testing code locks the bitmaps before using al_get_pixel on them, but didn't always unlock them. My original toggle_fullscreen_mode() function works fine after all, cloning the bitmaps once is enough. Thanks for trying to help, guys I have a bonus question: After toggling fullscreen, I would like to redraw the last frame. The menu screens in the game are just static images being drawn once, which means that the screen turns black after toggling the fullscreen mode. There is no way to get a copy of the front buffer, right? |
Thomas Fjellstrom
Member #476
June 2000
|
I'm not sure you can get the frontbuffer, its not always supported IIRC. But you can grab the backbuffer, just draw the screen again on switch? -- |
torhu
Member #2,727
September 2002
|
The backbuffer tends to not be the last frame, that's the problem... It's not hard to work around, but it means that my toggle_fullscreen_mode function can't be completely self-contained. There has to be code outside of it that knows about the switching. And just always copying the backbuffer before blitting seems like a waste. |
Trent Gamblin
Member #261
April 2000
|
Can you just call your "render" function again, if it's not all over the place?
|
torhu
Member #2,727
September 2002
|
I don't have a render function for the menu stuff, since it's just static. I guess I'll just make the menu code save the frame before calling al_flip_display(). When the actual game loop is running, I have to do some extra stuff anyway. Before calling toggle_fullscreen_mode() I stop the timers, and after calling it I call graphics_update() and then restart the timers. Unless the game was already paused, that is. |
Trent Gamblin
Member #261
April 2000
|
If it's static why can't you just draw it?
|
torhu
Member #2,727
September 2002
|
Well, it's not a single image, it's some text on a background, on another background. It's just that there's no animation. And there are several different screens like that. I can just add a global last_frame variable and make the menu code update that. Each menu has its own event loop, so the alternative would be to add code for handling the fullscreen switch in several places. UPDATE: static void update_display(void) { /* save the frame first, in case of a fullscreen switch */ al_set_target_bitmap(last_frame); al_draw_bitmap(al_get_backbuffer(display), 0, 0, 0); al_set_target_backbuffer(display); al_flip_display(); } But this function takes about half a second to run, which is very noticeable. The display is only 800x600x32. Why would it take so long, and is there a better way of doing this? |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Instead of drawing to 'last_frame' from the backbuffer, try just drawing your screen twice, once to 'last_frame', and once to the backbuffer before flipping. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
torhu
Member #2,727
September 2002
|
Thanks, that's better. I just draw the menu to a bitmap, then draw that to the backbuffer. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Assuming you don't use dirty rectangles and you make a full update of the display on every frame, then you don't need to draw twice, just call your display function on a different target just before you toggle fullscreen. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
torhu
Member #2,727
September 2002
|
The original problem was that I don't have a single update_display() function, so that won't work |
Edgar Reynaldo
Major Reynaldo
May 2007
|
torhu said: I don't have a single update_display() function, The Horror! My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Thomas Fjellstrom
Member #476
June 2000
|
If this is A5, drawing to video bitmaps can be slow on older/slower hardware (like intel gpus). -- |
|
1
2
|