Missing typedefs with qopenglwidget

D

Desperado17 about an hour ago

Greetings,

I try to build a Qt6 OpenGL application on an Ubuntu 22.04 Desktop system according to this:

But I get undefined errors:

In file included from /usr/include/x86_64-linux-gnu/qt6/QtGui/qopengl.h:146,
from /usr/include/x86_64-linux-gnu/qt6/QtOpenGLWidgets/qopenglwidget.h:47,
from /usr/include/x86_64-linux-gnu/qt6/QtOpenGLWidgets/QOpenGLWidget:1,
<ourinternalfiles>
/usr/include/x86_64-linux-gnu/qt6/QtGui/qopenglext.h:235:67: error: ‘GLdouble’ has not been declared
235 | typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s);

Same for other typedefs like GLshort etc.

So far I tried adding libgl1-mesa-dev, libglu1-mesa-dev libegl1-mesa-dev libgles2-mesa-dev mesa-common-dev libxcb-glx0-dev, freeglut3-dev

Any idea what that might be?

Regards

It appears qopenglext.h prototypes some GL functions with GL types, but neither defines those types nor includes one of the header files that defines them.

So which header(s) define GLdouble?..

> grep 'typedef.*GLdouble *;' /usr/include/GL/*
/usr/include/GL/gl.h:typedef double             GLdouble;       /* double precision float */
/usr/include/GL/glcorearb.h:typedef double GLdouble;
/usr/include/GL/glew.h:typedef double GLdouble;
grep: /usr/include/GL/internal: Is a directory

So one of these:

#include <GL/gl.h>   // OR...
#include <GL/glcorearb.h>

needs included before qopenglext.h is included.

Which package provides those header files? Here:

> rpm -qf /usr/include/GL/gl.h /usr/include/GL/glcorearb.h
Mesa-libGL-devel-18.0.2-lp150.18.3.1.x86_64
Mesa-libGL-devel-18.0.2-lp150.18.3.1.x86_64

If your system is similar, my bet is that libgl1-mesa-dev provides these header files.

So unless you see errors about not being able to include some header file in this compiler run, then the problem is some file should be including one of the above 2 GL header files first and isn’t.

This is possibly related:

That is, disable use of ANGLE (an OpenGL ES emulator) and force use of the native OpenGL provided by the platform.

Ah, here we go:

qopengl.h:

...
#if defined(QT_OPENGL_ES_2)
...
#else // non-ES2 platforms
# if defined(Q_OS_MAC)
...
# else
#  define GL_GLEXT_LEGACY // Prevents GL/gl.h from #including system glext.h ...
#  ifndef GL_GLEXT_PROTOTYPES
#   define GL_GLEXT_PROTOTYPES
#   include <GL/gl.h>
#   undef GL_GLEXT_PROTOTYPES
#  else
#   include <GL/gl.h>
#  endif
#  include <QtGui/qopenglext.h>
# endif // Q_OS_MAC
#endif // QT_OPENGL_ES_2

This suggests that…

  • Yes, when building for OpenGL, gl.h should be included before pulling in qopenglext.h, and
  • You’re probably supposed to include qopengl.h instead of qopenglext.h. This’ll get that gl.h header file included first (before qopenglext.h).

On that last point… The Qt docs tend to confirm that:

Some more info: I try to combine Qt with Magnum GitHub - mosra/magnum: Lightweight and modular C++11 graphics middleware for games and data visualization and the whole application is configured for OpenGL ES. It seems that Qt still pulls the desktop GL headers while Magnum pulls the lightweight GLES headers.

Is there any way to configure Qt for desktop so that it only pulls GLES headers and no GL headers?