I want to draw a polygon on the volumn data in freehand drawing. When mouse move, the volumn data and the ploygon render together, so the screen will stutter.
So I split the two data into two renders, when mosue move, only render the vtkRender with polygon. The method works, but the drawing result is wrong, I want the polygon without triangles.
m_pClipRender = vtkRenderer::New();
for (int i = 0; i < vecDisPts.size(); i++)
points1->InsertNextPoint(vecDisPts[i].GetX(), vecDisPts[i].GetY(), 0.0);
polys1->InsertNextCell(points1->GetNumberOfPoints() + 1);
for (int i = 0; i < points1->GetNumberOfPoints(); i++)
Also, you asked about “one vtkRenderWindow, two vtkRenderers”, maybe the following information is useful:
The color buffer and the depth buffer are owned by the window, not by the renderers. The renderers share the window’s color buffer and depth buffer. So when you render the polygon (in Layer 1), the rendered pixels stay in the buffer until the volume (in Layer 0) is re-rendered.
Thanks for your kindly reply!
At first, I hope the polygon is filled, but during the drawing process, the problem of concave polygons and self-intersecting polygons can occur, which can lead to repeated drawing.Like this:
Maybe after rendering the volume, you want to save the color buffer (the image in the window), and then re-use that image instead of re-rendering the volume every time? That would fix the stutter. But I don’t know a good way to do that with VTK.