Problems with clipping

I’m doing a tiled background but when the tiles get clipped the
function SDL_BlitSurface doesn’t write more tiles.
Have I to use a function to inform the surface about the clipping,
or it’s a bug in SDL?
I attach my code.

 ||| 
(o -)

oOOo(_)oOOo-----------------------------

" Real users hate Real programmers "
@Gorka
http://web.jet.es/~olsago/
http://fly.to/luzluciernaga

-------------- next part --------------
#include <SDL.h>

SDL_Surface *image, *screen;

#define X 15 /* Change this to a minor number to see that it works /
#define Y 11 /
Change this to a minor number to see that it works */

void draw_background(SDL_Surface *source, SDL_Surface *dest)
{
SDL_Rect pos;
unsigned int i, j;

    pos.w = source->w;
    pos.h = source->w;

    pos.y=0;
    for (i=0; i<Y; i++){
            pos.x=0;
            for (j=0; j<X; j++) {
                    SDL_BlitSurface(source, NULL, dest, &pos);
                    pos.x+=source->w;
            }
            pos.y+=source->h;
    }               

}

main()
{
SDL_Init(SDL_INIT_VIDEO);

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

image=SDL_LoadBMP("tile.bmp");
draw_background(image, screen);
SDL_Flip(screen);

while(!SDL_PollEvent(NULL));

return(0);
}

At 11:17 PM 7/13/99 +0200, you wrote:

I’m doing a tiled background but when the tiles get clipped the
function SDL_BlitSurface doesn’t write more tiles.
Have I to use a function to inform the surface about the clipping,
or it’s a bug in SDL?
I attach my code.

pos.w = source->w;
pos.h = source->w;

shouldn’t
pos.h = source->h;

and while(!SDL_PollEvent(NULL)); should use WaitEvent instead so you don’t
waste cpu in that tight while loop.

-Mongoose
WPI student majoring in Computer Science and an over obsessed gaming fanatic.
ICQ #495470

shouldn’t
pos.h = source->h;

Yes, but it doesn’t matter because the tile i use it’s square. The problem
is still there.

and while(!SDL_PollEvent(NULL)); should use WaitEvent instead so you don’t
waste cpu in that tight while loop.

It’s just an example. I didn’t want to optimize it, but thanks for the
tip.

 ||| 
(o -)

oOOo(_)oOOo-----------------------------

" Real users hate Real programmers "
@Gorka
http://web.jet.es/~olsago/
http://fly.to/luzluciernaga

The blitting function actually modifies the rectangles passed to it
so that they can be passed directly to SDL_UpdateRects() without
having to perform clipping twice. Reset the width and height of
the rectangles passed to SDL_BlitSurface() before each call.

-Sam Lantinga				(slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec