How to copy sdl_Surface from pointer c++

Hello.
I must do some solution in my game but I don’t know how to do it.

I have:

char * filedata; - parsed from huge datafile container
SDL_Surface * srfdest; - destination surface

How to copy filedata to srfdest.

Greetings

Hey David!

check this out:

http://sdldoc.csn.ul.ie/sdlcreatergbsurfacefrom.php

SDL_CreateRGBSurfaceFrom seems to be the function you need

SDL_Surface *SDL_CreateRGBSurfaceFrom(void *pixels, int width, int height,
int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32
Amask);

Hope this helps,
Atrix> ----- Original Message -----

From: kofianan@poczta.onet.pl (Dawid Makowski)
To:
Sent: Wednesday, August 20, 2003 2:30 AM
Subject: [SDL] How to copy sdl_Surface from pointer c++

Hello.
I must do some solution in my game but I don’t know how to do it.

I have:

char * filedata; - parsed from huge datafile container
SDL_Surface * srfdest; - destination surface

How to copy filedata to srfdest.

Greetings


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Uzytkownik “Atrix Wolfe” napisal w wiadomosci
news:077001c36793$2b262740$6401a8c0 at atrix…

Hey David!

check this out:

http://sdldoc.csn.ul.ie/sdlcreatergbsurfacefrom.php

SDL_CreateRGBSurfaceFrom seems to be the function you need

SDL_Surface *SDL_CreateRGBSurfaceFrom(void *pixels, int width, int height,
int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32
Amask);

Hope this helps,
Atrix

Nope.
I don’t know how is the width, height etc.
I have only pointer to data in memory.
Maybe I must overload method IMG_Load> ----- Original Message -----

From: “Dawid Makowski” <@Dawid_Makowski>
To:
Sent: Wednesday, August 20, 2003 2:30 AM
Subject: [SDL] How to copy sdl_Surface from pointer c++

Hello.
I must do some solution in my game but I don’t know how to do it.

I have:

char * filedata; - parsed from huge datafile container
SDL_Surface * srfdest; - destination surface

How to copy filedata to srfdest.

Greetings


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

how is it that you dont know the width and height?

where are you getting this data from?> ----- Original Message -----

From: kofianan@poczta.onet.pl (Dawid Makowski)
To:
Sent: Thursday, August 21, 2003 6:03 AM
Subject: [SDL] Re: How to copy sdl_Surface from pointer c++

Uzytkownik “Atrix Wolfe” <@atrix2> napisal w wiadomosci
news:077001c36793$2b262740$6401a8c0 at atrix…

Hey David!

check this out:

http://sdldoc.csn.ul.ie/sdlcreatergbsurfacefrom.php

SDL_CreateRGBSurfaceFrom seems to be the function you need

SDL_Surface *SDL_CreateRGBSurfaceFrom(void *pixels, int width, int
height,

int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32
Amask);

Hope this helps,
Atrix

Nope.
I don’t know how is the width, height etc.
I have only pointer to data in memory.
Maybe I must overload method IMG_Load

----- Original Message -----
From: “Dawid Makowski”
To:
Sent: Wednesday, August 20, 2003 2:30 AM
Subject: [SDL] How to copy sdl_Surface from pointer c++

Hello.
I must do some solution in my game but I don’t know how to do it.

I have:

char * filedata; - parsed from huge datafile container
SDL_Surface * srfdest; - destination surface

How to copy filedata to srfdest.

Greetings


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hello,

One more quick question because I am too lazy to look it up, and/or
figure it out… If I have two images on the screen, say a scrolling
background and a sprite, how do I layer these images? Example code
helps immensely, thank you much,

Max
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: text/enriched
Size: 268 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20030824/1b3d3eb8/attachment.bin

sorry, i reread your origional message, you HAVE to know the width and the
height to load image data from a pointer. How is SDL supposed to know the
size of your image if you dont tell it?

