How to use multiple surfaces?

hey everyone,

At the moment, I am developing my editor for my game, and I have hit a
cropper. I am trying to use multiple SDL_Surface’s on the screen, so that I
can have different parts to the editor. When I try to do this, it causes
the program to crash. Here is the part of the code:

 extern SDL_Surface *sScreen;       /* main SDL surface */
 SDL_Surface *sEditor;              /* The editor screen */
 SDL_Surface *sTileset;             /* The tileset used for the level */


/* The current color to fill */
Uint32 color;

/* We define the editing area */
SDL_Rect editarea;
    editarea.w = 400;
    editarea.h = 480;
    editarea.x = 0;
    editarea.y = 0;

/* Next we need the editing area */
color = SDL_MapRGB (sScreen->format, 0, 255, 0);
SDL_FillRect(sEditor,&editarea,color);

Basicly, when I try to draw the sEditor surface onto the screen by doing the
FillRect, it causes the program to crash. Where am I going wrong with
this? Basicly, what I am TRYING to do is use the sScreen surface to blit
the editor cursor, which is the current tile selected, then when the user
clicks the mouse, I want to blit that to the sEditor surface at the current
mouse x,y coords, and this surface and be exported to BMP later. I can’t
find any examples of this anywhere, only samples that use 1 surface, which
is no use to me.

Thanks in advance for any help.

Tane
http://tane.cream.org

Tane Piper wrote:

Basicly, when I try to draw the sEditor surface onto the screen by
doing the FillRect, it causes the program to crash. Where am I
going wrong with this?

FillRect doesn’t draw a surface to the screen, and the sEditor surface
isn’t even created at that point(assuming you haven’t omitted important
code) - it’s just a dangling pointer.–
Kylotan
http://pages.eidosnet.co.uk/kylotan

I think you want to blit the editor surface to the screen surface.

#include "SDL.h"SDL_Rect myRect;

myrect.x = 0;
myrect.y = 0;
myrect.w = 400;
myrect.h = 480;

SDL_BlitSurface(sEditor *src, myRect, screen, myRect);