Skip to content

Comments

#11371 Remove GLEW dependency and use Qt's QOpenGLFunctions#13631

Open
kriben wants to merge 2 commits intoOPM:devfrom
kriben:11371-remove-glew
Open

#11371 Remove GLEW dependency and use Qt's QOpenGLFunctions#13631
kriben wants to merge 2 commits intoOPM:devfrom
kriben:11371-remove-glew

Conversation

@kriben
Copy link
Collaborator

@kriben kriben commented Feb 18, 2026

Replace embedded GLEW library with Qt's native OpenGL function loading (QOpenGLFunctions/QOpenGLExtraFunctions) to resolve Qt 6 compatibility warnings about GLEW conflicts with qopenglfunctions.h.

  • Update CVF_CALLSITE_OPENGL macro to provide QOpenGLExtraFunctions pointer
  • Replace GLEW initialization with Qt OpenGL context validation
  • Keep direct calls for fixed-function GL (glBegin, glEnd, glMatrixMode, etc.)
  • Remove glew/ directory containing embedded GLEW source

Replace embedded GLEW library with Qt's native OpenGL function loading
(QOpenGLFunctions/QOpenGLExtraFunctions) to resolve Qt 6 compatibility
warnings about GLEW conflicts with qopenglfunctions.h.

- Update CVF_CALLSITE_OPENGL macro to provide QOpenGLExtraFunctions pointer
- Replace GLEW initialization with Qt OpenGL context validation
- Keep direct calls for fixed-function GL (glBegin, glEnd, glMatrixMode, etc.)
- Remove glew/ directory containing embedded GLEW source
Qt OpenGL headers conflict with Windows SDK glu.h causing APIENTRY
redefinition errors. Remove glu.h includes and replace GLU calls:
- gluBuild2DMipmaps -> glTexImage2D + glGenerateMipmap
- gluOrtho2D -> glOrtho
@kriben
Copy link
Collaborator Author

kriben commented Feb 18, 2026

Hi @sigurdp!

@magnesj and I would like your input on this PR.

Qt6 provides its own OpenGL function resolution infrastructure that replaces the need for GLEW.
Here's what Qt6 offers instead:

  1. QOpenGLFunctions — This class resolves OpenGL ES 2.0 (and desktop GL equivalent) functions portably. You inherit from it or access it via QOpenGLContext::functions(). It handles all the platform-specific function pointer loading that GLEW traditionally did.
  2. QOpenGLExtraFunctions — Extends the above with OpenGL ES 3.0/3.1/3.2 functions (and their desktop equivalents), available via QOpenGLContext::extraFunctions().

Pros:

  • GLEW manages its own global state and context assumptions, which can clash with Qt's context management (especially with multiple contexts or context sharing).
  • Qt's wrappers are context-aware and integrate cleanly with QOpenGLContext, QOpenGLWidget, and the rest of the Qt rendering pipeline.
  • We eliminate an external dependency for something Qt already handles well.

Cons:

  • Even more dependent on Qt.

@kriben kriben requested a review from sigurdp February 18, 2026 13:22
@kriben
Copy link
Collaborator Author

kriben commented Feb 18, 2026

[1022/2965] Building CXX object Fwk/AppFwk/cafViewer/CMakeFiles/cafViewer.dir/cafViewer.cpp.o
Warning that started the investigation:

In file included from /usr/include/x86_64-linux-gnu/qt5/QtGui/QOpenGLContext:1,
                 from /home/resinsight/projects/ResInsight/Fwk/AppFwk/cafViewer/cafViewer.cpp:75:
/usr/include/x86_64-linux-gnu/qt5/QtGui/qopenglcontext.h:55:2: warning: #warning qopenglfunctions.h is not compatible with GLEW, GLEW defines will be undefined [-Wcpp]
   55 | #warning qopenglfunctions.h is not compatible with GLEW, GLEW defines will be undefined
      |  ^~~~~~~
/usr/include/x86_64-linux-gnu/qt5/QtGui/qopenglcontext.h:56:2: warning: #warning To use GLEW with Qt, do not include <qopengl.h> or <QOpenGLFunctions> after glew.h [-Wcpp]
   56 | #warning To use GLEW with Qt, do not include <qopengl.h> or <QOpenGLFunctions> after glew.h
      |  ^~~~~~~

@magnesj
Copy link
Member

magnesj commented Feb 18, 2026

@magnesj
Copy link
Member

magnesj commented Feb 18, 2026

Here are 4 relevant Qt documentation links for this PR:

  1. [QOpenGLFunctions](https://doc.qt.io/qt-6/qopenglfunctions.html) — Cross-platform OpenGL ES 2.0 function resolution
  2. [QOpenGLExtraFunctions](https://doc.qt.io/qt-6/qopenglextrafunctions.html) — ES 3.x extensions used in the CVF_CALLSITE_OPENGL macro
  3. [Changes to Qt OpenGL (Qt 6)](https://doc.qt.io/qt-6/opengl-changes-qt6.html) — Qt 6 OpenGL module restructuring and porting notes
  4. [QOpenGLWidget](https://doc.qt.io/qt-6/qopenglwidget.html) — Widget base class used throughout ResInsight

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants