tags:

views:

470

answers:

3

I am writing a program in OpenGL and I need some sort of interfacing toolbar. My initial reactions were to use a GUI, then further investigation into C++ I realized that GUI's are dependent on the OS you are using (I am on Windows). Therefore, I decided to use QT to help me.

My Question is if I am taking the best/appropriate approach to this solution. Am I even able to write my OpenGL program and have the GUI I want to create interface with the C++ code to do what I want it to do.

For example, If I create a simple "control panel" with arrows in each direction. And on screen I have a box object created by glut can I interface the arrows to be clicked on and interact with the openGL program to move the box?

Thanks for all of the help,

Zach Smith

+8  A: 

Using Qt is coherent for your problem: it provides good integration of OpenGl through the QtOpenGL module.

  1. Derive your display classes from QGLWidget and implement virtual methods paintGL() etc.
  2. You will have access to the Qt's signal and slot system so that you will be able to catch Gui events and update the OpenGl display.
Julien L.
QtOpenGL Module: http://doc.trolltech.com/4.5/qtopengl.html
Georg Fritzsche
With very little knowledge of Qt I got an openGL window with a decent particle system working in about 2 hours. Its really quite nice.
Ron Warholic
A: 

You can use regular non-OpenGL Qt widgets on top of a QGLWidget so what you describe is do-able.

One thing I came across when doing this was that the regular widgets had to be opaque. The moment they were transparent in any way there was all sorts of garbage underneath them. That was a while ago so maybe the latest version addresses this issue. May have been platform-specific too so YMMV.

Troubadour
Ah, my anonymous downvoting shadow has returned!
Troubadour
+1  A: 

Stay in GLUT. There's no need to add Qt for a control panel. You could open a sub window (or second window, whichever works better for your program design), and draw the controls into that window, and use GLUT to handle the mouse interaction.

Furthermore, Qt and GLUT each have their own event loops. To use just Qt's event loop, you'd have to abandon much of the GLUT structure, since the GLUT event loop would not be there to call your callback functions. Qt does have the functionality to have let somebody else event loop call Qt's event processing code, but I don't think there's an easy way to make GLUT hand off the event information.

Mr. Berna
Since the author does not say that he is already using GLUT, your comment does not apply. Qt is clearly superior to GLUT and allows the application to evolve into either a full-blown application or a reusable widget.
Dat Chu
Dat Chu, the author does say he's already using GLUT. See paragraph three of his post, and the tags. You are right that Qt is superior to GLUT in most aspects, but mixing Qt and GLUT is very hard.
Mr. Berna