SWITCH_BACKGROUND hangs
locksleyu

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?

gnolam
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?

locksleyu

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, ..)

Neil Walker

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

locksleyu

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

Neil Walker

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 }

Evert
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

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!

Evert
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.

Thread #587627. Printed from Allegro.cc