Jump to content
  • Advertisement
Sign in to follow this  
Justindano

SDL Co-ordinates

This topic is 2467 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

Hey Guys,
My major problem is I always get confused when drawing a image onto the screen in SDL, I know that SDL coordinates are not as regular as in the real world, But my doubt is suppose, if i draw a square onto SDL coordinates in x and y axis. How will i calculate its offsets, This confuses me alot sometimes.
Could someone please help me ,
Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
SDL coordinates are like most graphic engine coordinates, they start at the top left corner of your screen/window. The more you go down the screen the Y increases and as you go across to the right the X increases

Ex. If you want an image in the top left corner set its X to 0 and it's Y to 0
This way the top left corner of the image will be at the top left corner of te screen.

Share this post


Link to post
Share on other sites
Thanks,
But i know that the co ordinates start from the top left corner, What im asking is, if i place a square say at ( 200, 200 ) will it have the same offset as the screens offset or different.

Share this post


Link to post
Share on other sites

Thanks,
But i know that the co ordinates start from the top left corner, What im asking is, if i place a square say at ( 200, 200 ) will it have the same offset as the screens offset or different.


Not sure if by "screen" you mean the physical display, or the window in which you are drawing. If you mean the window, placing a square at (200, 200) will appear at (200, 200) in the window, as long as the square's coordinates are zero indexed. If you mean the display, then unless the SDL screen surface is fullscreen, you are constrained by drawing in the window. All coordinates are relative to the window's origin.

Share this post


Link to post
Share on other sites
And also, If you draw a Sprite at position (200,200) for example, That means that the images top left corner is set at that position. Unless you transform it's origin.

The way I remember the Y direction is:


A girl goes down in front of you = positive
[/quote]

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!