mirror of
https://github.com/introlab/rtabmap.git
synced 2026-10-03 16:47:47 +08:00
CameraRGBD: set VTK QSurfaceFormat before QApplication
On macOS the embedded QVTKOpenGLNativeWidget (CameraViewer's cloud view) crashed on first paint: VTK called a null GL function pointer (vtkOpenGLVertexArrayObject::Bind -> 0x0) because no compatible OpenGL context was set. Set QSurfaceFormat::setDefaultFormat( QVTKRenderWidget::defaultFormat()) before constructing QApplication, as the main rtabmap app already does. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
e646b1cd79
commit
80b537b2e4
@@ -48,6 +48,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <QApplication>
|
||||
#include <QSurfaceFormat>
|
||||
#include <vtkVersionMacros.h>
|
||||
#include <QVTKRenderWidget.h>
|
||||
|
||||
void showUsage(const char * executableName)
|
||||
{
|
||||
@@ -168,7 +171,6 @@ int main(int argc, char * argv[])
|
||||
}
|
||||
if (strcmp(argv[i], "-pcl") == 0)
|
||||
{
|
||||
++i;
|
||||
usePCLViz = true;
|
||||
continue;
|
||||
}
|
||||
@@ -485,6 +487,14 @@ int main(int argc, char * argv[])
|
||||
}
|
||||
else // Use our own visualizer
|
||||
{
|
||||
#if VTK_MAJOR_VERSION > 9 || (VTK_MAJOR_VERSION==9 && VTK_MINOR_VERSION >= 1)
|
||||
// Needed to ensure the appropriate OpenGL context is created for VTK
|
||||
// rendering (QVTKOpenGLNativeWidget). Without it the embedded VTK widget
|
||||
// gets an incompatible context and VTK calls a null GL function pointer
|
||||
// (crash in vtkOpenGLVertexArrayObject::Bind on first paint). Must be set
|
||||
// before QApplication is constructed.
|
||||
QSurfaceFormat::setDefaultFormat(QVTKRenderWidget::defaultFormat());
|
||||
#endif
|
||||
QApplication app(argc, argv);
|
||||
|
||||
rtabmap::CameraViewer cameraViewer;
|
||||
|
||||
Reference in New Issue
Block a user