Building VTK for Arm64 with OpenGL ES

Hello,

I am trying to build VTK on FriendlyDesktop (Ubuntu flavour) on my NanoPC-T4, and am running into a build error.

/home/pi/devel/PB-x64/Deps/vtk/GUISupport/Qt/QVTKOpenGLNativeWidget.cxx: In member function ‘virtual void QVTKOpenGLNativeWidget::paintGL()’:
/home/pi/devel/PB-x64/Deps/vtk/GUISupport/Qt/QVTKOpenGLNativeWidget.cxx:537:3: error: ‘QOpenGLFunctions_3_2_Core’ was not declared in this scope
   QOpenGLFunctions_3_2_Core* f =
   ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/pi/devel/PB-x64/Deps/vtk/GUISupport/Qt/QVTKOpenGLNativeWidget.cxx:537:3: note: suggested alternative: ‘QOpenGLFunctionsPrivate’
   QOpenGLFunctions_3_2_Core* f =
   ^~~~~~~~~~~~~~~~~~~~~~~~~
   QOpenGLFunctionsPrivate
/home/pi/devel/PB-x64/Deps/vtk/GUISupport/Qt/QVTKOpenGLNativeWidget.cxx:537:30: error: ‘f’ was not declared in this scope
   QOpenGLFunctions_3_2_Core* f =
                              ^
/home/pi/devel/PB-x64/Deps/vtk/GUISupport/Qt/QVTKOpenGLNativeWidget.cxx:538:83: error: no matching function for call to ‘QOpenGLContext::versionFunctions<QOpenGLFunctions_3_2_Core>()’
     QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_3_2_Core>();
                                                                                   ^
In file included from /opt/qt-5.12.2/include/QtGui/QOpenGLContext:1:0,
                 from /home/pi/devel/PB-x64/Deps/vtk/GUISupport/Qt/QVTKOpenGLNativeWidget.cxx:20:

I have set the VTK_OPENGL_HAS_ES and VTK_OPENGL_HAS_EGL flags, and the appropriate libraries seem to be found.

I have built my own Qt with the -opengl es2 backend selected. Has anyone successfully built for arm64/opengl es?

So, exploring the code at it looks like QVTKOpenGLNativeWidget cannot be compiled with OpenGL ES, as the header for QOpenGLFunctions_3_2_Core has a guard against it. I am exploring some workarounds.

By removing QVTKOpenGLNativeWidget from my working copy and appropriate CMakeLists.txt changes I am able to build. This project is using CTK so hopefully it will still work with QVTKOpenGLWidget (which it should according to its CMakeLists.txt)

Some minor changes to QVTKOpenGLNativeWidget enable compilation of VTK. Specifically using QOpenGLExtraFunctions instead of QOpenGLFunctions_3_2_Core.

Hi Adam,

Thanks for your work. We do not test on Arm64 obviously but your contributions are welcome. Feel free to open a merge request so your changes can be integrated into VTK.

Of course, I know it’s not a normal use case, but I thought I’d explore it anyways.

QVTKOpenGLNativeWidget seems like an easy fix (if I understand the Qt OpenGL wrapping correctly), but QVTKGraphicsItem (via vtkOpenGLError) will be a bit harder to unravel. For now I’ve just disabled Module_vtkGUISupportQtOpenGL as I don’t need it (I think).