[vtkusers] vtkCamera::SetPosition causes delayed rendering?

David Gobbi david.gobbi at gmail.com
Tue Jul 26 17:54:00 EDT 2011


Hi David,

You should never, ever call renderer->Render().  That method is only
meant to be called by the vtkRenderWindow.  The documentation says
so quite clearly.  By calling it you are probably causing some timestamps
to be set (indicating that all actors in the renderer have rendered), but you
aren't actually doing any rendering.  Then, when you call
renderWindow->Render() it sees that those timestamps have been updated
and thinks that there is nothing to be done.

Also it is a good idea to always set the ViewUp when setting the
Position and FocalPoint.  All three are needed in order to uniquely
define the view transform.

 - David





On Tue, Jul 26, 2011 at 3:32 PM, David Doria <daviddoria at gmail.com> wrote:
> I am trying to position the camera before the interaction starts. I tried
> this:
>
>   vtkSmartPointer<vtkRenderWindow> renderWindow =
>     vtkSmartPointer<vtkRenderWindow>::New();
>   renderWindow->AddRenderer(renderer);
>   renderer->AddActor(contourActor);
>   renderer->AddActor(vertsActor);
>
>   vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
>     vtkSmartPointer<vtkRenderWindowInteractor>::New();
>   renderWindowInteractor->SetRenderWindow(renderWindow);
>   renderer->Render(); // This seems to construct the camera
>   renderWindow->Render();
>
>   vtkCamera* camera = renderer->GetActiveCamera();
>   //camera->SetPosition(400, 100, 100);
>   camera->SetFocalPoint(200, 0, 0);
>   renderer->Render();
>
>   renderWindow->Render();
>   renderWindowInteractor->Start();
> If I uncomment the SetPosition call, then the render window is blank until I
> perform some interaction (it's not like the camera is not aimed at the
> scene, any tiny interaction and the scene is displayed properly.)
> Can anyone explain how to tell it to "ReallyRender()" since Render() doesn't
> seem to do the job?
> Thanks,
>
> David



More information about the vtkusers mailing list