February 14, 2012

Gonsor Gonsor
Lab Rat
1 posts

How to use glew with Qt 4.8?

 

Hi,

I am trying to use glew and Qt together, which worked fine with Qt 4.7. In 4.8 however it does not seem to be possible anymore. Including glew before QtOpenGL yields:

  1. /usr/include/QtOpenGL/qglfunctions.h:46:2: warning: #warning qglfunctions.h is not compatible with GLEW, GLEW defines will be undefined [-Wcpp]
  2. /usr/include/QtOpenGL/qglfunctions.h:47:2: warning: #warning To use GLEW with Qt, do not include <QtOpenGL> or <QGLFunctions> after glew.h [-Wcpp]

and it later does not find functions like ‘glUseProgram’. If I turn the includes around, the result is:
  1. /usr/include/GL/glew.h:84:2: error: #error gl.h included before glew.h
  2. /usr/include/GL/glew.h:87:2: error: #error glext.h included before glew.h

I cannot find much information about how it would still be possible to use them together. I have a rather large codebase of platform independent c++ opengl code and I always used Qt for window/context creation etc on desktops. The dependency on glew is not necessary, if I could still call all gl* functions normally c style. The documentation of QGLFunctions indicates how to achieve this for the paintGL method only, which is obviously not enough.

Is there still a way to use glew and Qt 4.8 together? Or to drop glew as explained above?

Regards
Daniel

4 replies

April 3, 2012

stante stante
Lab Rat
1 posts

QGLFunctions has only support for OpenGL/ES 2.0 API functionality. For using functionality of the latest OpenGL API you should not include QtOpenGL because it include qglfunctions.h and yields to the error you described. If you want to use your custom OpenGL widget based on QGLWidget you can just include the glew header before QGLWidget.

April 10, 2012

limdor limdor
Lab Rat
14 posts

I confirm what stante says. I use glew and Qt 4.8 and I just do:

  1. #include "glew.h"
  2. #include <QGLWidget>

without QGLFuntions include.

April 15, 2012

KeithS KeithS
Lab Rat
34 posts

Same here:

  1. #include <GL/glew.h>
  2. #include <QGLWidget>
  3. #include <QGLFramebufferObject>
  4. #include <QGLPixelBuffer>
  5. #include <QGLBuffer>

works just fine in Qt 4.x

[Edit: Added @ tags around code; mlong]

May 12, 2013

mfeemster mfeemster
Lab Rat
17 posts

This has ceased working in Qt 5. QGLWidget automatically includes QGLFunctions, which blows away glew. This ought to be fixed.

 
  ‹‹ how to add the external libraries in the .pro file      Installing Qt SDK on mac 10.5.8 ››

You must log in to post a reply. Not a member yet? Register here!