Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
OpenGL demos in Qt 4.8 don't compile
So I downloaded the latest SDK and tried to setup the Boxes OpenGL demo on Windows . The compile throws me an error that it can't find gluPerspective identifier and it is right because the project doesn't reference this lib which should be glew . So I connected glew and put the header glew.h into glextension.h .Running the compiler again throws me the following preprocessor warning :
#warning qglfunctions.h is not compatible with GLEW, GLEW defines will be undefined
#warning To use GLEW with Qt, do not include <QtOpenGL> or <QGLFunctions> after glew.h
So how do I deal with it ? If I remove those headers I need to delete almost half of Qt OpengGL methods in this demo and replace with those of glew.I suppose the author of the demo did something else so that he didn't need to use glew ? Anyone can help with this issue ?
In your qmake file, add:
QT += opengl
It is set by default
You are not supposed to add any glew or glut libraries to your programs. Just include QtOpenGL in your source and it will implicitly include everything it requires. Have you tried compiling the example called grabber? please compile it without editing it and paste the compilation log here if it doesn't compile. I based my first openGL simulation on that example.
Look , I have already this header included by default . For example scene.h has it bit it doesn't recognize gluPerspective....
My friend, please compile that example and copy the log so that I can help you. I can't suggest why this happens without reading the compilation log of an example I know. If that example compiles with no problems, then it's another story.
This is the example I'm talking about
Please find it in your SDK or download it to your computer. It should work properly, unless you have other problems that we could investigate later.
TheDestroyer , I have good and bad news for you .The good ones are that the grabber works .The bad news are that it has nothing to do with my issue.It doesn't contain gluPerpective() and it uses a fixed (old) pipeline .So it is seems unrelated.What I can see here is I can't even get any glu method in the editor IntelliSence completion . But have you tried to compile and run the Boxes demo by yourself ?
Output of the boxes compilation:
..\boxes\scene.cpp(925) : error C3861: 'gluPerspective': identifier not found
C:\QtSDK\QtCreator\bin\jom.exe -f Makefile.Debug
jom: C:\QtSDK\Demos\4.7\boxes-build-desktop-Qt_4_8_0_for_Desktop_-_MSVC2010__Qt_SDK__Debug\Makefile.Debug [debug\roundedbox.obj] Error 2
jom 1.0.8 - empower your cores
jom: C:\QtSDK\Demos\4.7\boxes-build-desktop-Qt_4_8_0_for_Desktop_-_MSVC2010__Qt_SDK__Debug\Makefile [debug] Error 2
13:27:19: The process "C:\QtSDK\QtCreator\bin\jom.exe" exited with code 2.
Error while building project boxes (target: Desktop)
When executing build step 'Make'
Well ,I think the issue can be closed.The demo was missing
inside QtOpenGL.h header.
Now it works .
Good for you :-). Although I never needed to edit Qt sources, but if it works for you that way, have fun! ;-)
If your problem's solved, be sure and edit the thread title to add [Solved]. Thanks.
guillory last edited by
The demos included in SDK 1.2 seem to have a couple of issues when compiled with 4.8. In 4.8, OpenGL/glu.h is now intentionally no longer included within <QtOpenGL>, and programs that use it must include it themselves. For more info, see https://bugreports.qt-project.org/browse/QTSDK-1022
Adding #include "OpenGL/glu.h" after the other includes in qtbox.h in the boxes source tree fixes the problem without having to modify the main Qt headers.
Also, if you try to compile the demos.pro project, you will need to comment out the "#include <private/qpixmapdata_p.h>" line of the arthurwidgets.cpp file in the shared folder of the demos.