im learning SDL , i like to create Rectangle surface with color
that is not image . here is my code that compiles fine but dosnt work :
im passing the function this params:
SDL_Surface* m_screen = SDL_SetVideoMode(SCREEN_WIDTH,SCREEN_HEIGHT,SCREEN_BPP,SDL_SWSURFACE);
SDL_FillRect(m_screen,&m_screen->clip_rect,SDL_MapRGB(m_screen->format,0xFF, 0xFF, 0xFF));
...
Button button(m_screen,0,0,50,50,255,0,0)
...
...
Button::Button(SDL_Surface* screen,int x,int y,int w,int h,int R, int G, int B)
{
SDL_Rect box;
SDL_Surface * ButtonSurface;
ButtonSurface = NULL ;
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
box.x = x;
box.y = y;
box.w = w;
box.h = h;
ButtonSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, box.w,box.h, 32,
rmask, gmask, bmask, amask);
if(ButtonSurface == NULL)
{
LOG_MSG("Button::Button Button failed");
}
SDL_FillRect(screen,&box,SDL_MapRGB ( ButtonSurface->format, R, G, B ));
//ut.ApplySurface(0,0,ButtonSurface,screen);
SDL_BlitSurface(ButtonSurface,NULL,screen,&box);
}
what im doing here wrong ?