Example #1
0
void DaydreamRenderer::SetCameraRig(jlong native_camera) {
    cameraRig_ = reinterpret_cast<gvr::CameraRig *>(native_camera);
    scratch_viewport_list_->SetToRecommendedBufferViewports();

    scratch_viewport_list_->GetBufferViewport(0, &scratch_viewport_);
    SetCameraProjectionMatrix((gvr::CustomCamera *) cameraRig_->left_camera(), scratch_viewport_
            .GetSourceFov(), kZNear, kZFar);

    scratch_viewport_list_->GetBufferViewport(1, &scratch_viewport_);
    SetCameraProjectionMatrix((gvr::CustomCamera *) cameraRig_->right_camera(), scratch_viewport_
            .GetSourceFov(), kZNear, kZFar);
}
Example #2
0
void InitWindowsSystem (osgViewer::Viewer& viewer, const char* const title, int x, int y, int width, int height)
{
	viewer.setUpViewInWindow(x, y, width, height);

	//Get the traits of the current window
	osg::ref_ptr< osg::GraphicsContext::Traits > traits = new osg::GraphicsContext::Traits( *viewer.getCamera()->getGraphicsContext()->getTraits());

	//Set the title
	traits->windowName = title;

	// disable vertical sync
	traits->vsync = false;

	//Create a new graphics context with the modified traits
	osg::ref_ptr< osg::GraphicsContext > gc = osg::GraphicsContext::createGraphicsContext( traits.get() );
	gc->realize();
	gc->makeCurrent();

	// set the vertical black off by default
	osgViewer::Viewer::Windows windows;
	viewer.getWindows(windows);
	for(osgViewer::Viewer::Windows::iterator itr = windows.begin(); itr != windows.end(); ++itr) {
		osgViewer::GraphicsWindow* const graphicsWindow = (*itr);
		graphicsWindow->setSyncToVBlank (false);
	}

	//Create the new camera which is a copy of the current camera in the viewer
	osg::ref_ptr<osg::Camera> cam = new osg::Camera( *viewer.getCamera() ); 

	//Set the cameras graphics context to the gc we made above
	cam->setGraphicsContext( gc );

	//assign the viewer the new camera
	viewer.setCamera( cam.get() );

	// int the camera default perspective matrix
	SetCameraProjectionMatrix (viewer, 60.0f, dFloat (width) / height, 0.01, 1000.0f);


	// set the file find callback
	osg::ref_ptr<DemosFindFileCallback> filecallback = new DemosFindFileCallback;
	osgDB::Registry::instance()->setFindFileCallback (filecallback.get());
}