Sign in to follow this  
VaugeCookie

What are offsets in SDL?

Recommended Posts

VaugeCookie    303
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 Edited by JTippetts
Obnoxious font coloration; please use code tags for source code.

Share this post


Link to post
Share on other sites
ultramailman    1720

don't forget what comes after it:

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

if you read this

[url]http://www.libsdl.org/docs/html/sdlblitsurface.html[/url]

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.

Edited by ultramailman

Share this post


Link to post
Share on other sites

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'.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this