Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • VTK VTK
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 738
    • Issues 738
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 202
    • Merge requests 202
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • VTK
  • VTKVTK
  • Issues
  • #18006

Closed
Open
Created Sep 13, 2020 by B3nni@hopfer.benjamin

"Error in cache state" from vtkOpenGLState for vtkWorldPointPicker in QVTKOpenGLNativeWidget

Description

Using vtkWorldPointPicker inside QVTKOpenGLNativeWidget worked fine until vtk 8.2.0.

In vtk 9.0.1 it warns about an invalid vtkOpenGLState (details at the bottom) (In Debug only, otherwise warnings are disabled)

System: Win10, VS 2019, QT (both 5.14.2 and 5.15.0), vtk 9.0.1

Example

(Basically a combination of the following two examples:

  • https://vtk.org/Wiki/VTK/Examples/Cxx/Qt/RenderWindowNoUiFile
  • https://vtk.org/Wiki/VTK/Examples/Cxx/Interaction/WorldPointPicker )

After startup you have to click into the window to trigger the point picking and the warning.

#include <QApplication>

#include <vtkActor.h>
#include <vtkInteractorStyleTrackballCamera.h>
#include <vtkPolyDataMapper.h>
#include <vtkObjectFactory.h>
#include <vtkRendererCollection.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkSmartPointer.h>
#include <vtkSphereSource.h>

#include <vtkCellPicker.h>
#include <vtkPointPicker.h>
#include <vtkPropPicker.h>
#include <vtkWorldPointPicker.h>

#include <QVTKOpenGLNativeWidget.h>


class MouseInteractorStyle : public vtkInteractorStyleTrackballCamera
{
public:
  static MouseInteractorStyle *New();
  vtkTypeMacro(MouseInteractorStyle, vtkInteractorStyleTrackballCamera);

  virtual void OnLeftButtonDown()
  {
    std::cout << "Picking pixel: " << this->Interactor->GetEventPosition()[0] << " " << this->Interactor->GetEventPosition()[1] << std::endl;
    this->Interactor->GetPicker()->Pick(this->Interactor->GetEventPosition()[0],
                                        this->Interactor->GetEventPosition()[1],
                                        0,  // always zero.
                                        this->Interactor->GetRenderWindow()->GetRenderers()->GetFirstRenderer());
    double picked[3];
    this->Interactor->GetPicker()->GetPickPosition(picked);
    std::cout << "Picked value: " << picked[0] << " " << picked[1] << " " << picked[2] << std::endl;
    // Forward events
    vtkInteractorStyleTrackballCamera::OnLeftButtonDown();
  }

};
vtkStandardNewMacro(MouseInteractorStyle);

int main(int argc, char **argv)
{
  QApplication app(argc, argv);

  QVTKOpenGLNativeWidget widget;
  widget.resize(256, 256);

  auto renderer = vtkSmartPointer<vtkRenderer>::New();
  widget.renderWindow()->AddRenderer(renderer);

  auto sphereSource = vtkSmartPointer<vtkSphereSource>::New();
  auto sphereMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
  sphereMapper->SetInputConnection(sphereSource->GetOutputPort());
  auto sphereActor = vtkSmartPointer<vtkActor>::New();
  sphereActor->SetMapper(sphereMapper);
  renderer->AddActor(sphereActor);

  auto style = vtkSmartPointer<MouseInteractorStyle>::New();
  widget.interactor()->SetInteractorStyle(style);

  // Works:
  //widget.interactor()->SetPicker(vtkSmartPointer<vtkCellPicker>::New());

  // Works:
  //widget.interactor()->SetPicker(vtkSmartPointer<vtkPointPicker>::New());

  // Works:
  //widget.interactor()->SetPicker(vtkSmartPointer<vtkPropPicker>::New());

  // OpenGl cache state warning on point picking:
  widget.interactor()->SetPicker(vtkSmartPointer<vtkWorldPointPicker>::New());

  widget.show();
  app.exec();
  return EXIT_SUCCESS;
}

Warning / Stacktrace

2020-09-13 15:01:42.980 (   2.313s) [                ]     vtkOpenGLState.cxx:203   WARN| Error in cache state for GL_READ_FRAMEBUFFER_BINDING
2020-09-13 15:01:43.524 (   2.857s) [                ]     vtkOpenGLState.cxx:265   WARN| at stack loc
 at vtksys::SystemInformationImplementation::GetProgramStack in C:\_cpplibs\debug\vtk\v9.0.1\Utilities\KWSys\vtksys\SystemInformation.cxx line 3947
 at vtksys::SystemInformation::GetProgramStack in C:\_cpplibs\debug\vtk\v9.0.1\Utilities\KWSys\vtksys\SystemInformation.cxx line 871
 at vtkOpenGLState::CheckState in C:\_cpplibs\debug\vtk\v9.0.1\Rendering\OpenGL2\vtkOpenGLState.cxx line 264
 at vtkOpenGLState::vtkBindFramebuffer in C:\_cpplibs\debug\vtk\v9.0.1\Rendering\OpenGL2\vtkOpenGLState.cxx line 481
 at `anonymous namespace'::FrameBufferHelper::FrameBufferHelper in C:\_cpplibs\debug\vtk\v9.0.1\Rendering\OpenGL2\vtkOpenGLRenderWindow.cxx line 97
 at vtkOpenGLRenderWindow::GetZbufferData in C:\_cpplibs\debug\vtk\v9.0.1\Rendering\OpenGL2\vtkOpenGLRenderWindow.cxx line 1616
 at vtkOpenGLRenderWindow::GetZbufferData in C:\_cpplibs\debug\vtk\v9.0.1\Rendering\OpenGL2\vtkOpenGLRenderWindow.cxx line 1692
 at vtkRenderer::GetZ in C:\_cpplibs\debug\vtk\v9.0.1\Rendering\Core\vtkRenderer.cxx line 1346
 at vtkWorldPointPicker::Pick in C:\_cpplibs\debug\vtk\v9.0.1\Rendering\Core\vtkWorldPointPicker.cxx line 47
 at MouseInteractorStyle::OnLeftButtonDown in D:\axiocomp\utils\qtvtkpickingtest\src\main.cxx line 41
...
Edited Sep 13, 2020 by B3nni
Assignee
Assign to
Time tracking