Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » SWITCH_BACKGROUND hangs

This thread is locked; no one can reply to it. rss feed Print
SWITCH_BACKGROUND hangs
locksleyu
Member #7,742
September 2006

My application, which is normally very stable, tends to hang when not the active window whenever I run with set_display_switch_mode(SWITCH_BACKGROUND). I am calling acquire_screen() and release_screen() before and after any writes to the screen, but this doesn't seem to help.

I'm using Allegro 4.2.0 under Windows 2000 professional and Visual Studio 2005.

Can anyone get SWITCH_BACKGROUND to work?

ARTSG: Real-Time Strategy game: http://artsg.pbwiki.com/

gnolam
Member #2,030
March 2002
avatar

Quote:

I am calling acquire_screen() and release_screen() before and after any writes to the screen, but this doesn't seem to help.

You're not doing anything else except blitting operations to the screen between those calls are you?

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

locksleyu
Member #7,742
September 2006

I am only doing circle(), line(), rect() and draw_sprite() between the acquire and the release. I am using double buffering so I do most of the normal drawing to my active page, and then I call draw_sprite(screen, active_page, ..)

ARTSG: Real-Time Strategy game: http://artsg.pbwiki.com/

Neil Walker
Member #210
April 2000
avatar

I take it you know switch_background doesn't actually work in windows fullscreen mode?

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

locksleyu
Member #7,742
September 2006

I'm running in windowed mode with videomode GFX_GDI. SWITCH_BACKGROUND works in this mode, right?

ARTSG: Real-Time Strategy game: http://artsg.pbwiki.com/

Neil Walker
Member #210
April 2000
avatar

I can only imagine so, but you should always test the return value. In my code I allow swapping between windowed/fullscreen and various other modes so I simply code for the bare minimum that should work for windows and other o/s's, as in:

1 if(set_display_switch_mode(SWITCH_PAUSE)==0)
2 Configuration::LogEntry("Switch mode set to PAUSE");
3 else
4 {
5 Configuration::LogEntry("Failed. Trying SWITCH_AMNESIA");
6 if(set_display_switch_mode(SWITCH_AMNESIA)==0)
7 Configuration::LogEntry("Switch mode set to SWITCH_AMNESIA - pause/resume but buffer needs refreshing on focus");
8 else
9 {
10 Configuration::LogEntry("Failed. Trying SWITCH_BACKAMNESIA");
11 if(set_display_switch_mode(SWITCH_BACKAMNESIA)==0)
12 Configuration::LogEntry("Switch mode set to SWITCH_AMNESIA - run in background but buffer needs refreshing on focus");
13 else
14 Configuration::LogEntry("Switch mode failed to set SWITCH_BACKAMNESIA. Nothing Done!");
15 }
16 }

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

Evert
Member #794
November 2000
avatar

Quote:

set_display_switch_mode(SWITCH_BACKGROUND)

You did remember to checkthereturn value, right?
If that doesn't work (but BACK_AMNESIA does), you probably should not be writing to screen when your program is swapped out.

Quote:

SWITCH_BACKGROUND works in this mode, right?

I wouldn't know, but why don't you check the return value and find out?

locksleyu
Member #7,742
September 2006

I changed my video mode from GFX_GDI to GFX_DIRECTX_WIN and the hangs have stopped.

By the way, the call to set_display_switch_mode(SWITCH_BACKGROUND) was returning 0.

Thanks for the help everyone!

ARTSG: Real-Time Strategy game: http://artsg.pbwiki.com/

Evert
Member #794
November 2000
avatar

Quote:

I changed my video mode from GFX_GDI to GFX_DIRECTX_WIN and the hangs have stopped.

Any particular reason you're not using GFX_AUTODETECT_WINDOWED? If not, you should use that instead of any other driver.

Go to: