CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2007
    Posts
    38

    SDL: Blit to a non-visible surface

    I am trying to write a method which returns an SDL_Surface*. The code I am using is:
    Code:
    SDL_Surface* SDLMenu::getSurface() {
    	//Create and unlock surface
    	SDL_Surface* output = SDL_CreateRGBSurface(SDL_SWSURFACE, 100, 25, 32, 0, 0, 0, 0);
    	SDL_UnlockSurface(output);
    
    	SDL_FillRect(output, 0, SDL_MapRGB(output->format, 255, 0, 255));
    
    	SDL_LockSurface(output);
    
    	return output;
    }
    The problem I have is when I call this function, the output shown is a black screen. Can anyone tell me where I'm going wrong?
    Code:
    	SDLApplication app;
    
    	SDLMenu menu = SDLMenu();
    	SDL_BlitSurface(menu.getSurface(), NULL, app.getScreen(), NULL);
    
    	SDL_Flip(app.getScreen());
    
    	SDL_Delay(10000);
    
    	return 0;
    Thanks,
    Gary

  2. #2
    Join Date
    Mar 2007
    Location
    Montreal, Quebec, Canada
    Posts
    185

    Re: SDL: Blit to a non-visible surface

    Since your masks are all zero, it filters out any colours you're trying to put. Hence why you have black

    Try putting this in:
    Code:
        Uint32 rmask, gmask, bmask, amask;
        rmask = 0x000000ff;
        gmask = 0x0000ff00;
        bmask = 0x00ff0000;
        amask = 0xff000000;
        
        SDL_Surface * output = SDL_CreateRGBSurface(SDL_SWSURFACE, 100, 25, 32,
            rmask, gmask, bmask, amask);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured