Possible clipping-bug?

Hello ! :slight_smile:

I noticed that my program crashes with an X-error if I blit to outside
the screen. Would be what I expect, had I not turned on clipping.
If I do a:
SDL_SetClipping(mysprite, 10, 10, 629, 469) on a screen of 640x480
then my sprite is not seen in the 10-pixel border, but the program
aborts when it moves outside the screen.
Or just blit it at 1000,0 or something. Should the clipping not
take care of that ?
I have SDL1.1.1 (the 1.1.2-announcement doesn’t mention this though),
on XFree3.3.x.

All the best,
rob

PS: the docs say:
"Note that blits are automatically clipped to the edges of the source
and destination surfaces."
which sort of answers my last question above, and turns it into a real
bug-report :slight_smile:

Hello ! :slight_smile:

I noticed that my program crashes with an X-error if I blit to outside
the screen. Would be what I expect, had I not turned on clipping.
If I do a:
SDL_SetClipping(mysprite, 10, 10, 629, 469) on a screen of 640x480
then my sprite is not seen in the 10-pixel border, but the program
aborts when it moves outside the screen.
Or just blit it at 1000,0 or something. Should the clipping not
take care of that ?
I have SDL1.1.1 (the 1.1.2-announcement doesn’t mention this though),
on XFree3.3.x.

Can you send a simple test case which I can use to reproduce this?

Thanks!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

Ok, here is a test-program that just opens an 640x480x16-sdl-window,
creates a sprite-surface, copies some part of the screen to it, enables
clipping, and tries to blit it outside the screen.

What I didn’t get until now is that not the BlitSurface fails, but the
UpdateRects. So it probably is no real clipping-problem. But perhaps
UpdateRects should be able to catch that too.

All the best,
rob

PS: the output is:
I
II
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 129 (MIT-SHM)
Minor opcode of failed request: 3 (X_ShmPutImage)
Value in failed request: 0x2bc
Serial number of failed request: 11
Current serial number in output stream: 12

----------------
#include <stdlib.h>
#include <stdio.h>
#include <SDL.h>

int main() {
SDL_Surface *screen, *tmp, *sprite;
SDL_Rect dest;

if (SDL_Init(SDL_INIT_VIDEO)) {
    printf ("SDL_Init failed with %s\n", SDL_GetError());
    exit (1);
}
atexit (SDL_Quit);

screen = SDL_SetVideoMode(640, 480, 16, SDL_SWSURFACE);

tmp = SDL_CreateRGBSurface(0, 32, 32, 32, 0xff000000, 0x00ff0000, 0x0000ff0
sprite = SDL_DisplayFormat(tmp);
SDL_SetClipping(sprite, 0, 0, 639, 479);

dest.x = 70; dest.y = 1; dest.h = 32; dest.w = 32;
SDL_BlitSurface(screen, &dest, sprite, NULL);
SDL_UpdateRects(sprite, 1, NULL);

printf (“I\n”);
dest.x = 700; dest.y = 1; dest.h = 32; dest.w = 32;
SDL_BlitSurface(sprite, NULL, screen, &dest);
printf (“II\n”);
SDL_UpdateRects(screen, 1, &dest);
printf (“III\n”);

return (0);

}

Ok, here is a test-program that just opens an 640x480x16-sdl-window,
creates a sprite-surface, copies some part of the screen to it, enables
clipping, and tries to blit it outside the screen.

Thanks, this is now fixed in CVS. Thanks! :slight_smile:

-Sam Lantinga, Lead Programmer, Loki Entertainment Software