[SDL] Trying to display a colored surface

Carlos citrouille at wanadoo.fr
Sun Jul 14 23:23:00 PDT 2002


I already know how to setup a screen window, that's why I don't specify the code for the screen variable. Below the comments " /* window  ... */ ", just after le SDL_Rect declaration, you must understand that I put a window setup for "screen" (which uses le SDL_SetVideoMode)

Just the think I want to do, is drawing a little square into the screen WITH the "test" variable...
> > 
> > So i do this
> > 
> > *****
> > 
> > SDL_Surface *screen;
> > SDL_Surface *test;
> > SDL_Rect r;
> > /* window setup an screen setup */
> > 
> > test = SDL_CreateRGBSurface(SDL_SWSURFACE,100,100,16,rmask,gmask,bmask,amask); //square setup
> > 
> > r.x = 100; r.y = 100;
> > while(1) //main loop
> > {
> >   SDL_FillRect(screen, NULL, 0x00000000); //I color my screen to black
> >   SDL_FillRect(test, NULL, 0xFFFFFF00); //I want to color my square to white
> >   SDL_BlitSurface(test,NULL,screen,&r); //then draw it, this doen't work
> > 
> >   SDL_Flip(screen);		
> > }
> > 
> > what can I do to just display a little colored square if not what I writen ???
> > 
> 
> To setup a window you must use SDL_SetVideoMode().
> SDL_CreateRGBSurface() creates an offscreen surface. I suggest you to
> read some tutorials.
> 
> 
> 
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl




More information about the SDL mailing list