vtkOpenGLExtensionManager not Available in VTK 9.3 | Qt 6.5.6 |Unable to initialize OpenGL functions after porting to vtk 9 from vtk 4

Hi ,

Currently we are using Qt 6.5.6 in our application and thats the main criteria. To use medical images and operations related to those images (pan/zoom/windowing) earlier in qt 5.5 version we were using vtk 4.10 and all the image related operations were very smooth and performance was fine.
After migrating to Qt 6.5, we migrated vtk to v9.3 and started facing performance related issues during image operations.
Upon debugging it is found out that vtkOpenGLExtensionManager class is missing in vtk 9.3 which was present in vtk 4 which was initializing openGL functions for caching vtk image across operations.

Now i have 2 questions here

  1. Whats the alternate in vtk 9.3 to vtkOpenGLExtensionManager class i.e to use openGL function initializations.
  2. Is updating to vtk 9.3 mandatory to work with qt6.5 where as vtk 4.10 was working perfectly with qt 5.5?

Secondly, To overcome this vtkOpenGLExtensionManager we are using QVTKOpenGLNativeWidget in conjuction with vtkGenericOpenGLRenderWindow in qt 6.5 instead of QVTKGraphicsWidget used earlier in qt 5.5 and we started facing performance issues like image operations are being slowed down.
Any setting/configuration that we can use in QVTKOpenGLNativeWidget that can compensate the performance like in QVTKGraphicsWidget/vtkQtOpenGLRenderWindow2 ?

There was no vtkOpenGLExtensionManager in VTK 4, perhaps you were using VTK 5.10?

  1. VTK 9.3 used a third-party package called “glew” to manage OpenGL extensions. VTK 9.4 uses a third-party package called “glad” for the same purpose. But management of OpenGL extensions is usually done internally by VTK itself, what were you using the vtkOpenGLExtensionManager for?
  2. VTK 5.10 over ten years old and long past its end-of-life, it was released around 8 years before Qt 6 even existed. I don’t know of anyone actively trying to modify VTK 5.10 for use with qt 6.

You can try calling ReportCapabilities() on your render window after the first call to Render(). This method returns a string with information about the OpenGL context.

My suspicion is that the slowdowns aren’t related to OpenGL, but are instead caused by changes in the VTK pipeline between VTK 5.10 and VTK 9.3 that you haven’t accounted for when modifying your code to work with VTK 9.3. But without seeing your code, it’s impossible to know for sure.

hi , Thanks for your time and response.

I have taken care of 2nd point mentioned above , thats the slowness of the image rendering by adding update() on the widget on move event .

But the 1st point needs your input further where we need to replace vtkOpenGLExtensionManager as our code inside widget → setCacheVtkBackground() using that extention to set other functions which is causing issue as vtkOpenGLExtensionManager no more available. Attaching source snippet for your reference.

void ourGraphicsWidget::setCacheVtkBackground( bool value )
{
if (d->mCacheVtkBackground != value) {
d->mCacheVtkBackground = value;

    if (d->mCacheVtkBackground) {

        vtkOpenGLRenderWindow* oglRenWin = this->GetRenderWindow();
      /  vtkOpenGLExtensionManager* extMan = NULL;
        if (oglRenWin) {
            extMan = oglRenWin->GetExtensionManager();
        }

        if (extMan) {
            // Verify the OpenGl environment supports it.
            extMan->SetRenderWindow(this->GetRenderWindow());
            bool  hasObj = QOpenGLFramebufferObject::hasOpenGLFramebufferObjects();
            // Can only do caching if the OpenGL environment supports frame buffer objects.
            d->mCacheVtkBackground = d->mCacheVtkBackground && hasObj;

            // Need non-power-two textures too.
            d->mCacheVtkBackground = d->mCacheVtkBackground &&
                (extMan->ExtensionSupported("GL_VERSION_2_0") || // GL2.0 has non-power-two textures by default
                    extMan->ExtensionSupported("GL_ARB_texture_non_power_of_two"));

            if (!s_backgroundCachingMessageDisplayed) {
                if (value) {
                    if (d->mCacheVtkBackground) {
                        qDebug() << "Widget:Background caching enabled";
                    }
                    else {
                        qDebug() << "Widget:Background caching not supported:";
                        if (!QOpenGLFramebufferObject::hasOpenGLFramebufferObjects()) {
                            qDebug() << " - OpenGLFramebufferObjects are not supported";
                        }
                        else {
                            if (!extMan->ExtensionSupported("GL_VERSION_2_0"))
                                qDebug() << " - GL_VERSION_2_0 extension not supported";
                            if (!extMan->ExtensionSupported("GL_ARB_texture_non_power_of_two"))
                                qDebug() << " - GL_ARB_texture_non_power_of_two extension not supported";
                        }*/
                    }
                }
                s_backgroundCachingMessageDisplayed = true;
            }

        /*}
        else {
            if (!s_backgroundCachingMessageDisplayed) {
                if (value) {
                    qDebug() << "GraphicsWidget:Background caching not supported : extension manager not available.";
                }
                else {
                    qDebug() << "GraphicsWidget:Background caching not enabled.";
                }
                s_backgroundCachingMessageDisplayed = true;
            }
            d->mCacheVtkBackground = false;
        }*/
    }

    if (!d->mCacheVtkBackground) {

        if (d->mFBO) {
            delete d->mFBO;
            d->mFBO = NULL;
        }
    }
    }

}

how to add GLEW in cmake like other modules?

if((VTK_MAJOR_VERSION EQUAL 9) AND (VTK_MINOR_VERSION GREATER 0))
find_package(VTK COMPONENTS
CommonCore
RenderingVolume
InteractionImage
)

Since VTK 9 already requires GL_VERSION_2_0, do you even need these checks?

I haven’t used glew myself, so unfortunately I have no instructions on its use.