Microsoft Windows Focus woes using OpenGL

Okay, is there a verified totally agreed on method for reacting to
losing/gaining focus under windows, and reloading textures appropriately?

I thought I had my app working fine, but have just discovered that although
it does reload the textures when you come back to the app from having tabbed
away, not all the textures are reloaded correctly. If I then manually
reload the textures (on key press), everything is fine. This suggests that
the are reloading at the wrong time … I guess?

I have further issues under windows when switching between windowed and full
screen mode. Switching to windowed mode generates the windows blue screen
of death (Windows XP Professional). I have the latest drivers for my
mobility ATI 9600. Surely I simply shouldn’t be able to do this, no matter
how badly I write my stock c++?

Here’s what I use for reloading textures, switching screen modes, etc:

case SDL_ACTIVEEVENT:
if ( event.active.state & SDL_APPACTIVE )
{
// If gained focus
if ( event.active.gain )
{
focus=focusMode::FOCUS;
// If in fullscreen mode, assume that the application has been alt+tabbed
away, and is regaining context
if( fullscreen )
{
setVideo(screen_width, screen_height, screen_depth,
fullscreen_flags);
reload();
}
}
// If iconified
else
focus=focusMode::MINIMISED;
}
else if( !(SDL_GetAppState() & SDL_APPINPUTFOCUS) )
focus=focusMode::NO_FOCUS;
break;

focus defines whether the application does any work, or simply sleeps
quietly in the background.
The setVideo function re-inits the video display.
The reload function reloads all the textures.

Okay, is there a verified totally agreed on method for reacting to
losing/gaining focus under windows, and reloading textures appropriately?

You never have to reload textures as a result of losing focus.

I have further issues under windows when switching between windowed and full
screen mode. Switching to windowed mode generates the windows blue screen
of death (Windows XP Professional). I have the latest drivers for my
mobility ATI 9600. Surely I simply shouldn’t be able to do this, no matter
how badly I write my stock c++?

Windows or your drivers are broken.

case SDL_ACTIVEEVENT:
if ( event.active.state & SDL_APPACTIVE )
{
// If gained focus
if ( event.active.gain )
{
focus=focusMode::FOCUS;
// If in fullscreen mode, assume that the application has been alt+tabbed
away, and is regaining context
if( fullscreen )
{
setVideo(screen_width, screen_height, screen_depth,
fullscreen_flags);
reload();

Why touch the video mode? If you change the video mode, you are going to
have to reinit the context–but you don’t have to do that.On Thu, Jun 03, 2004 at 12:09:15PM +1000, Rob Sadedin wrote:


Glenn Maynard

I thought that I needed to get a new buffer handle from opengl when you gain
focus after switching back to the desktop? Is this not so?

I’m worried about the thought of my drivers being broken, since the laptop
manufacturer doesn’t release that often.

If I don’t have to reload textures upon losing focus … when do I need to?
What should I check for to determine if I need to reload all my textures or
not … under windows, this is, of course.> ----- Original Message -----

From: g_sdl@zewt.org (Glenn Maynard)
To:
Sent: Thursday, June 03, 2004 12:20 PM
Subject: Re: [SDL] Microsoft Windows Focus woes using OpenGL

On Thu, Jun 03, 2004 at 12:09:15PM +1000, Rob Sadedin wrote:

Okay, is there a verified totally agreed on method for reacting to
losing/gaining focus under windows, and reloading textures
appropriately?

You never have to reload textures as a result of losing focus.

I have further issues under windows when switching between windowed and
full

screen mode. Switching to windowed mode generates the windows blue
screen

of death (Windows XP Professional). I have the latest drivers for my
mobility ATI 9600. Surely I simply shouldn’t be able to do this, no
matter

how badly I write my stock c++?

Windows or your drivers are broken.

case SDL_ACTIVEEVENT:
if ( event.active.state & SDL_APPACTIVE )
{
// If gained focus
if ( event.active.gain )
{
focus=focusMode::FOCUS;
// If in fullscreen mode, assume that the application has been
alt+tabbed

away, and is regaining context
if( fullscreen )
{
setVideo(screen_width, screen_height, screen_depth,
fullscreen_flags);
reload();

Why touch the video mode? If you change the video mode, you are going to
have to reinit the context–but you don’t have to do that.


Glenn Maynard


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl