![]() |
|
Fullscreen toggle laggy? |
DaGamesta
Member #13,887
January 2012
|
Using the following code in the main loop: if (keysDown[ALLEGRO_KEY_F4]) { I am able to toggle fullscreen on and off. However, while the game runs fine normally in the (initial) windowed mode, when I toggle to fullscreen, it lags badly, and then upon toggling it back the lag remains. What am I doing wrong? |
Arthur Kalliokoski
Second in Command
February 2005
![]() |
Just guessing, but did you mean this? if (keysDown[ALLEGRO_KEY_F4]) { if (al_get_display_flags(display) & ALLEGRO_FULLSCREEN) al_set_new_display_flags(0); } else{ al_set_new_display_flags(ALLEGRO_FULLSCREEN); al_destroy_display(display); display = al_create_display(640,480); }
“Throughout history, poverty is the normal condition of man. Advances which permit this norm to be exceeded — here and there, now and then — are the work of an extremely small minority, frequently despised, often condemned, and almost always opposed by all right-thinking people. Whenever this tiny minority is kept from creating, or (as sometimes happens) is driven out of a society, the people then slip back into abject poverty. This is known as "bad luck.” ― Robert A. Heinlein |
Matthew Leverton
Supreme Loser
January 1999
![]() |
Recreate all your bitmaps after changing modes. |
Edgar Reynaldo
Member #8,592
May 2007
![]() |
There was a thread about this recently : It turned out for him, it was because the bitmaps became memory bitmaps, or else they were incompatible with the new display somehow. |
DaGamesta
Member #13,887
January 2012
|
Problem here is, I'm using Allegro 5.0.5, which doesn't have al_convert_bitmap. Also, I store all of my bitmaps in separate "sprite" classes, they'd be a major pain to keep track of separately. Is my only option to compile allegro 5.1 elsewise, though? |
Matthew Leverton
Supreme Loser
January 1999
![]() |
You should be able to do this as a temporary work around: void fix_bmp(ALLEGRO_BITMAP **bmp) { if (al_get_bitmap_flags(*bmp) & ALLEGRO_MEMORY_BITMAP) { ALLEGRO_BITMAP *tmp = *bmp; *bmp = al_clone_bitmap(*bmp); /* converts to video */ al_destroy_bitmap(tmp); } } fix_bmp(&sprite->bmp); al_draw_bitmap(sprite->bmp, x, y, 0);
|
DaGamesta
Member #13,887
January 2012
|
I feel very stupid for not thinking of that, or rather noticing that that function existed. Thank you very much for the help. |
Felix-The-Ghost
Member #9,729
April 2008
![]() |
Thomas Fjellstrom
Member #476
June 2000
![]() |
Felix-The-Ghost said: If I'm using A4 and I toggle fullscreen dynamically would I also need to refresh my bitmaps? Only if they are video bitmaps. Or possibly system bitmaps. If they were created via create_bitmap, you're fine. -- |
Felix-The-Ghost
Member #9,729
April 2008
![]() |
Ahh okay. And load_bitmap I assume. Is there anything else I'd need to do (aside from the different drawing code) I made a fullscreen toggle test waaaay back, ~A4.2 and I forgot what I did |
Arthur Kalliokoski
Second in Command
February 2005
![]() |
Seems to me you had to do a set_gfx_mode(GFX_TEXT,0,0,0,0); then you could reset a graphic mode. “Throughout history, poverty is the normal condition of man. Advances which permit this norm to be exceeded — here and there, now and then — are the work of an extremely small minority, frequently despised, often condemned, and almost always opposed by all right-thinking people. Whenever this tiny minority is kept from creating, or (as sometimes happens) is driven out of a society, the people then slip back into abject poverty. This is known as "bad luck.” ― Robert A. Heinlein |
Edgar Reynaldo
Member #8,592
May 2007
![]() |
If I don't do : set_gfx_mode(GFX_TEXT , 0 , 0 , 0 , 0); allegro_message("blah"); set_gfx_mode(NEW_MODE , W , H , 0 , 0); then the screen goes pink or doesn't display right on Windows. That's just what works for me. The problems were especially bad going from fullscreen to windowed mode. |
Felix-The-Ghost
Member #9,729
April 2008
![]() |
Thomas Fjellstrom
Member #476
June 2000
![]() |
I'd say the only purpose it serves is putting a delay between the two calls. Some glitch in allegro or the OS/drivers might not like it when the mode is changed too fast. -- |
Edgar Reynaldo
Member #8,592
May 2007
![]() |
Yeah, at least for me, the allegro message bit was necessary to properly change resolutions. I just use it to output the new resolution to the user. |
Felix-The-Ghost
Member #9,729
April 2008
![]() |
Thomas Fjellstrom
Member #476
June 2000
![]() |
If it is just a timing issue, a rest should work. -- |
Felix-The-Ghost
Member #9,729
April 2008
![]() |
Arthur Kalliokoski
Second in Command
February 2005
![]() |
I'd imagine a full second delay should work for anything. “Throughout history, poverty is the normal condition of man. Advances which permit this norm to be exceeded — here and there, now and then — are the work of an extremely small minority, frequently despised, often condemned, and almost always opposed by all right-thinking people. Whenever this tiny minority is kept from creating, or (as sometimes happens) is driven out of a society, the people then slip back into abject poverty. This is known as "bad luck.” ― Robert A. Heinlein |
Felix-The-Ghost
Member #9,729
April 2008
![]() |
Ah, alright. Sometimes I'm impressed with the speed of computers. I get awed when I make a function that loops a lot of y/x pixels and does something with them and the program still runs at dozens/frames/second |
weapon_S
Member #7,859
October 2006
![]() |
Nobody noticed that putting that in your main loop would try to create a new display for the number of times you check the keyboard while F4 is pressed down? (Or would the actual switch pause the program long enough to let you lift your finger?) And what does cdecl do?! |
Felix-The-Ghost
Member #9,729
April 2008
![]() |
Looks like cdecl is a name-space -- user defined or otherwise. weapon_S said: Nobody noticed that putting that in your main loop would try to create a new display for the number of times you check the keyboard while F4 is pressed down? I assume this does something about it: Quote: keysDown<ALLEGRO_KEY_F4> = false;
|
|