Win32 Controls within an OpenGL window.

Started by
14 comments, last by TheMightyDude 19 years, 3 months ago
Hello All Just a quick question... I have an OpenGL window, and I want to have a Combo Box, a couple of Command buttons and a few Slider controls. Does anyone know how to get it to display within an OpenGL window? Or isnt this posible, if so will I have to create these controls by hand? Because I dont really want to code complete control sets to be used within OpenGL if you can use windows controls. Thansk in advance Paul Kirby
Advertisement
I don't think that's possible.
You could create a window with your controls and than display the OpenGL stuff in a part of that window (I wouldn't know how to do that, but I think 3D editors are made that way).
Or, if you want these controls for your game menus or something like that, you have to create them by yourself or use a library that does it for you (I can't tell you any specific name but I guess there are some out there)
I imagine it would be easier to just use controls within OpenGL, look into the GLUT library which is made for making such GUIs in OpenGL. I'm not sure how good GLUT's built in control selection is, but extensions exist that should cover anything you need.
You can create a control that will house the opengl rendering. I would suggest a multi-line richedit control since you can vary the size and place all your other controls outside.

The code to render within the control is not all that different from rendering in a window, simply take its device context.

Or you can look at this.
Thanks for all the replies.

I will look into how GLUT does it.

I dont really want to use GLUT, but it may help me see how I could do it.

Thanks for the help :)

Paul Kirby
Im not sure if its what you are looking for but try GLUI.

Luke.
Member of the NeHe team.
Quote:Original post by Kazade
Im not sure if its what you are looking for but try GLUI.

Luke.


GLUI uses GLUT :(

I dont really want to use GLUT at all, if I can help it.

Thanks for the reply

Paul
Oops, it logged me out :(
In my last OGL app, I created a seperate window for OGL rendering, tracked it inside a normal dialog (it moves with the dialog when you drag the dialog around) and set it to go fullscreen with a button and back to a dialog window with Esc.

As for using native win API controls on top of openGL, you can do it if you stop rendering when the control is active, otherwise it'll flash as the openGL window continues it's rendering loop and Windows continually sees the need for a repaint on the control.

Before calling your control, stop your rendering loop. I set 'state' flags when a control was active.

The rendering loop looks at the 'state' it's in before commencing with it's next iteration and doesn't render if 'control'-state is set.

Of course, this means you'll have to show/hide your controls with a hotkey, mouse-press, or maybe a context-menu to get 'em up on the screen - they can't be there when you're in render-mode......which is why I ended up building a dialog to house the controls (28 buttons, edit boxes, etc.) and a seperate window altogether just for openGL rendering.

But try it out and see what you come up with.

[Edited by - comservlant on November 28, 2004 1:10:38 AM]
you can also create OpenGL contexts inside of custom control Dialog Boxes in MFC. There is a way to do that somewhere... I just dont remember where I found it :)

This topic is closed to new replies.

Advertisement