Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Using allegro I can create a Bitmap to draw just doing:

BITMAP* bmp = NULL;
bmp = create_bitmap(width,height); // I don't remember exactly the parameters

I'm using SDL now, and i want create an SDL_Surface to draw the game level (that is static). I create an SDL_Surface, draw the tiles on it, then just blit this surface to the screen instead of drawing the tiles directly on screen (I believe this will require more processing);

Is there a way to create a blank SDL_Surface as I did with Allegro to draw before I blit it?

share|improve this question
1  
If you care about searching on the sdl documentation, yes, there are. –  Gustavo Maciel Mar 18 '12 at 17:25
    
Also, I'd check Lazy Foo', as he does a lot of really good stuff regarding SDL, including Surface stuff. –  thePalindrome Mar 19 '12 at 4:51

2 Answers 2

up vote 2 down vote accepted

You are looking for this function:

SDL_Surface* SDL_CreateRGBSurface(Uint32 flags, int width, int height, int bitsPerPixel,
             Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);

Check the docs to see what to pass as each argument.

share|improve this answer

Normally you set up an

SDL_Surface * screen;

which is a pointer to a spot of memory that stores pixel information for a given resolution and color depth. You create one as a screen initially and manage it with a SetVideoMode function. You can then blit all of your images onto screen and flip the buffers at the end of your main loop.

You may also want to look into SDL_Image to make loading and working with various image files easier. Also as someone else mentioned, I highly recommend Lazy Foo's Tutorials. There is information on his site about setting up and using SDL_Image.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.