QVTKOpenGLNativeWidget crash when using Mesa

Viewed 136

I have a problem with QVTKOpenGLNativeWidget when using software rendering mode. I am using vtk 9.0.1 with Qt6 ( 6.2.4) and Mesa driver 22.0 (Releases · pal1000/mesa-dist-win · GitHub). The application crashes when widget->show() is called. The problem seems to be that glew fails to initialize.

This minimal example illustrates the problem:

#include <QtGui/qsurfaceformat.h>
#include <QApplication>
#include <vtkAutoInit.h>

VTK_MODULE_INIT( vtkRenderingOpenGL2 )
VTK_MODULE_INIT( vtkRenderingContextOpenGL2 )
#include <QVTKOpenGLNativeWidget.h>
#include <vtkGenericOpenGLRenderWindow.h>


int main( int argc, char** argv ) {

    SetEnvironmentVariableW( L"gallium_driver", L"llvmpipe" );
    SetEnvironmentVariableW( L"QT_LOGGING_RULES", L"qt.qpa.gl=true" );

    //setting this to false works, but I need to use the software rendering
    // the mesa dll opengl32sw.dll is next to the exe
    QCoreApplication::setAttribute( Qt::AA_UseSoftwareOpenGL, true );

    auto format = QVTKOpenGLNativeWidget::defaultFormat();
    QSurfaceFormat::setDefaultFormat( format );
    QApplication app( argc, argv );

    auto* qvtkWidget_ = new QVTKOpenGLNativeWidget();
    qvtkWidget_->show(); //crashes here

    std::cout << "Window is ready to render " << std::boolalpha << qvtkWidget_->isValid();
    qvtkWidget_->close();
    delete qvtkWidget_;

    return EXIT_SUCCESS;
}

Any help would be very appreciated.

Output from qt.qpa.gl: Output from qt.qpa.gl

qt.qpa.gl: Qt: Using WGL and OpenGL from "opengl32sw" qt.qpa.gl: QOpenGLStaticContext::create OpenGL: "Mesa/X.org","llvmpipe (LLVM 14.0.0, 256 bits)" default ContextFormat: v4.5 profile: QSurfaceFormat::CompatibilityProfile options: QFlagsQSurfaceFormat::FormatOption(DeprecatedFunctions),SampleBuffers, Extension-API present Extensions: 293 ... 2022-04-12 16:15:57.074 ( 0.557s) [ ]vtkOpenGLRenderWindow.c:493 ERR| vtkGenericOpenGLRenderWindow (000001B0D5E8E750): GLEW could not be initialized: Missing GL version

Crash : Unhandled exception at 0x0000000000000000 in MinimalExample.exe: 0xC0000005: Access violation executing Crash

0 Answers
Related