Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Lags after changing resolution on-the-fly

This thread is locked; no one can reply to it. rss feed Print
Lags after changing resolution on-the-fly
Frenzy
Member #13,868
December 2011

Hello, i have a little problem here, i have display running on some predefined WIDTH and HEIGHT .. when i try to switch to fullscreen from windowed and using al_get_display_mode, al_set_new_display_flags(ALLEGRO_FULLSCREEN) and then al_destroy_display and al_create_display with new screen resolution from `al_get_display_mod`e .. my screen really lags .. changing back to windowed (again on the fly) didn't help.

I ve tried add counter before redrawing routine where is if(al_is_event_queue_empty(event_queue)) .. and counter is about 120 when it jumps in with normal screen but after resolution change it is about 600

Thanks for all advices

Trezker
Member #1,739
December 2001
avatar

I wonder if this is related to the behavior I've had with multiple displays. When switching focus from one to the other it takes more than a second before events come through to my program. Might not be related at all though.

Frenzy
Member #13,868
December 2011

Hm, maybe i use two monitors but dont work with it in allegro .. i will try to disconnect it

EDIT: still same lags :/ :)
EDIT 2: tried to delete event queue and register a new one, still lagging :/
EDIT 3: Fraps: before resize 60FPS, after 11FPS .. CPU: before 2% after 25%

jmasterx
Member #11,410
October 2009

It might lag because you lose your video bitmaps and they become memory bitmaps?

Itachihro
Member #12,001
May 2010

jmasterx said:

It might lag because you lose your video bitmaps and they become memory bitmaps?

Very likely, this. Try reloading your bitmaps, see if that helps.

Frenzy
Member #13,868
December 2011

Hmm that is highly possible .. i will definetly try it, but reloading mean only reloading or iniciating all bitmaps to null and then reload ?

J-Gamer
Member #12,491
January 2011
avatar

I think you'd want to free the memory they used first, then reload them.

" There are plenty of wonderful ideas in The Bible, but God isn't one of them." - Derezo
"If your body was a business, thought would be like micro-management and emotions would be like macro-management. If you primarily live your life with emotions, then you are prone to error on the details. If you over-think things all the time you tend to lose scope of priorities." - Mark Oates

Frenzy
Member #13,868
December 2011

Thank all of you. It's working now, it really was memory problem. Freeing memory and reloading bitmaps works :) THX a lot !

Dario ff
Member #10,065
August 2008
avatar

Isn't there a way to do it without loading again from the disk?(which is probably the biggest bottleneck without an SSD) I mean, if there's both a memory and video bitmap copy, shouldn't it be possible to use al_clone_bitmap or something like that to recreate the video bitmap from the memory bitmap and send it to the GPU again with the new display?

TranslatorHack 2010, a human translation chain in a.cc.
My games: [GiftCraft] - [Blocky Rhythm[SH2011]] - [Elven Revolution] - [Dune Smasher!]

Matthew Leverton
Supreme Loser
January 1999
avatar

Allegro 5.1 handles this automatically. Or you can use al_convert_bitmap() manually.

torhu
Member #2,727
September 2002
avatar

al_clone_bitmap works on 5.0.x, but memory is wasted somewhere when you use it that way.

Thomas Fjellstrom
Member #476
June 2000
avatar

torhu said:

al_clone_bitmap works on 5.0.x, but memory is wasted somewhere when you use it that way.

How much? I can't really imagine what it'd be unless you're forgetting to delete the old bitmap.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

torhu
Member #2,727
September 2002
avatar

I don't have a number for an individual bitmap, sorry. Memory use went up about 5 MB each time I cloned my 30 or so bitmaps. To try to reduce memory fragmentation, I tried cloning all bitmaps first, then destroying all in one go. But it didn't seem to matter.

Thomas Fjellstrom
Member #476
June 2000
avatar

If you have a test case, or ever try it again, please report it :)

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Go to: