Jump to content
  • Advertisement
Sign in to follow this  
VaugeCookie

What are offsets in SDL?

This topic is 1828 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!