[vtkusers] Two vtkRenderer in one vtkRenderWindow

Tobias Erne tme at thermoanalytics.com
Thu Jan 23 12:51:29 EST 2003


Hello everybody,

I'm trying to use two vtkRenderer in one vtkRenderWindow.
I would like to have the second vtkRenderer in the upper left corner.
My problem is, that everything works fine under Linux Red Hat 7.3 but under
Windows 2000 I get only black screen.

Can anyone help me?

Thanks in advance.

Here is my example code.

void main( int argc, char *argv[] )
{
  // create a rendering window and two renderer
  vtkRenderer *ren = vtkRenderer::New();

  vtkRenderer *ren1 = vtkRenderer::New();
  ren1->SetViewport( 0,0.8,0.2,1);

  vtkRenderWindow *renWindow = vtkRenderWindow::New();
  renWindow->AddRenderer(ren);
  renWindow->AddRenderer(ren1);
  renWindow->SetSize( 600, 600 );

  ren->SetBackground(1,1,1);
  ren1->SetBackground(0,0,0);

  // create an actor and give it cone geometry
  vtkCubeSource *cube = vtkCubeSource::New();
  cube->SetBounds(10.0,15.0,10.0,20.0,10.0,20.0);
  vtkPolyDataMapper *cubeMapper = vtkPolyDataMapper::New();
  cubeMapper->SetInput(cube->GetOutput());
  vtkActor *cubeActor = vtkActor::New();
  cubeActor->SetMapper(cubeMapper);
  cubeActor->RotateY(-20.0);

  vtkProperty *prop = vtkProperty::New();
  prop = cubeActor->GetProperty();
  prop->SetColor( 1,0,1);

  ren->AddActor(cubeActor);

  // Interaction
  vtkRenderWindowInteractor *inter = vtkRenderWindowInteractor::New();
  vtkInteractorStyleSwitch* joy = vtkInteractorStyleSwitch::New();
  inter->SetInteractorStyle(joy);

  inter->SetRenderWindow(renWindow);
  inter->Initialize();

  // draw the resulting scene
  renWindow->Render();
  inter->Start();

  // Clean up
  ren->Delete();
  renWindow->Delete();
  cube->Delete();
  cubeMapper->Delete();
  cubeActor->Delete();
  inter->Delete();
}

-Tobi

-------------------------------------------------------



More information about the vtkusers mailing list