Jump to content
  • Advertisement
Sign in to follow this  
TFS_Waldo

Using screen (2D) coordinates instead of 3D space?

This topic is 4842 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 there. I am trying to figure out how I would use screen coords. (ex. 0, 0, 100, 100) when creating a quad instead of (0.0f, 0.0f, 1.0f, 1.0f). I hope you get what I'm trying to say. The first one uses pixels, and the second, it uses units in OpenGL. I don't need to do it through my entire app. Just when I draw a certain quad. How do I do this? Thanks in advance, Matt U.

Share this post


Link to post
Share on other sites
Advertisement
I don't know OGL, but if there's (int width) pixels = (1 unit) across and (int height) pixels = (1 unit) down...

To go from pixels to units just do x/width and y/height.

Share this post


Link to post
Share on other sites
You want to set an orthographic projection matrix that corresponds to your screen size. You can do this by using the function gluOrtho2D function like gluOrtho2D( 0, 0, screen_width, screen_height ), then use glVertex2i for specifying coordinates.

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!