Original Post
hi, I have this problem with SDL. I want to create a small SDL_Surface, fill it with some color,
then blit it to the screen surface. I do that, but when I use SDL_Flip the small surface is not
shown... I have make a small example, could someone please tell me what I am doind wrong?
int main( int argc, char* argv[] )
{
/* SDL init */
if( SDL_Init ( SDL_INIT_VIDEO ) == -1 ) {
// error
}
atexit(SDL_Quit);
SDL_Surface* s = SDL_SetVideoMode(200, 200, 0, SDL_SWSURFACE | SDL_DOUBLEBUF );
/* Create new SDL_Surface (exemple from the docs) */
Uint32 rmask, gmask, bmask, amask;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
rmask = 0xff000000;
gmask = 0x00ff0000;
bmask = 0x0000ff00;
amask = 0x000000ff;
#else
rmask = 0x000000ff;
gmask = 0x0000ff00;
bmask = 0x00ff0000;
amask = 0xff000000;
#endif
SDL_Surface *p = SDL_CreateRGBSurface(SDL_SWSURFACE, 20, 20, 32, rmask, gmask, bmask, amask);
/* fill the SDL_Surface - WHITE is defined with the white hexadecimal code */
SDL_FillRect(p,NULL,WHITE);
/* blit p to s */
SDL_Rect temp = {10,10,200,200};
SDL_BlitSurface(p,NULL,s,&temp);
/* flip the screen surface */
SDL_Flip(s);
/* whait for click */
SDL_Event event;
while (true)
{
while(SDL_PollEvent(&event)) {
if( event.type == SDL_QUIT )
return 0;
if( event.type == SDL_MOUSEBUTTONDOWN )
return 0;
}
}
return 0;
}
|