Possible Bug?

Hi I’ve just started using SDL and have come across the following
problem (Linux RedHat 5.2, SDL 0.8.10):

When I have two surfaces, one being the screen (initialized by
SetVideoMode) and the other being a buffer larger than the screen itself
for rendering scrolling backgrounds, etc, I have a problem blitting from
the larger surface to the smaller surface.
The problem is that the Rect gets clipped even though I make sure that
it is the same size as the destination surface.

Example:

In this example, map_buffer (SDL_Surface) is 740x580 just to show what
I’m talking about (100x100 bigger than the screen surface)

src_rect.x = 100; // Offset into the larger surface
by 100
src_rect.y = 100; // Offset by Y also
src_rect.w = screen->w; // Make the rect the same size as the dest
surface
src_rect.h = screen->h; // (640x480)

SDL_MapSurface(map_buffer,screen->format);
SDL_BlitSurface(map_buffer,&src_rect,screen,NULL); //This should’ve
copied a 640x480 rect of data into screen surface

printf(“x=%d,y=%d w=%d
h=%d\n”,src_rect.x,src_rect.y,src_rect.w,src_rect.h);

Output shows a smaller area actually drawn, and the src_rect has been
changed:

x=100,y=100 w=540 h=380

This leads me to believe that the source surface was clipped to fit in
the corner of the dest surface,
even though it was exactly the right size to fit on the entire screen
(640x480). I’ve tried playing
with SDL_SetClipping(map_buffer,0,0,0,0) with no results.

Am I doing something incorrectly? Any help would be greatly appreciated.

Thanks!
Tom Stock
Galaxy Long Distance Inc.
(813)221-4200

@Tom_Stock

Hi I’ve just started using SDL and have come across the following
problem (Linux RedHat 5.2, SDL 0.8.10):

Can you reproduce the problem with SDL 0.9.x?

Thanks!
-Sam Lantinga (slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
Author of Simple DirectMedia Layer -
http://www.devolution.com/~slouken/SDL/

Hi Sam,

Sorry about the earlier report. It was (well hidden) human error on my part
:slight_smile:

One question since I have you here:

Why was SDL_MapSurface removed in 0.9.x? The documentation still lists it
as being required before a blit, but the function no longer exists in the
header files or library. Just curious, no real concern of course.

Thanks!
-tom

Sam Lantinga wrote:> > Hi I’ve just started using SDL and have come across the following

problem (Linux RedHat 5.2, SDL 0.8.10):

Can you reproduce the problem with SDL 0.9.x?

Thanks!
-Sam Lantinga (slouken at devolution.com)

Lead Programmer, Loki Entertainment Software

Author of Simple DirectMedia Layer -
http://www.devolution.com/~slouken/SDL/

Why was SDL_MapSurface removed in 0.9.x? The documentation still lists it
as being required before a blit, but the function no longer exists in the
header files or library. Just curious, no real concern of course.

SDL_MapSurface is done automatically by SDL when required.
I’ll update the documentation. :slight_smile:

See ya!
-Sam Lantinga (slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
Author of Simple DirectMedia Layer -
http://www.devolution.com/~slouken/SDL/