[vtkusers] 3D monitors

Hal Canary hal at cs.unc.edu
Wed May 16 17:32:39 EDT 2012


On 05/16/2012 05:10 PM, Hal Canary wrote:
> On 05/16/2012 02:17 PM, Kishore Mosaliganti wrote:
> > Is there a "Hello World" program for stereo rendering available
> > somewhere? Do you guys mind sharing this code if you have it.
 >
> Here it is in Python:  [...]


And I've just translated it into C++, just to see if that worked too.

#include "vtkActor.h"
#include "vtkCamera.h"
#include "vtkCubeSource.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkDataSetMapper.h"
#include "vtkInteractorStyle.h"
#include "vtkInteractorStyleTrackballCamera.h"
int main(int argc, char** argv) {
   vtkCamera * camera = vtkCamera::New();
   camera->SetPosition(2.5, 2.0, 1.0);
   camera->SetFocalPoint(0.0, 0.0, 0.0);
   camera->SetViewUp(0.0, 1.0, 0.0);
   camera->SetViewAngle(30);
   vtkRenderer * renderer = vtkRenderer::New();
   renderer->SetActiveCamera(camera);
   vtkCubeSource * cubeSource = vtkCubeSource::New();
   vtkDataSetMapper * dataSetMapper = vtkDataSetMapper::New();
   dataSetMapper->SetInputConnection(cubeSource->GetOutputPort());
   vtkActor * actor = vtkActor::New();
   actor->SetMapper(dataSetMapper);
   renderer->AddActor(actor);
   vtkRenderWindow * renderWindow = vtkRenderWindow::New();
   renderWindow->FullScreenOn();
   renderWindow->StereoCapableWindowOn();
   renderWindow->SetStereoTypeToCrystalEyes();
   renderWindow->StereoRenderOn();
   renderWindow->AddRenderer(renderer);
   vtkRenderWindowInteractor * renderWindowInteractor
     = vtkRenderWindowInteractor::New();
   renderWindowInteractor->SetRenderWindow(renderWindow);
   vtkInteractorStyle * interactorStyle
     = vtkInteractorStyleTrackballCamera::New();
   renderWindowInteractor->SetInteractorStyle(interactorStyle);
   renderWindowInteractor->Initialize();
   renderWindow->Render();
   renderWindowInteractor->Start();
   return 0;
}


-- 
Hal Canary



More information about the vtkusers mailing list