PDA

View Full Version : 2D controls over a 3D world



JohnS
09-19-2000, 04:34 PM
Hello there. I have the following problem.
How can I draw 2D controls over my 3D world?
(i.e. in the same window where my 3d rendering takes place?)
Thanks very much in advance.

Bob
09-19-2000, 09:38 PM
Best, easiest and fastest ways is to setup an orthographic projection matrix, and draw all controls as textured quads.

Assuming your window size is 640x480 pixels, you can do like this.



glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho2D(0,640,0,480);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
// here you can draw all quads directly in screen coordinates
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);

JohnS
09-20-2000, 07:08 AM
Many thanks for your help and code. It worked (of course : ) )and I rearranged
everything to work with one ogl window. However I use glDrawPixels to display the
console control and the program is unacceptably slow. I think I will break the
console image in 128x128px fractions and use texture mapping to display it. If this
does not work I will return to the 2 window approach and use SendMessage to
update each window as needed. If this won;t work I might use threads and God
help me... Thanks again.