Qt contradicts GLee

I am adding OpenGL support to a game based on Qt 3 (office policy). The basics (QGLWidget, etc.) are working fine.

To get to the OpenGL extensions, I arbitrarily chose GLee (it was compiled out of the box, GLew did not).

GLee.h and qgl.h do not play well together. AFAICT, each must be included in front of the other.

I checked the preprocessing checks [that made sure it was turned on first] from GLee.h, inserted preprocessor directives into it before including OpenGL headers, and then turned on qgl.h first. On linux, it boils down to:

    #define __glext_h_  /* prevent glext.h from being included  */
    #define __glxext_h_ /* prevent glxext.h from being included */
    #define GLX_GLXEXT_PROTOTYPES
#include <qgl.h>
#include "GLee.h" // my hacked version

It builds (I don’t know if my code will actually run ... this question is proactive [ie I put off]), but it seems like a terrible kludge. A lot of people appeared in Googling asking this basic question (although most of them did not bother to figure out the errors of the fake compilers so that they could see the problem with the root), but I did not see the real answers.

Is there a better (more elegant, portable, reliable, etc.) way to do this?

+5
source share
4 answers

It's still not as clean as we would like, but at least it builds and runs without cracking GLee.h.

After all else, #include qobject.h, GLee.h and qgl.h (in that order).

So the header file might look like

...blah...
...other #includes

#include <qobject.h>
#include "GLee.h"
#include <qgl.h>

class MyGlWidget : public QGLWidget
{
...
}

then the soure file will # include this file last.

+3

( , , , , glew):

#include <GL/GLee.h>
#include <GL/glu.h>

#undef Status
#undef Bool
#undef CursorShape
#undef Unsorted
#undef None
#undef KeyPress
#undef KeyRelease
#undef FocusIn
#undef FocusOut
#undef FontChange
#undef GrayScale
#undef Expose
#undef Complex

...

#include <qgl.h>
+2

, , . .

( : , - GLee.h #error, ... .)

, , Qt , X. , CursorShape X.h 0, qnamespace.h , ": "

, , - undefined:

#include "qgl.h"
#undef __glext_h_
#undef __glxext_h_
#undef __gl_h_
#include "GLee.h"

GLee.h, , GLee.h .

GLee.h qgl.h , .

, - -E gcc - , , . 0, , . /usr/include , - X.h. , , pary - Qt - , X11 - .

+1
source

Short answer: use glew. It works great with QT.

0
source

All Articles