Blit Bug?

Running this simple SDL program on windowsXP,DirectX9
when alt+tab and return I get “error: Blit surfaces
were lost, reload them” "error:
DirectDrawSurface3::Blt: Surface was lost"
What’s going on? It seems to still run. Tried to
SDL_SetVideoMode but it doesn’t fix it.
Here’s the code.

#include <SDL/SDL.h>
#include <windows.h>
SDL_Surface *screen;
int Gamestate;
Uint8 *keys;
enum { play, done };

SDLmain {
Gamestate = play;
SDL_Init( SDL_INIT_VIDEO ) ;
screen=SDL_SetVideoMode(800, 600, 0,
SDL_HWSURFACE|SDL_FULLSCREEN|SDL_DOUBLEBUF );
while( Gamestate < done){
SDL_Event ev;
while(SDL_PollEvent(&ev) > 0){
switch ( ev.type){

    	   case SDL_ACTIVEEVENT:              		   	   
           if( ev.active.gain ){ 
	        	if (SDL_BlitSurface(screen, 0, screen, 0)

== -2 )
fprintf(stderr, “SDL error: %s\n”,
SDL_GetError());
}

           break;
           default:    break;  
  }   }         
  keys = SDL_GetKeyState(NULL);        
  if ( keys[SDLK_ESCAPE] ) Gamestate = done;      
  SDL_FillRect(screen, 0, 0); 
  SDL_Flip(screen);    

}
fprintf(stderr, “SDL error: %s\n”, SDL_GetError());

SDL_Quit();
return 0; }__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Jason Robertson wrote:

Running this simple SDL program on windowsXP,DirectX9
when alt+tab and return I get “error: Blit surfaces
were lost, reload them” "error:
DirectDrawSurface3::Blt: Surface was lost"
What’s going on? It seems to still run. Tried to
SDL_SetVideoMode but it doesn’t fix it.
Here’s the code.

That’s documented. See the manpage for SDL_BlitSurface :

   If  either  of  the surfaces were in video memory, and the blit 

returns
-2, the video memory was lost, so it should be reloaded with
artwork
and re-blitted:

           while ( SDL_BlitSurface(image, imgrect, screen, dstrect) 

== -2 ) {
while ( SDL_LockSurface(image)) < 0 )
Sleep(10);
– Write image pixels to image->pixels –
SDL_UnlockSurface(image);
}

    This happens under DirectX 5.0 when the system switches away 

from your
fullscreen application. Locking the surface will also fail
until you
have access to the video memory again.

Stephane