Sign in to follow this  

HUD with 3D object

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

I want to render the 3 world axis at a corner of the window. How can I render a 3D object in the foreground (with glOrtho) ? Do I have to render the 3 axis to a texture and then render this texture as a 2D transparent GL_QUAD?

Share this post


Link to post
Share on other sites
You can simply render the object in the last stage of your rendering function, disabling depth testing to make sure the axis are drawn on top of everything.

Share this post


Link to post
Share on other sites
Yes you can. You can position it like any other 3d object. In fact, an easy way to make it follow the camera is to call a glLoadIdentity first. Then just move down the z a couple units position and draw your object accordingly. Because of the reset, it won't matter where the camera is because you reset the view first. You don't even have to go Ortho if you don't want to.

Share this post


Link to post
Share on other sites
The problem is that I need to rotate the 3 axis according to the camera orientation.
I think I have to compute the view matrix manually without gluLookAt to discard the camera position

Share this post


Link to post
Share on other sites
I managed to render the axis in the lower right part of the screen by altering the viewport size.
At the end of the rendering:

const int AXES_VIEWPORT_SIZE = 50;
glDisable(GL_DEPTH_TEST);
glViewport(0, 0, AXES_VIEWPORT_SIZE, AXES_VIEWPORT_SIZE);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

//draw the axis

//set back the viewport to normal


The problem now is that I don't know how to rotate the axis without translating them so that they stay at the same location in the small viewport.

Share this post


Link to post
Share on other sites
Quote:
Original post by Deckards
The problem now is that I don't know how to rotate the axis without translating them so that they stay at the same location in the small viewport.


Just multiply by the same matrix from your camera except with the translation part (indices 12,13, and 14 in the array) set to 0.

Share this post


Link to post
Share on other sites
You should be able to do it easily. If you call a glLoadIdentity first, then translate to the position(lower left or whatever), then rotate according to the same angles as you camera(not using gluLookAt rather glRotatef), don't try to use LookAt, just rotate and draw like anything else.

Share this post


Link to post
Share on other sites

This topic is 4701 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this