[vtkusers] Stereo rendering

Eric Wait ericwait at uwm.edu
Mon Sep 27 15:19:29 EDT 2010


I am trying to do a "Hello World" cone in stereoscopic 3D using VTK (C++)
with a GeForce GTX 460 graphics card, NVidia 3D vision glasses and an Asus
VG236 Monitor.

I have found fragments of code and have pieced them together but have not
had any success in rendering anything in stereo.  I am a newbie to VTK, so
any help would be greatly appreciated.

Here is what I have thus far:

 /*=========================================================================
  Program:   Visualization Toolkit
  Module:    $RCSfile: Cone.cxx,v $

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

MODIFIED by Eric Wait for Stereoscopic viewing
=========================================================================*/
#include "vtkConeSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkRenderWindow.h"
#include "vtkCamera.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
int main(){
  vtkConeSource *cone = vtkConeSource::New();
  cone->SetHeight( 3.0 );
  cone->SetRadius( 1.0 );
  cone->SetResolution( 100 );

  vtkPolyDataMapper *coneMapper = vtkPolyDataMapper::New();
  coneMapper->SetInputConnection( cone->GetOutputPort() );

  vtkActor *coneActor = vtkActor::New();
  coneActor->SetMapper( coneMapper );

  vtkRenderer *ren1= vtkRenderer::New();
  ren1->AddActor( coneActor );
  ren1->SetBackground( 0.1, 0.2, 0.4 );

  vtkRenderWindow *renWin = vtkRenderWindow::New();
  renWin->AddRenderer( ren1 );
  renWin->SetStereoTypeToCrystalEyes();
  renWin->SetStereoCapableWindowOn();
  renWin->SetStereoRender(1);

  renWin->SetFullScreen(1);

  //renWin->SetSize( 300, 300 );

  int i;
  for (i = 0; i < 1000; ++i){
    renWin->Render();
    ren1->GetActiveCamera()->Azimuth(1);
  }

  cone->Delete();
  coneMapper->Delete();
  coneActor->Delete();
  ren1->Delete();
  renWin->Delete();

  return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100927/eb665a54/attachment.htm>


More information about the vtkusers mailing list