Search Results

Search found 2 results on 1 pages for 'user3689'.

Page 1/1 | 1 

  • SDL beginner: create Rectangle surface filled with color

    - by user3689
    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 ?

    Read the article

  • How can I create a rectangular SDL surface filled with a particular color?

    - by user3689
    I'm learning SDL. I'd like to create rectangular surface filled with a flat color (not an image). Below is my code -- it compiles fine, but doesn't work. I'm passing the function these parameters: 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 am I doing wrong here?

    Read the article

1