[SDL] possible clipping-bug ?

Robert Linden linden at triton.informatik.uni-bonn.de
Thu Apr 13 17:04:01 PDT 2000


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


--------<nsip>--------
#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);
}   



More information about the SDL mailing list