Advertisement

Window within open GL window

Started by March 11, 2005 09:10 AM
2 comments, last by Celesa 19 years, 8 months ago
Hi I been following through the Nehe opengl window tutorial, now the opengl window is up, anyone know how can I create another window within it? EG: Main opengl window to display a 3d model and the small window has some lables that describe the data(text/numbers). Thanks a lot
normally you use a gui,
to present additional informations,

there are some ready mades,
but you can make your own gui, here on gamedev there is an article series
about that topic.

a ready gui I know is Crazy Ed's GUI (or so)...
Advertisement
You can also use the viewports and do it all regualr OpenGL. Remember in the init function you called glViewport(0, 0, 640, 480), or something like that depending on the resolution of the window. You can change these values and call the function in your rendering loop to render only to whatever square you want. If your possible resolutions vary, put the x and y resolution in variables. I'll use XREZ and YREZ for this example.
//Draw to upper left
glViewport(0, YREZ/2, XREZ/2, YREZ/2);
//Draw whatever in this window
//Draw to upper right
glViewport(XREZ/2, YREZ/2, XREZ/2, YREZ/2);
//Draw again, maybe text instead
//Draw to lower left
glViewport(0, 0, XREZ/2, YREZ/2);
//Draw again
//Draw to lower right
glViewport(XREZ/2, 0, XREZ/2, YREZ/2);
/Once again draw whatever

This code draws a four way split screen. The parameters work like texture coords, in that it is from lower left to upper right form 0 to 1. The first two parameters of the function is the lower left corner, the third is the width and fourth the length of the rectangle in which you want to draw. Remember that you would use OpenGL to draw everything if you do it like this though, look at NEHE tut # 14 I think for the GL text.


Hi Thanks a lot , I manage to write some text in the OPENGL Window and able to pass/display variable too. :-)


Thanks!!!


This topic is closed to new replies.

Advertisement