View Full Version : Game UI in OpenGL
What is the best way to draw a UI in Op for a strategy game? The only way I know is to draw some quads in front of the cam and put textures on it, but that is slow and impossible to put text on it or to locate clicks!
[This message has been edited by Sim (edited 09-09-2000).]
Well, quads is one way, and a pretty darn good way too. It gives you maximum flexibility, because you can do the UI as you want to. And if it's slow, you are probably doing something wrong. Quads are as fast as standard triangles.
And to put text on a quad is not that difficult, either add the text to the texture, or use a second renderpass and add a new quad with the text.
Clicks can easily be detected with (as long as you know the mouseposition and what button is pressed) the selection mode. Just render the buttons to the selectionbuffer, and let OpenGL tell you what quad you clicked on. This works for ANY kind of button form.
09-13-2000, 12:54 PM
A better way, if you don't want to have a picking algorithm or something, is to change the Projection matrix to glOrtho, matching right and height to your windows respective width and height (gluOrtho2D works better), then just process the mouse clicks. Remember to do glPushMatrix/glPopMatrix, to save your camera positions. Also, disable Depth testing and mask out the zbuffer
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.