Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
OpenGL 3.x functions
I'm attempting to integrate my 3.3 opengl codebase with QtQuick from Qt5. I suspect I'm going about this the wrong way. The issue I have is that using QOpenGLContext throws up these warnings when combined with GLEW:
@#warning qopenglfunctions.h is not compatible with GLEW, GLEW defines will be undefined
#warning To use GLEW with Qt, do not include <qopengl.h> or <QOpenGLFunctions> after glew.h@
So I can't figure out how to mix Qt5 and GLEW together.
One possible alternative I've found is to use QOpenGLContext::getProcAddress but then I would have to maintain all these functions myself. Is QOpenGLContext the wrong thing to use then? Do I stick with QGLWidget and QGLContext?
rcari last edited by
The problem seems to be with having both GLEW and QtOpenGL includes in a same compilation unit. You could put all your rendering code that use GLEW in files (.cpp) that deal with the pure OpenGL side of things and wrap all that drawing code within objects on which you would just call a method @object->render();@ or something like that.
ZapB last edited by
You can #include <GL/glew.h> after the Qt OpenGL-related headers.
I have a patch pending for Qt 5.1 which will remove the need to use GLEW with Qt5: https://codereview.qt-project.org/#change,35408 Unfortunately this missed the window for 5.0.
I went the route of placing the headers in different compilation units. Including GLEW after the Qt opengl headers didn't work because of GLEW complaining about having GL/gl.h included before GLEW.
I saw the change to remove GLEW. The approach seems similar to GL3W. I'll be looking forward to that change.
ZapB last edited by
Please feel free to cherry pick the above set of changes and take them for a spin. I am looking for feedback and testing. If you can try them out it would be much appreciated.
Awesome, I'll give that a try tomorrow.