JoGL GUI/HUD

In jogl, how does one make a gui/hud that is drawn ontop of the canvas? its something that I havent been able to crack yet. thanks for any help.

What im looking for is a way to draw at least a rectangle inside the canvas (or glpanel which ever) and be able to put components into it. It should be like a internal frame. again, thanks for any help.

You’ll have to play with your modelview matrix. For example, after drawing all the 3D stuff, you just load the identity matrix again, and your canvas will stretch from (-1,-1) to (1,1) again. I believe. Please don’t take my word for it, look it up! You could do a little scaling, so the (0,0) coordinates are the top left of your screen, and e.g. (800,600) the bottom right. Then draw at will. ;D

Draw your 3D-stuff, reset the projection matrix, change to orthographic projection using glOrtho, reset the modelview matrix, disable depth testing and draw the hud:


// draw your 3d-stuff
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrtho(left, right, bottom, top, znear, zfar);
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glDisable(GL.GL_DEPTH_TEST);
// draw your hud

ah thank you cylab and bahuman :slight_smile: i was wonderin how it was done, i’ll put it to use when i get back from work, thanks again :smiley:

Well, wait a moment - is this HUD supposed to show Java components, or something that’s rendered from OpenGL?