0
votes

I need to move my code from a C++/OpenGL and Config.txt situation to a UI friendly space. I was told here to try Qt and installed it in Windows.

The issue I ran into is that it did not support the OpenGL version I needed out of the box and I had to rebuild with the -opengl desktop parameter.

First time doing this, but was able to follow the instructions (and a ton of Google) and it "succesfully" was built. My issue now is I am unsure how to make the files I have work with Qt Creator.

I copied over all the folders from the qt5 folder created by git over to the Src folder in Qt5.0.1/5.0.1/Src but the hellogl example still wouldn't build.

I checked the options and it was pointing to a qmake in Qt5.0.1/5.0.1/msvc2010/bin so I copied over the qmake.exe from qtbase/qmake over to this folder (renaming the old one) and now Qt Creator builds the hellogl example on my Windows system.

My worry is, did I do this the right way? I fumbled around and got something, but is this the way I should have proceeded after I built the qt5 from git? If not what was the way I should have gone about making it all work with the Qt Creator?

1

1 Answers

1
votes

The typical way to utilize the modern OpenGL the feature set (post fixed-function pipeline) in Qt is by utilizing a extension wrangler (GLEW) that finds all the OpenGL functions your graphics drivers support BEFORE Qt includes any OpenGL headers.

To accomplish this simply do the following:

  1. If you already haven't, download GLEW (or another extension wrangler if you wish) and install it in your system path. I would recommend the 32 bit package as it will be easier to work with.

  2. #include glew.h in your source code before any other Qt header includes that may use OpenGL headers. Just to be safe, make glew.h the first header included in your source code.

  3. In your Qt project's .pro file add the line LIBS += -lGLEW (mac/linux) or LIBS += -lglew32 (windows).

Note: Beware of using Qt OpenGL wrappers when implementing an application that uses post fixed-function pipeline facilities. Qt 5's OpenGL wrappers all operate using the OpenGL ES 2.0 specification which may cause problems when interleaved with your OpenGL 3/4 code. Even QPainter can become troublesome when performing overpainting on a QGLWidget due to it's heavy use of the fixed-function transformation stack. I am currently developing a library called QGLX that provides alternative Qt wrappers designed for complying to the modern desktop OpenGL specification. The beta will hopefully be released by the end of this year for Qt 4 & Qt 5.