Questions about using vtkOpenGLHardwareSelector

Hi,

We are using vtkOPenGLHardwareSelector as a base class for our own hardware cell picker. (While it seems like there are some hardware-accelerated prop pickers, we don’t see a hardware cell picker, so we wrote our own). In general, it works great but there is one big problem. If we don’t build a separate renderer for the picking and copy all of our props into it, it doesn’t always pick correctly and sometimes we get openGL state errors.

The basic process that we follow is this:

  • call BeginSelection()
  • call SetArea(…) with the area we want to pick
  • call SetFieldAssociation(vtkDataObject::FIELD_ASSOCIATION_CELLS);
  • call renderwindow->OffScreenRenderingOn();
  • call CaptureBuffers()
  • Process captured data
  • call ClearBuffers()
  • call renderwindow->OffScreenRenderingOff();
  • call EndSelection()

If we build a new renderer and add it to the render window and use it for this work, everything works great. If we use the existing renderer, it does not always pick correctly, sometimes objects disappear from the screen, sometimes the screen goes black. Definitely something in OpenGL seems not happy. Once it goes wrong, the display is never correct again.

We would rather use the same renderer that we are using to display things on the screen as it takes too much time to build the new renderer and this is occurring during user interaction. Does anyone have any idea why we need to create a new renderer for this to work correctly? Is there some way to reset the renderer after doing a capture?

I don’t think you can just turn off-screen rendering on and off.

If you send a link to your implementation, preferably along with a test that reproduces the issue, then maybe VTK developers can have a look at it.

Thank you Andras. I have narrowed down the problem a bit. It has something to do with using our class in combination with vtkRenderedAreaPicker, which also does hardware picking but uses the Select() method instead of CaptureBuffers. By switching to vtkAreaPicker for this other code, our problem disappears. It seems like something about the way we do things upsets the opengl state and once it’s broken the app never recovers.

We would like to contribute our HW CellPicker if we can get it to play nice with the rest of vtk. I will try to make a test containing the new class that duplicates the problem with vtkRenderedAreaPicker. It may take me a while…