QVTKOpenGLWidget: Vertices disappear when RenderPointsAsSpheresON()

Hi everyone,

When using QVTKOpenGLWidget, the vertices cannot be rendered as spheres (they disappear) when I set “RenderPointsAsSpheresON()”, while they are properly rendered with vtkRenderWindow.

I want to obtain the same result as with “vtkRenderWindow” when using “vtkGenericOpenGLRenderWindow”.

Is there a workaround for this problem?
I’m using VTK 8.2.0 and Qt 5.12.3.

I appreciate any suggestions.

Thanks in advance and best regards.


OK: vtkRenderWindow

tube_and_sphere_vtk_OK

NG: vtkGenericOpenGLRenderWindow (Vertices disappears)

tube_and_sphere_qvtk_NG

Code example:

#include <vtkSmartPointer.h>
#include <vtkConeSource.h>
#include <vtkPolyDataMapper.h>
#include <vtkRenderWindow.h>
#include <vtkActor.h>
#include <vtkProperty.h>
#include <vtkRenderer.h>
#include <vtkGenericOpenGLRenderWindow.h>

#include <QVBoxLayout>
#include <QVTKOpenGLWidget.h>

#include "qvtk_tubes_spheres.h"
#include <qcoreapplication.h>

Widget::Widget(QWidget *parent) : QWidget(parent)
{
    qvtk = new QVTKOpenGLWidget(this);
    layout = new QVBoxLayout(this);
    layout->addWidget(qvtk);
    setLayout(layout);
    resize(300, 300);

    auto cone = vtkSmartPointer<vtkConeSource>::New();
    auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
    auto actor = vtkSmartPointer<vtkActor>::New();
    auto ren = vtkSmartPointer<vtkRenderer>::New();
    auto renwin = vtkSmartPointer<vtkGenericOpenGLRenderWindow>::New();

    mapper->SetInputConnection(cone->GetOutputPort());
    actor->SetMapper(mapper);

    ///////////////////////////////////////////////////////////////////
    // Rendering Tubes and Spheres in VTK
    // https://blog.kitware.com/rendering-tubes-and-spheres-in-vtk/

    actor->GetProperty()->SetEdgeVisibility(1);
    actor->GetProperty()->SetEdgeColor(0.9, 0.9, 0.4);
    actor->GetProperty()->SetLineWidth(6);
    actor->GetProperty()->SetPointSize(12);
    actor->GetProperty()->SetRenderLinesAsTubes(1);
    actor->GetProperty()->SetRenderPointsAsSpheres(1);
    actor->GetProperty()->SetVertexVisibility(1);
    actor->GetProperty()->SetVertexColor(0.5, 1.0, 0.8);
    ///////////////////////////////////////////////////////////////////
    
    ren->AddActor(actor);
    renwin->AddRenderer(ren);

#if VTK_MINOR_VERSION < 90
    qvtk->SetRenderWindow(renwin);
    qvtk->GetRenderWindow()->Render();
#else
    qvtk->setRenderWindow(renwin);
    qvtk->renderWindow()->Render();
#endif   
}

I encountered similar problems when using QVTKOpenGLNativeWidget, VTK9.0.3 and QT5.14.2 :upside_down_face: Expert for any solution.

// before initializing QApplication, set the default surface format.
QSurfaceFormat::setDefaultFormat(QVTKOpenGLNativeWidget::defaultFormat());
I do this, RenderPointsAsSpheresOn() is successful.