What are offsets in SDL?

Started by
2 comments, last by VaugeCookie 10 years, 9 months ago
hi im teaching myself SDL via lazyfoos website and i keep coming across "offset"


void apply_surface(int x, int y, SDL_Surface* source, SDL_Surface* destination )
{
  //Make a temporary rectangle to hold the offsets
  SDL_Rect offset;
 
  //Give the offsets to the rectangle
  offset.x = x; offset.y = y;
}

im obviously new to all this so please be gentle, im not sure what these actually mean or do? what am i offsetting? is it something to do with where its going to appear on the screen?

thanks in advance
Advertisement

don't forget what comes after it:


SDL_BlitSurface( source, NULL, destination, &offset );

if you read this

http://www.libsdl.org/docs/html/sdlblitsurface.html

you will see that the rectangle named "offset" is used to pass the position of the surface you want to blit.

edit: so it is simply the position of the surface you want to draw. if i was lazyfoo, i'd have called it "position" instead, haha.

edit: offset makes sense too. it is an offset to the upper left corner of the background surface you want to draw on.

As ultramailman explains, it's the position on the screen where you want to draw the image.

However, since 'destination' doesn't have to be the screen (it could be another non-screen SDL_Surface), so it would be the position in 'destination' where you want to draw 'source'.

i love this forum, cheers people

This topic is closed to new replies.

Advertisement