Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


What are offsets in SDL?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 VaugeCookie   Members   -  Reputation: 303

Like
0Likes
Like

Posted 20 July 2013 - 10:05 AM

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, 20 July 2013 - 09:09 PM.
Obnoxious font coloration; please use code tags for source code.


Sponsor:

#2 ultramailman   Prime Members   -  Reputation: 1581

Like
4Likes
Like

Posted 20 July 2013 - 01:56 PM

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, 20 July 2013 - 02:35 PM.


#3 Servant of the Lord   Crossbones+   -  Reputation: 20236

Like
3Likes
Like

Posted 20 July 2013 - 02:17 PM

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


It's perfectly fine to abbreviate my username to 'Servant' rather than copy+pasting it all the time.
All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.
Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal

[Fly with me on Twitter] [Google+] [My broken website]

[Need web hosting? I personally like A Small Orange]


#4 VaugeCookie   Members   -  Reputation: 303

Like
0Likes
Like

Posted 20 July 2013 - 07:30 PM

i love this forum, cheers people






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS