OpenGL / C ++ / Qt - consultation required

I am writing a program in OpenGL and I need a pairing toolbar. My initial reactions were to use a graphical interface, and then further research in C ++. I realized that the graphical interface depends on the OS you are using (I am on Windows). So I decided to use QT to help me.

My question is that I am using the best / appropriate approach to this solution. I can even write my OpenGL program and have a graphical interface that I want to create using C ++ code to do what I want.

For example, if I create a simple “control panel” with arrows in each direction. And on the screen I have a box object created by oversaturation, can I link the arrows that I need to click on and interact with the openGL program to move the field?

+4
source share
3 answers

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

  • QGLWidget display classes from QGLWidget (prior to Qt 4.8) or from QOpenGLWidget (starting from Qt 5.4) and implement virtual paintGL() methods, etc.
  • You will have access to the Qt signal and slot system so that you can catch Gui events and refresh the OpenGl screen.
+7
source

Stay in GLUT. There is no need to add Qt for the control panel. You can open the auxiliary window (or the second window, depending on what is best suited for the design of your program) and draw the controls in this window, as well as use GLUT to interact with the mouse.

In addition, Qt and GLUT have their own event loops. To use only the Qt event loop, you will have to abandon most of the GLUT structure since the GLUT event loop will not be there to call the callback functions. Qt has a function that allows someone else to loop through the events of the Qt event handling code, but I don’t think there is a simple way to get GLUT to pass event information.

-one
source

You can use regular non-OpenGL Qt widgets on top of QGLWidget , so what you are describing is possible.

One thing I came across when I did this was that regular widgets should have been opaque. At that moment when they were transparent, they have all kinds of garbage. It was a long time ago, so perhaps the latest version solves this problem. Perhaps this also applies to the platform, so YMMV.

-2
source

All Articles