Definition of blit?

Hi,

I’m trying to get this following bit of code working - the code is
actually alittle more complex than this but this is what I’m using to
test the idea:

background=IMG_Load("…/media/inGame/background.jpg");
SDL_BlitSurface(background, NULL, mapBuffer, NULL);
screen=SDL_SetVideoMode(1024,768,16,SDL_SWSURFACE);
SDL_BlitSurface(mapBuffer, screen, 0, 0);
SDL_UpdateRect(screen, 0, 0, 0, 0);

The code will be used load hex shaped tiles onto the mapBuffer surface
so that it only ever has to be built once - and any playing pieces can
then just be blitted over the top of the appropriate hexes straight onto
the screen.

However, this code produces only a blank screen.

Am I right in thinking that a blit is just a “copy” from one surface to
another? If this is correct, then why does this code not work? Or have I
got it wrong somehow? Any suggestions to a solution would be greatly
appreciated.

regards,
Nevyn.

Nevyn wrote:

SDL_BlitSurface(mapBuffer, screen, 0, 0);

However, this code produces only a blank screen.

you messed up the arguments, it should be more like:

SDL_BlitSurface(mapBuffer, 0, screen, 0);

Right you are - sorry I was trying to keep my DrawIMG function
definition out of this - basically that’s the order which I pass things
through to this function - so assume that line is actually

SDL_BlitSurface(mapBuffer, NULL, screen, NULL);On Sat, 2004-10-30 at 01:00, Jonathan Atkins wrote:

Nevyn wrote:

SDL_BlitSurface(mapBuffer, screen, 0, 0);

However, this code produces only a blank screen.

you messed up the arguments, it should be more like:

SDL_BlitSurface(mapBuffer, 0, screen, 0);


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

I assume that you should update the mapBuffer too before blitting it
onto the screen surface.

Nevyn schrieb:>Hi,

I’m trying to get this following bit of code working - the code is
actually alittle more complex than this but this is what I’m using to
test the idea:

background=IMG_Load("…/media/inGame/background.jpg");
SDL_BlitSurface(background, NULL, mapBuffer, NULL);
screen=SDL_SetVideoMode(1024,768,16,SDL_SWSURFACE);
SDL_BlitSurface(mapBuffer, screen, 0, 0);
SDL_UpdateRect(screen, 0, 0, 0, 0);

The code will be used load hex shaped tiles onto the mapBuffer surface
so that it only ever has to be built once - and any playing pieces can
then just be blitted over the top of the appropriate hexes straight onto
the screen.

However, this code produces only a blank screen.

Am I right in thinking that a blit is just a “copy” from one surface to
another? If this is correct, then why does this code not work? Or have I
got it wrong somehow? Any suggestions to a solution would be greatly
appreciated.

regards,
Nevyn.


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

Hi!

background=IMG_Load("…/media/inGame/background.jpg");
SDL_BlitSurface(background, NULL, mapBuffer, NULL);
screen=SDL_SetVideoMode(1024,768,16,SDL_SWSURFACE);
SDL_BlitSurface(mapBuffer, screen, 0, 0);
SDL_UpdateRect(screen, 0, 0, 0, 0);

its actually
void SDL_UpdateRect(SDL_Surface *screen, Sint32 x, Sint32 y, Sint32 w, Sint32 h);

so, you should try
SDL_UpdateRect(screen, 0, 0, 1024, 768);

you also can use
int SDL_Flip(SDL_Surface *screen);

hope that helps
Sven

Well I figured it out:
It needs to go something like this:

screen=SDL_SetVideoMode(1024,768,16,SDL_DOUBLEBUF); //must be called
//BEFORE SDL_CreateRGBSurface

background=IMG_Load("…/media/inGame/background.jpg");

map=SDL_CreateRGBSurface(SDL_SWSURFACE,(mapx/2)(tileDimensions.width+
tileDimensions.sideWidth),(mapy
tileDimensions.height)
+(tileDimensions.height/2),16,0,0,0,0); //initates surface

SDL_BlitSurface(background, NULL, map, NULL);

SDL_BlitSurface(map, NULL, screen, NULL);

SDL_UpdateRect(screen, 0, 0, 0, 0); //updates whole screen (omits
//rectangle definition)On Sat, 2004-10-30 at 02:14, Dominik Spitzer wrote:

I assume that you should update the mapBuffer too before blitting it
onto the screen surface.

Nevyn schrieb:

Hi,

I’m trying to get this following bit of code working - the code is
actually alittle more complex than this but this is what I’m using to
test the idea:

background=IMG_Load("…/media/inGame/background.jpg");
SDL_BlitSurface(background, NULL, mapBuffer, NULL);
screen=SDL_SetVideoMode(1024,768,16,SDL_SWSURFACE);
SDL_BlitSurface(mapBuffer, screen, 0, 0);
SDL_UpdateRect(screen, 0, 0, 0, 0);

The code will be used load hex shaped tiles onto the mapBuffer surface
so that it only ever has to be built once - and any playing pieces can
then just be blitted over the top of the appropriate hexes straight onto
the screen.

However, this code produces only a blank screen.

Am I right in thinking that a blit is just a “copy” from one surface to
another? If this is correct, then why does this code not work? Or have I
got it wrong somehow? Any suggestions to a solution would be greatly
appreciated.

regards,
Nevyn.


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

Sven Dawitz wrote:

its actually
void SDL_UpdateRect(SDL_Surface *screen, Sint32 x, Sint32 y, Sint32 w, Sint32 h);

so, you should try
SDL_UpdateRect(screen, 0, 0, 1024, 768);

you also can use
int SDL_Flip(SDL_Surface *screen);

hope that helps
Sven

actually, Sven, passing all 0’s makes SDL update the whole screen.
it’s a shortcut.

-LIM-