Skip to main content
GameDev.net gamedev.net
🔒 Locked

Status panes in front of scene?

Started by ajmas Nov 22, 2007 at 10:29 AM 5 replies 1.7k views
Original Post
ajmas
ajmas
I am wanting to create a scene and at the same time draw some panes in front of the scene which would allow the user to change certain settings. In doing so I want to ensure that any manipulattion of my scene does not interfere with my panes. Can anyone suggest how to do this or point me towards some examples?
spookycat
spookycat
If you want a really nice simple solution then have a look at AntTweakBar Very easy to use.
ajmas
ajmas
Thanks for the reply and for the link.

In reality I am more interested in learning the mechanics of doing it myself for the moment. I am still learning OpenGL and feel that I would rather understand how this is done in OpenGL, before using a ready built solution.
jouley
jouley
The basics of a 2D overlay/HUD are to render your 3D scene with a perspective projection and then switch to an orthographic projection (with glOrtho) to render your status panel. There's also a nice entry in the forum FAQ about 2D with OpenGL.
ImperfectFreak
ImperfectFreak
I actually just worked this out myself. Here is some psuedocode of what I did:

pushPerspectiveProjection();

while(running)
pushOrthographicProjection();
drawUI();
popProjection();

drawScene();
end

pushOrthographicProjection()
glPushAttrib(GL_TRANSFORM_BIT);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0.0f, width, 0.0f, height, -1.0f, 1.0f);
glPopAttrib();
end
ajmas
ajmas
Thanks, this work beautifully. Some actual code, in Java using JOGL, for anyone else who happens to come along this thread:

    void pushOrthographicProjection( GL gl ) {        gl.glPushAttrib(GL.GL_TRANSFORM_BIT);        gl.glMatrixMode(GL.GL_PROJECTION);        gl.glPushMatrix();        gl.glLoadIdentity();        gl.glOrtho(0.0f, getWidth(), 0.0f, getHeight(), -1.0f, 1.0f);          }    void popOrthographicProjection( GL gl ) {        gl.glPopMatrix();        gl.glPopAttrib();     }
swiftcoder
swiftcoder
Just make sure you don't forget to toggle the matrix mode back before drawing ;)
Quote:
Original post by ajmas
    void pushOrthographicProjection( GL gl ) {        gl.glPushAttrib(GL.GL_TRANSFORM_BIT);        gl.glMatrixMode(GL.GL_PROJECTION);        gl.glPushMatrix();        gl.glLoadIdentity();        gl.glOrtho(0.0f, getWidth(), 0.0f, getHeight(), -1.0f, 1.0f);              gl.glMatrixMode(GL.GL_MODELVIEW);     }    void popOrthographicProjection( GL gl ) {         gl.glMatrixMode(GL.GL_PROJECTION);          gl.glPopMatrix();         gl.glMatrixMode(GL.GL_MODELVIEW);          gl.glPopAttrib();     }
Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.