[vtkusers] TestDragon Oculus Rift test code

abenchaaben abenchaaben at histalim.com
Wed May 31 10:18:57 EDT 2017


Hi, 

I build vtk with the support of Oculus Rift. I'm trying to build the example
of  TestDragon.cxx.

#include "vtkCamera.h"
#include "vtkRenderer.h"
#include "vtkOpenGLRenderWindow.h"
#include "vtkActor.h"
#include "vtkPolyDataMapper.h"
#include "vtkPLYReader.h"
#include "vtkNew.h"
#include "vtkProperty.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkOpenGLRenderWindow.h"
#include "vtkCullerCollection.h"
#include "vtkLight.h"
#include "vtkOculusCamera.h"
#include "vtkOculusRenderer.h"
#include "vtkOculusRenderWindow.h"
#include "vtkOculusRenderWindowInteractor.h"

//----------------------------------------------------------------------------
int TestDragon(int argc, char *argv[])
{
  vtkNew<vtkActor> actor;
  vtkNew<vtkOculusRenderer> renderer;
  renderer->SetBackground(0.2, 0.3, 0.4);
  vtkNew<vtkOculusRenderWindow> renderWindow;
  renderWindow->AddRenderer(renderer.Get());
  renderer->AddActor(actor.Get());
  vtkNew<vtkOculusRenderWindowInteractor>  iren;
  iren->SetRenderWindow(renderWindow.Get());
  vtkNew<vtkOculusCamera> cam;
  renderer->SetActiveCamera(cam.Get());

  // crazy frame rate requirement
  // need to look into that at some point
  renderWindow->SetDesiredUpdateRate(350.0);
  iren->SetDesiredUpdateRate(350.0);
  iren->SetStillUpdateRate(350.0);

  renderer->RemoveCuller(renderer->GetCullers()->GetLastItem());

  vtkNew<vtkLight> light;
  light->SetLightTypeToSceneLight();
  light->SetPosition(0.0, 1.0, 0.3);
  renderer->AddLight(light.Get());

  const char* fileName =
    vtkTestUtilities::ExpandDataFileName(
      argc, argv, "Data/dragon.ply");
  vtkNew<vtkPLYReader> reader;
  reader->SetFileName(fileName);
  reader->Update();

  vtkNew<vtkPolyDataMapper> mapper;
  mapper->SetInputConnection(reader->GetOutputPort());
  actor->SetMapper(mapper.Get());
  actor->GetProperty()->SetAmbientColor(0.2, 0.2, 1.0);
  actor->GetProperty()->SetDiffuseColor(1.0, 0.65, 0.7);
  actor->GetProperty()->SetSpecularColor(1.0, 1.0, 1.0);
  actor->GetProperty()->SetSpecular(0.5);
  actor->GetProperty()->SetDiffuse(0.7);
  actor->GetProperty()->SetAmbient(0.5);
  actor->GetProperty()->SetSpecularPower(20.0);
  actor->GetProperty()->SetOpacity(1.0);
//  actor->GetProperty()->SetRepresentationToWireframe();

  renderer->ResetCamera();
  renderWindow->Render();

  int retVal = vtkRegressionTestImage( renderWindow.Get() );
  if ( retVal == vtkRegressionTester::DO_INTERACTOR)
    {
    iren->Start();
    }

  return EXIT_SUCCESS;
}



I have this error : #error:  gl.h included before glew.h.  I noticed that
this concern only the include of this headers :
-#include "vtkOculusRenderWindow.h"
-#include "vtkOculusRenderWindowInteractor.h"

Does that mean that i didn't build vtk with the righ opengl flags?




--
View this message in context: http://vtk.1045678.n5.nabble.com/TestDragon-Oculus-Rift-test-code-tp5743489.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list