Advertisement

Making a GUI

Started by December 04, 2002 01:34 AM
1 comment, last by Structural 21 years, 11 months ago
Aye, I''ve started with OpenGL a few weeks ago, and I''m coming quite far at the moment. There is one thing though I cannot find in my book or any tutorials I''ve read. This is the making of a GUI. What I want to make is basically a partially-transparent GUI with knobs and buttons which the user can use to control the 3D world and display data in a 2D way. If you don''t know what I exactly mean think of the health/ammo information given in first person shooters, like the HUD in Unreal. Any basic tips/tutorials are very welcome. Please don''t describe it too cryptic as I''m still not fully used to the OpenGL API. Thank you
STOP THE PLANET!! I WANT TO GET OFF!!
Here is one solution.. I think there are better, but this is one way to do it.


// Enter Ortho Mode: (Render infront of the camera... kind of)
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho( left, right, bottom, top, 0, 1); // 0/1 is near/far
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

// Enable Blending, so that you can render transparent things..
glBlendFunc(GL_SCR_ALPHA,GL_ONE);
glEnable(GL_BLEND);

// Just render anything here =) (like quads with textures)

glDisable(GL_BLEND);

// Back To Perspective:
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);

----------------------------------------------Petter Nordlander"There are only 10 kinds of people in the world. They who understand binary and those who do not"
Advertisement
Here''s the first of an excellent series of articles dealing with the creation of a GUI. The articles are DirectX based, but the theory is the same - as the previous poster pointed out, actually rendering the GUI to screen is quite easy. The data structures and input processing are the tricky aspects.

This topic is closed to new replies.

Advertisement