if you made the program to make your datafile container, you should make it
store the width and the height and any other data you need before the image
data. Thats what i do (:

hope this helps,
Atrix> ----- Original Message -----

From: @atrix2 (atrix2)
To:
Sent: Sunday, August 24, 2003 7:53 PM
Subject: Re: [SDL] Re: How to copy sdl_Surface from pointer c++

how is it that you dont know the width and height?

where are you getting this data from?

----- Original Message -----
From: “Zolthar”
To:
Sent: Thursday, August 21, 2003 6:03 AM
Subject: [SDL] Re: How to copy sdl_Surface from pointer c++

Uzytkownik “Atrix Wolfe” <@atrix2> napisal w wiadomosci
news:077001c36793$2b262740$6401a8c0 at atrix…

Hey David!

check this out:

http://sdldoc.csn.ul.ie/sdlcreatergbsurfacefrom.php

SDL_CreateRGBSurfaceFrom seems to be the function you need

SDL_Surface *SDL_CreateRGBSurfaceFrom(void *pixels, int width, int
height,

int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32
Amask);

Hope this helps,
Atrix

Nope.
I don’t know how is the width, height etc.
I have only pointer to data in memory.
Maybe I must overload method IMG_Load

----- Original Message -----
From: “Dawid Makowski”
To:
Sent: Wednesday, August 20, 2003 2:30 AM
Subject: [SDL] How to copy sdl_Surface from pointer c++

Hello.
I must do some solution in my game but I don’t know how to do it.

I have:

char * filedata; - parsed from huge datafile container
SDL_Surface * srfdest; - destination surface

How to copy filedata to srfdest.

Greetings


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

— Max Countryman wrote:

One more quick question because I am too lazy to look it up, and/or
figure it out… If I have two images on the screen, say a scrolling
background and a sprite, how do I layer these images? Example code
helps immensely, thank you much,

I don’t think there’s specific functionality for this built into SDL,
but SDL does support it very nicely. The use of SDL_Surface to store
graphic data that is kept separate and then blitted sequentially to the
display (prior to the buffer flip) should fill your need excellently.

In my current project (a tile-based tactical RPG), the background for
a
level is built from a dataset and a .bmp that contains images for each
tile. A factory object builds the Stage object out of the data and the
images, blitting from the SDL_Surface with the tile images to a
Surface made to store the terrain for that level. Then the Actor
objects are read in from storage and associated with their image data
from other .bmps.

As the game runs, a sub-section of the terrain is blitted to the
main-display (scrolling used to work, I broke it yesterday 'cause it
was badly in need of re-implmentation), then the Actor objects, all of
which know how to draw themselves and are aware of their position,
blit themselves on top of the terrain.

                                                           NBarnes__________________________________

Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software

Ah, it’s that last bit that I need, blit on top of another image; how
do I do this? Is it the order of the blits, if so, that doesn’t seem to
be working… Thanks for your help,

MaxOn Sunday, August 24, 2003, at 08:42 PM, NBarnes wrote:

— Max Countryman <@Max_Countryman> wrote:

One more quick question because I am too lazy to look it up, and/or
figure it out… If I have two images on the screen, say a scrolling
background and a sprite, how do I layer these images? Example code
helps immensely, thank you much,

I don’t think there’s specific functionality for this built into SDL,
but SDL does support it very nicely. The use of SDL_Surface to store
graphic data that is kept separate and then blitted sequentially to the
display (prior to the buffer flip) should fill your need excellently.

In my current project (a tile-based tactical RPG), the background for
a
level is built from a dataset and a .bmp that contains images for each
tile. A factory object builds the Stage object out of the data and the
images, blitting from the SDL_Surface with the tile images to a
Surface made to store the terrain for that level. Then the Actor
objects are read in from storage and associated with their image data
from other .bmps.

As the game runs, a sub-section of the terrain is blitted to the
main-display (scrolling used to work, I broke it yesterday 'cause it
was badly in need of re-implmentation), then the Actor objects, all of
which know how to draw themselves and are aware of their position,
blit themselves on top of the terrain.

                                                           NBarnes

Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

— Max Countryman wrote:

Ah, it’s that last bit that I need, blit on top of another image; how
do I do this? Is it the order of the blits, if so, that doesn’t seem
to be working… Thanks for your help,

Blitting over something isn’t any different than, well, not blitting
over something. The biggest think you need to know is SDL_SetColorKey
(it’s in the documentation) to set the transparency color for your
second blit, so the parts that aren’t supposed to be there aren’t
there.

doBlit() {
SDL_Surface *mainDisplay = SDL_SetVideoMode(600, 800, 0,
SDL_HWSURFACE|SDL_DOUBLEBUF);
SDL_Surface *background = SDL_LoadBMP(“background.bmp”);
SDL_Surface *sprite = SDL_LoadBMP(“sprite.bmp”);
SDL_SetColorKey(sprite, SDL_SRCCOLORKEY, SDL_MapRGB(sprite->format, 0,
255, 255));
//Assume the correct SDL_Rects in the blit calls, since reading how
they’re created won’t enlighten you for this purpose
SDL_BlitSurface(background, backgroundSourceRect, mainDisplay,
backgroundTargetRect);
SDL_BlitSurface(sprite, spriteSourceRect, mainDisplay,
spirteTargetRect);
SDL_Flip(mainDisplay);
}

And the sprite will appear over the background on the display, with
the areas of the sprite bitmap that are color 0, 255, 255 not
appearing.

                                                          NBarnes__________________________________

Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software

Sorry, the e-mail that followed this up got hosed by spam in the mailing
list filter. The orignal poster wrote that he found out about SDL_rwops,
and that solved his problem nicely. Apparently he had the raw image data
as an image file, which contained all the information necessary for IMG_load
to load it.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Ok… I still don’t understand why one image should appear above
another. Right now my two images are fighting to be on top of
one-another. Causing a horrible flicker. I thought that I should need
to somehow tell one image to be on top of the other… Thanks again,

MaxOn Sunday, August 24, 2003, at 09:45 PM, NBarnes wrote:

— Max Countryman <@Max_Countryman> wrote:

Ah, it’s that last bit that I need, blit on top of another image; how
do I do this? Is it the order of the blits, if so, that doesn’t seem
to be working… Thanks for your help,

Blitting over something isn’t any different than, well, not blitting
over something. The biggest think you need to know is SDL_SetColorKey
(it’s in the documentation) to set the transparency color for your
second blit, so the parts that aren’t supposed to be there aren’t
there.

doBlit() {
SDL_Surface *mainDisplay = SDL_SetVideoMode(600, 800, 0,
SDL_HWSURFACE|SDL_DOUBLEBUF);
SDL_Surface *background = SDL_LoadBMP(“background.bmp”);
SDL_Surface *sprite = SDL_LoadBMP(“sprite.bmp”);
SDL_SetColorKey(sprite, SDL_SRCCOLORKEY, SDL_MapRGB(sprite->format, 0,
255, 255));
//Assume the correct SDL_Rects in the blit calls, since reading how
they’re created won’t enlighten you for this purpose
SDL_BlitSurface(background, backgroundSourceRect, mainDisplay,
backgroundTargetRect);
SDL_BlitSurface(sprite, spriteSourceRect, mainDisplay,
spirteTargetRect);
SDL_Flip(mainDisplay);
}

And the sprite will appear over the background on the display, with
the areas of the sprite bitmap that are color 0, 255, 255 not
appearing.

                                                          NBarnes

Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

— Max Countryman wrote:

Ok… I still don’t understand why one image should appear above
another. Right now my two images are fighting to be on top of
one-another. Causing a horrible flicker. I thought that I should need
to somehow tell one image to be on top of the other…

That sounds like you might not be using a double buffered surface
as your main display and then calling SDL_Flip(mainDisplay) to
change the view. Updating the surface when it’s being displayed
can cause effects like you describe.

                                                       NBarnes__________________________________

Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software

Once you drew the “topmost” image, you just stop blitting… The fewer
Blits, the
smoother your app gets. Also try to blit small areas, if possible.
The just blit faster.

Good Luck.

Juan Ignacio Carniglia - Programmer - Buenos Aires, Argentina.> -----Original Message-----

From: sdl-admin at libsdl.org [mailto:sdl-admin at libsdl.org] On
Behalf Of NBarnes
Sent: Monday, August 25, 2003 3:09 AM
To: sdl at libsdl.org
Subject: Re: [SDL] Layers

— Max Countryman wrote:

Ok… I still don’t understand why one image should appear above
another. Right now my two images are fighting to be on top of
one-another. Causing a horrible flicker. I thought that I
should need
to somehow tell one image to be on top of the other…

That sounds like you might not be using a double buffered
surface as your main display and then calling
SDL_Flip(mainDisplay) to change the view. Updating the
surface when it’s being displayed can cause effects like you describe.

                                                       NBarnes

Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design
software http://sitebuilder.yahoo.com


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

— Juan Ignacio Carniglia wrote:

Once you drew the “topmost” image, you just stop blitting… The
fewer Blits, the smoother your app gets. Also try to blit small
areas, if possible. The just blit faster.

It seems to me that ‘fewer blits’ is really a relative term, though.
Running something like an advanced side-scroller (Raiden or similar)
would involve two or three dozen blits per frame of game, yes? For
my game, I’m absolutely planning on having up to four PCs, between
one and fifteen enemy combatants, random non-character objects, and
further SFX onscreen at once, which would easily account for several
dozen blits per frame. Small blits, to be sure, but lots of them.

                                                          NBarnes__________________________________

Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software

What I meant, is that if your sprite didn?t change in position, then
you don?t have to redraw it, which seemed what Max was doing.

Of course, the more objects you have on screen, the more Blits you will
end up doing. You can only hope for them to be small and fast (with
RLEACCEL).

Juan Ignacio Carniglia - Programmer - Buenos Aires, Argentina.> -----Original Message-----

From: sdl-admin at libsdl.org [mailto:sdl-admin at libsdl.org] On
Behalf Of NBarnes
Sent: Monday, August 25, 2003 9:21 AM
To: sdl at libsdl.org
Subject: RE: [SDL] Layers

— Juan Ignacio Carniglia <@Juan_Ignacio_Carnigl> wrote:

Once you drew the “topmost” image, you just stop
blitting… The fewer
Blits, the smoother your app gets. Also try to blit small areas, if
possible. The just blit faster.

It seems to me that ‘fewer blits’ is really a relative term,
though. Running something like an advanced side-scroller
(Raiden or similar) would involve two or three dozen blits
per frame of game, yes? For my game, I’m absolutely planning
on having up to four PCs, between one and fifteen enemy
combatants, random non-character objects, and further SFX
onscreen at once, which would easily account for several
dozen blits per frame. Small blits, to be sure, but lots of them.

                                                          NBarnes

Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design
software http://sitebuilder.yahoo.com


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Uzytkownik “Atrix Wolfe” napisal w wiadomosci
news:00de01c36ab4$197a7860$6501a8c0 at atrix…

how is it that you dont know the width and height?

where are you getting this data from?

I have my own data container where files are packed into one file. I don’t
know what format of each file is.
But I found the solution.
SDL give us some function to load SDL_Surface from data pointer.

this is some examle

SDL_RWops *rwops = SDL_RWFromMem (<const char *>, );
SDL_Surface *imgtmp = IMG_Load_RW(rwops, 1);

Result is imgtmp. It’s now my new SDL_Surface. I didn’t know what format
was.
SDL_RWFromMem and IMG_Load_RW parses these informations from data.>

----- Original Message -----
From: “Zolthar” <@Dawid_Makowski>
To:
Sent: Thursday, August 21, 2003 6:03 AM
Subject: [SDL] Re: How to copy sdl_Surface from pointer c++

Uzytkownik “Atrix Wolfe” napisal w wiadomosci
news:077001c36793$2b262740$6401a8c0 at atrix…

Hey David!

check this out:

http://sdldoc.csn.ul.ie/sdlcreatergbsurfacefrom.php

SDL_CreateRGBSurfaceFrom seems to be the function you need

SDL_Surface *SDL_CreateRGBSurfaceFrom(void *pixels, int width, int
height,

int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32
Amask);

Hope this helps,
Atrix

Nope.
I don’t know how is the width, height etc.
I have only pointer to data in memory.
Maybe I must overload method IMG_Load

----- Original Message -----
From: “Dawid Makowski” <@Dawid_Makowski>
To:
Sent: Wednesday, August 20, 2003 2:30 AM
Subject: [SDL] How to copy sdl_Surface from pointer c++

Hello.
I must do some solution in my game but I don’t know how to do it.

I have:

char * filedata; - parsed from huge datafile container
SDL_Surface * srfdest; - destination surface

How to copy filedata to srfdest.

Greetings


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Ok, now I am really confused. No, I am running a double buffered main
surface. But what you are saying makes absolutely no sense at all! Why
should one image appear over the other? Where and how do you define
this??? As far as I can see, there is NO reason for one image to appear
over the other…

MaxOn Sunday, August 24, 2003, at 11:09 PM, NBarnes wrote:

— Max Countryman <@Max_Countryman> wrote:

Ok… I still don’t understand why one image should appear above
another. Right now my two images are fighting to be on top of
one-another. Causing a horrible flicker. I thought that I should need
to somehow tell one image to be on top of the other…

That sounds like you might not be using a double buffered surface
as your main display and then calling SDL_Flip(mainDisplay) to
change the view. Updating the surface when it’s being displayed
can cause effects like you describe.

                                                       NBarnes

Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Here are my two blits, you tell me how to make one blit appear over the
other:

/* Blit the player sprite to the screen. */

SDL_BlitSurface ( sprite, NULL, screen, &spriteLocation );

spriteLocation.y = spritePosition_y;
spriteLocation.x = spritePosition_x;

SDL_SetColorKey( sprite, SDL_SRCCOLORKEY, 0);
SDL_SetAlpha( sprite, SDL_SRCALPHA, 255 );

/* Scroll the the level background… */

SDL_BlitSurface ( background, &pictureLocation, screen, NULL );
scrollPosition–;

pictureLocation.y = scrollPosition;

SDL_Flip( screen );
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: text/enriched
Size: 824 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20030825/1cd9a243/attachment.bin

Max, you ever try painting?

when you paint a square and then let it dry and paint a circle partialy over
the square, doesnt the circle apear over the square?

This is the same reason when you draw one image after another, it apears
above the other image.> ----- Original Message -----

From: maxc@mac.com (Max Countryman)
To:
Sent: Monday, August 25, 2003 10:37 AM
Subject: Re: [SDL] Layers

Ok, now I am really confused. No, I am running a double buffered main
surface. But what you are saying makes absolutely no sense at all! Why
should one image appear over the other? Where and how do you define
this??? As far as I can see, there is NO reason for one image to appear
over the other…

Max
On Sunday, August 24, 2003, at 11:09 PM, NBarnes wrote:

— Max Countryman wrote:

Ok… I still don’t understand why one image should appear above
another. Right now my two images are fighting to be on top of
one-another. Causing a horrible flicker. I thought that I should need
to somehow tell one image to be on top of the other…

That sounds like you might not be using a double buffered surface
as your main display and then calling SDL_Flip(mainDisplay) to
change the view. Updating the surface when it’s being displayed
can cause effects like you describe.

                                                       NBarnes

Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Let me tell you how should IMHO bliting of a small sprite over a large
surface work:

You have:

  • A Background.
  • A Sprite.
  • Position A (Where the sprite was before you moved it).
  • Position B (where it is going to be when your are done moving it).

The first time you blit this sprite…
With position A…

  1. Suppose you have a Square containing a sprite. Blit THE SCREEN
    (BACKGROUND) that
    this sprite is about to be above of, onto a non-displayed surface
    (Called SURFA, for instance).
  2. Blit the Sprite over the background.

The following times…
With position A…

  1. Re-Paint the background with SURFA (which contained that portion
    of the original background).
    With position B…
  2. Suppose you have a Square containing a sprite. Blit THE SCREEN
    (BACKGROUND) that
    this sprite is about to be above of, onto a non-displayed surface
    (Called SURFA, for instance).
  3. Blit the Sprite over the background.

This is an example of this implementation… many variable names are
declared in spanish, but I don’t think
that is relevant.

struct Cosa {
int x,y;
int px, py;
int Potencia;
int Damage;
int Vidas;
int Prev_PosXReal;
int Prev_PosYReal;
int CurrImg;
SDL_Surface * fondo;
};

void MuestraCosa(struct Cosa * CosaActual)
{
SDL_Rect *srcrect, *dstrect;
srcrect = (SDL_Rect *) malloc(sizeof(SDL_Rect));
dstrect = (SDL_Rect *) malloc(sizeof(SDL_Rect));

if (CosaActual->fondo) {
//If I’m here, it means that this is not the first time this sprite is
drawn

// RE-PAINT background rect overdrawn before… —
srcrect->x = (short) 0;
srcrect->y = (short) 0;
srcrect->w = (unsigned short) CosaActual->fondo->w;
srcrect->h = (unsigned short) CosaActual->fondo->h;

dstrect->x = (short) (CosaActual->Prev_PosXReal);
dstrect->y = (short) (CosaActual->Prev_PosYReal);
dstrect->w = (unsigned short) CosaActual->fondo->w;
dstrect->h = (unsigned short) CosaActual->fondo->h;

SDL_BlitSurface(CosaActual->fondo, srcrect, screen, dstrect) ;
SDL_UpdateRect(screen, dstrect->x, dstrect->y, dstrect->w,
dstrect->h);
// —

} else {
//This is the first time I draw this Sprite…
// I create a new Surface to save the Background to…
CosaActual->fondo = (struct SDL_Surface *)
malloc(sizeof(SDL_Surface));
CosaActual->fondo =
SDL_CreateRGBSurface(SDL_HWSURFACE|SDL_SRCCOLORKEY,
Imagenes[CosaActual->CurrImg]->w, Imagenes[CosaActual->CurrImg]->h,
32, 0xff000000, 0x00ff0000,
0x0000ff00, 0x000000ff);
}

// I save the bakground again… for later use…
srcrect->x = (short) (CosaActual->x);
srcrect->y = (short) (CosaActual->y);
srcrect->w = (unsigned short) CosaActual->fondo->w;
srcrect->h = (unsigned short) CosaActual->fondo->h;

dstrect->x = (short) 0;
dstrect->y = (short) 0;
dstrect->w = (unsigned short) CosaActual->fondo->w;
dstrect->h = (unsigned short) CosaActual->fondo->h;

SDL_BlitSurface(screen, srcrect, CosaActual->fondo, dstrect) ;
//—

// I draw the Sprite…
srcrect->x = (short) 0;
srcrect->y = (short) 0;
srcrect->w = (unsigned short) Imagenes[CosaActual->CurrImg]->w;
srcrect->h = (unsigned short) Imagenes[CosaActual->CurrImg]->h;

dstrect->x = (short) (CosaActual->x);
dstrect->y = (short) (CosaActual->y);
dstrect->w = (unsigned short) Imagenes[CosaActual->CurrImg]->w;
dstrect->h = (unsigned short) Imagenes[CosaActual->CurrImg]->h;

SDL_BlitSurface(Imagenes[CosaActual->CurrImg], srcrect, screen,
dstrect) ;
SDL_UpdateRect(screen, dstrect->x, dstrect->y, dstrect->w, dstrect->h);
// –
}

Good Luck!

Juan Ignacio Carniglia - Programmer - Buenos Aires, Argentina.> ----- Original Message -----

From: sdl-admin@libsdl.org [mailto:sdl-admin at libsdl.org] On Behalf Of
Max Countryman
Sent: Monday, August 25, 2003 2:42 PM
To: sdl at libsdl.org
Subject: Re: [SDL] Layers

Here are my two blits, you tell me how to make one blit appear over the
other:

/* Blit the player sprite to the screen. */

SDL_BlitSurface ( sprite, NULL, screen, &spriteLocation );

spriteLocation.y = spritePosition_y;
spriteLocation.x = spritePosition_x;

SDL_SetColorKey( sprite, SDL_SRCCOLORKEY, 0);
SDL_SetAlpha( sprite, SDL_SRCALPHA, 255 );

/* Scroll the the level background… */

SDL_BlitSurface ( background, &pictureLocation, screen, NULL );
scrollPosition–;

pictureLocation.y = scrollPosition;

SDL_Flip( screen );