Jump to content
• Advertisement

# Screen Coordinates and World Coordinates

This topic is 5387 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 evrybody, I tried to find a similar thread in the history, but I was unable to find my luck... I would like to know what is the relation between the screen coordinates and the world coordinates. Especially, I would like to know the relation between my camera distance and the size of the object I'm looking at? An example will be easier to understand what I looking for. Having a screen width of 800 and height of 600, so if I draw a square in the middle of the screen with an edge of 1.0f. Now If I'm situated at (0.0f, 0.0f, -1.0f) would this mean that the cube has an edge of 600 pixels on the screen ? In fact I'm looking for a mathematical equation helping me to define the object size depending on my distance from the origin. Thx.

#### Share this post

##### Share on other sites
Advertisement
I think you're looking for gluProject() and gluUnProject(). GluProject() takes x, y, z world coordinates and converts them into x, y screen coordinates. GluUnproject does the opposite, where it takes x, y screen coordinates plus a depth value and converts them into into x, y, z world coordinates. Try doing a search for gluUnproject/gluUnProject and see if this is what you're after.

The amount of space a fixed-size object will take up in screen coordinates also depends on your viewing angle. If you have a tight view angle a small object could take up the entire viewing area, while if you have a wide view angle a very large object could take up a very small amount of viewing area.

Hope this helps!

#### Share this post

##### Share on other sites
Thx. Will look at those functions.

#### Share this post

##### Share on other sites
In fact your answer was in some way helpfull. I was able to find some information that might help me to move any further...

I try not to use any glu functions for the moment. It would be nice if some simple gl function I could set or determine the values for the focus and/or viewing angle values. This way I should be able to establish some equation to determine what position and size my object should have to be at a precise size on the screen.

To be more precise, I'm working on a GUI with some buttons (radio, checkbox, etc.), textboxes and so on. And I would like to know how to set their world coordinates in order to be sure they will be at the right place and have the right size and shape.

Thx.

#### Share this post

##### Share on other sites
Quote:
 Original post by werbfredTo be more precise, I'm working on a GUI with some buttons (radio, checkbox, etc.), textboxes and so on. And I would like to know how to set their world coordinates in order to be sure they will be at the right place and have the right size and shape.Thx.

Use an orthogonal projection for that!

#### Share this post

##### Share on other sites
Quote:
 Original post by mjs1I think you're looking for gluProject() and gluUnProject(). GluProject() takes x, y, z world coordinates and converts them into x, y screen coordinates.

Into object space! Not world space.

#### Share this post

##### Share on other sites
Orthogonal projection works fine... Thanks

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Now

• 21
• 15
• 9
• 17
• 13
• Advertisement
×

## Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!