With the following code, in window mode, there’s no problem (the windows is
white for some seconds, then yellow for some).
In fullscreen mode (under Linux it works, and there no way to get hardware
surfaces…), instead, the screen becomes white again after a second about.
The “nice” thing is that with page flipping it works.
If I change the last SDL_Delay() with a loop where I poll for events, it
works. If I change with an empty loop, it doesn’t work.
So, do I just have SDL to continuosly have a function called for working
correctly, or what?
It also works if I just put everything into a loop. So, I must think that
SDL need a continuos call od functions…?
This is the code:
#include <SDL.h>
#include <stdlib.h>
int main( int argc, char *argv[] )
{
SDL_Surface *screen;
SDL_Color colors[256];
int i;
SDL_Init( SDL_INIT_VIDEO );
screen = SDL_SetVideoMode( 800, 600, 8, SDL_HWPALETTE
| SDL_FULLSCREEN /*| SDL_DOUBLEBUF */);
for( i = 0; i < 256; i++ ) {
colors[i].r = 255;
colors[i].g = 255;
colors[i].b = 255;
}
SDL_SetColors( screen, colors, 0, 256 );
i = rand() % 256;
SDL_FillRect( screen, NULL, i );
//SDL_UpdateRect( screen, 0, 0, 0, 0 );
SDL_Flip( screen );
SDL_Delay( 4000 );
colors[i].r = 255;
colors[i].g = 255;
colors[i].b = 0;
SDL_SetColors( screen, &colors[ i ], i, 1 );
//SDL_FillRect( screen, NULL, i );
//SDL_UpdateRect( screen, 0, 0, 0, 0 );
SDL_Delay( 8000 );
/*bool done = 0;
SDL_Event event;
while ( !done ) {
SDL_PollEvent(&event);
if ( event.type == SDL_QUIT )
done = 1;
if ( event.type == SDL_KEYDOWN )
switch( event.key.keysym.sym ) {
case SDLK_ESCAPE:
done = 1;
break;
}
}*/
SDL_Quit();
return 0;
}