Jump to content
  • Advertisement
Sign in to follow this  
NIm

OpenGL Screen coordinates

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

Is there a way to make openGl draw relative to the screen? or should I just remember where the nearest clipping plane is and glTranslate to it? I figure it'd be lot faster if opengl did this natively.

Share this post


Link to post
Share on other sites
Advertisement
What do you mean by 'screen coordinates'? Like in pixels? If so, your best option is to use an orthographic projection matrix. Don't worry about the speed with that too much, it's pretty fast.

Share this post


Link to post
Share on other sites
I'm talking about a set of coordinates attached to the screen, as opposed to world coodinates, which are attached to the arbitrary point you've chosen as your origin, also opposed to model coordinates, like when you use glTranslate() and glRotate to move the origin to the position and rotation of your model.

Don't care what units it in: I can convert easily. I'm talking about drawing on the camera, like a heads up display or something. Will I be able to use glOrtho() for my HUD, and glPerspective() for drawing the world?

I realize that I can remember where the camera is positioned and draw the hud directly in front of it, but it seems like it would be more efficient to draw quads and stuff on the 2d space that is the screen, because then you don't have any of the maths involved in transforming them to what boils down to a position on the screen, rather than a position in space.

In less precise, less clever, and more clear words: How do I make a HUD to show information to the player?

Also: What's the best way to write text?

Share this post


Link to post
Share on other sites
Well, there are some ways.

You see, you can simple paste an image in the framebuffer (or blend it in ect.). Look up these functions:

glDrawBuffer();
glDrawPixels();





I'd use this for a HUD.

If you still want to use screen coordinates for, for instance bitmaps, you might want something like this:

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(some arguments i cant remmeber from the top of my head);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//and now you are working in 2d!
//remember to set GL to 3d once you get back to drawing the scene





Here is a link for drawing text (which requires the 2d code metioned above):
http://www.glprogramming.com/red/chapter08.html#name1

Does this answer your question?

Edit: I am also relatively new to opengl, there might be mistakes in here

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!