? Clipping Bug?

Hi!

I think I’ve found a bug in SDL_BlitSurface’s clipping (but I’m not sure…).
I’m using SDL 1.1.3 .

This code

void UndrawBlock()
{
SDL_Rect Rect;
int i;

for (i=0;i<PlayerNum;i++) {
    Rect.x=BPlayer[i].x*10;
Rect.y=BPlayer[i].y*10;
    Rect.w=50;
    Rect.h=50;

    SDL_BlitSurface(BackBuffer, &Rect, Screen, &Rect);
printf( "Rect.x: %d, Rect.y %d, Rect.w %d, Rect.h %d\n", Rect.x, Rect.y,

Rect.w, Rect.h);
printf( “BackBuffer->w: %d, BackBuffer->h %d, Screen->w %d, Screen->h %d\n”,
BackBuffer->w, BackBuffer->h, Screen->w, Screen->h);
}
}

produces this output:

Rect.x: 120, Rect.y 380, Rect.w 50, Rect.h 50
BackBuffer->w: 500, BackBuffer->h 400, Screen->w 500, Screen->h 400

Shouldn’t Rect.h clipped to 20???

Is this really a bug or am I doing something wrong?

Bye, Karl.

No comment on this?

Bye, Karl.> Hi!

I think I’ve found a bug in SDL_BlitSurface’s clipping.
I’m using SDL 1.1.3 .

This code

void UndrawBlock()
{
SDL_Rect Rect;
int i;

for (i=0;i<PlayerNum;i++) {
    Rect.x=BPlayer[i].x*10;
    Rect.y=BPlayer[i].y*10;
    Rect.w=50;
    Rect.h=50;

    SDL_BlitSurface(BackBuffer, &Rect, Screen, &Rect);
    printf( "Rect.x: %d, Rect.y %d, Rect.w %d, Rect.h %d\n", Rect.x, Rect.y,

Rect.w, Rect.h);
printf( “BackBuffer->w: %d, BackBuffer->h %d, Screen->w %d, Screen->h %d\n”,
BackBuffer->w, BackBuffer->h, Screen->w, Screen->h);
}
}

produces this output:

Rect.x: 120, Rect.y 380, Rect.w 50, Rect.h 50
BackBuffer->w: 500, BackBuffer->h 400, Screen->w 500, Screen->h 400

Shouldn’t Rect.h clipped to 20???

Is this really a bug or am I doing something wrong?

Bye, Karl.

No comment on this?

Bye, Karl.

Hi!

I think I’ve found a bug in SDL_BlitSurface’s clipping.
I’m using SDL 1.1.3 .

This code

void UndrawBlock()
{
SDL_Rect Rect;
int i;

for (i=0;i<PlayerNum;i++) {
    Rect.x=BPlayer[i].x*10;
    Rect.y=BPlayer[i].y*10;
    Rect.w=50;
    Rect.h=50;

    SDL_BlitSurface(BackBuffer, &Rect, Screen, &Rect);
    printf( "Rect.x: %d, Rect.y %d, Rect.w %d, Rect.h %d\n", Rect.x, Rect.y,

Rect.w, Rect.h);
printf( “BackBuffer->w: %d, BackBuffer->h %d, Screen->w %d, Screen->h %d\n”,
BackBuffer->w, BackBuffer->h, Screen->w, Screen->h);
}
}

produces this output:

Rect.x: 120, Rect.y 380, Rect.w 50, Rect.h 50
BackBuffer->w: 500, BackBuffer->h 400, Screen->w 500, Screen->h 400

Shouldn’t Rect.h clipped to 20???

I actually think you’re expecting SDL_BlitSurface to do something it’s not
meant to do. I /believe/ SDL_BlitSurface does not clip if you extend
beyond the edge of the destination surface (as a matter of fact, I’d
expect it to crash on you… or at least not even try to blit the
surface… at least, I think this happenned on an early background
scolling routine I was working on).

I.e., you must set the proper clipped rectangle before calling
SDL_BlitSurface.

SDL_BlitSurface isn’t that smart :wink: (and I dont think it was intended to
be… if you need a function that’ll do this for you, I’d recommend making
a wrapper)

(anyone feel free to correct me if I’m wrong)On Wed, 28 Jun 2000, Karl Bartel wrote:


Sam Hart http://www.physics.arizona.edu/~hart/
Web Page Highlights: Video Game History, Black Hole Simulation, & more.
OTHER WEB SITES MAINTAINED BY SAM HART
http://www.geekcomix.com/ - Geekcomix, the Daily Geek Comic Strip Site
http://www.physics.arizona.edu/~hart/gw/ - Ghostworks (Alt./Linux Computing)

Hi!

Rect.x: 120, Rect.y 380, Rect.w 50, Rect.h 50
BackBuffer->w: 500, BackBuffer->h 400, Screen->w 500, Screen->h 400

Shouldn’t Rect.h clipped to 20???

I actually think you’re expecting SDL_BlitSurface to do something it’s not
meant to do. I /believe/ SDL_BlitSurface does not clip if you extend
beyond the edge of the destination surface (as a matter of fact, I’d
expect it to crash on you… or at least not even try to blit the
surface… at least, I think this happenned on an early background
scolling routine I was working on).

I.e., you must set the proper clipped rectangle before calling
SDL_BlitSurface.

SDL_BlitSurface isn’t that smart :wink: (and I dont think it was intended to
be… if you need a function that’ll do this for you, I’d recommend making
a wrapper)

(anyone feel free to correct me if I’m wrong)

The SDL docs says about SDL_BlitSurface:
"The final blit rectangles are saved in ‘srcrect’ and ‘dstrect’ after all
clipping is performed."
What does this mean if it doesn’t clip at all?

Bye, Karl.

The SDL docs says about SDL_BlitSurface:
"The final blit rectangles are saved in ‘srcrect’ and ‘dstrect’ after all
clipping is performed."
What does this mean if it doesn’t clip at all?

SDL_BlitSurface() does clip. SDL_LowerBlit() does not clip.

Could the poster of the original code send me a very simple example
program exhibiting the problem?

See ya,
-Sam Lantinga, Lead Programmer, Loki Entertainment Software