LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: 8Bit_Jedi on July 17, 2013, 10:37:50

Title: HUD Questions (OpenGL 3)
Post by: 8Bit_Jedi on July 17, 2013, 10:37:50
Hello everybody,

Just your thoughts on my method of rendering my HUD.

Pseudo steps I take to draw HUD: (Everything is in the main game loop)

My Questions are:

If I am way out of the ballpark here tell me plz, are there any better ways to handle the HUD staying on top of everything.

Also any tutorials on HUD/Text creation would be helpful, I am soon going to have to implement "drag 'n drop" functionality.

Goodbye everybody.
Title: Re: HUD Questions (OpenGL 3)
Post by: Fool Running on July 17, 2013, 12:33:31
1) It doesn't really matter where you turn on/off stuff. Maybe put it in a place that makes it easy to remember what you did and reverse if if needed. If its easier to remember in the main loop, then put it there, otherwise keep it where it is. :)
2) Just once is fine as long as you never need to change it. OpenGL will remember it for as long as the OpenGL context is available.
Title: Re: HUD Questions (OpenGL 3)
Post by: 8Bit_Jedi on July 17, 2013, 14:29:15
Thankyou,

Looking back with hind-sight question (2) was kinda dumb since I know OpenGL is a state machine and will keep the state set with DepthFunc().

Was checking this 'ol link, always do when I am not sure: http://www.opengl.org/wiki/Common_Mistakes (http://www.opengl.org/wiki/Common_Mistakes), section Disable depth test and allow depth writes

It said: "The correct solution is to tell GL to ignore the depth test results with glDepthFunc(GL_ALWAYS)"

So I replaced my calls of glDisable(GL_DEPTH_TEST) and glEnable(GL_DEPTH_TEST) to glDepthFunc(GL_ALWAYS) and glDepthFunc(GL_LESS) respectively. Same results HUD and text still on top of everything which is good, but still feel that mucking about with OpenGL functions like that in the game loop might cause a small performance hit, but can't think of anything else.