namespace
{
+
#define GL(x) { x; int err = context.GetError(); if(err) { DALI_LOG_ERROR( "GL_ERROR: [%d] '%s', %x\n", __LINE__, #x, (unsigned)err);fflush(stderr);fflush(stdout);} else { /*DALI_LOG_ERROR("GL Call: %s\n", #x); fflush(stdout);*/} }
+
+// These dimensions must match those used by the Tizen VR engine.
+// TODO: Get these from the Tizen VR engine when such an API is implemented.
+const Rect<int> DEFAULT_VR_VIEWPORT_DIMENSIONS( 0, 0, 1024, 1024 );
+
} // Anonymous namespace
}
}
+void VrManager::GetVrViewportDimensions( Rect<int>& viewportDimensions )
+{
+ viewportDimensions = DEFAULT_VR_VIEWPORT_DIMENSIONS;
+}
+
} // Internal
public:
/**
- * @brief todor
+ * @brief Constructor.
+ * @param[in] vrEngine The VR engine abstraction object
*/
VrManager( Dali::Integration::VrEngine* vrEngine );
/**
- * @brief todor
+ * @brief Destructor.
*/
~VrManager();
*/
void SubmitFrame( Context& context );
+ /**
+ * @brief todor
+ */
+ void GetVrViewportDimensions( Rect<int>& viewportDimensions );
+
private:
Dali::Integration::VrEngine* mVrEngine; ///< todor
- SceneGraph::Node* mHeadNode;
- bool mEnabled;
- bool mEngineInitialized;
+ SceneGraph::Node* mHeadNode; ///< todor
+ bool mEnabled; ///< todor
+ bool mEngineInitialized; ///< todor
};
#include <cstdio>
#include <string.h>
-//TODOVR
-//#define DEBUG_DISABLE_BARREL_DISTORTION
-
using namespace Dali::Integration::Vr;
using Dali::Integration::VrEngine;
mImpl->context.GlContextCreated();
mImpl->programController.GlContextCreated();
-
// renderers, textures and gpu buffers cannot reinitialize themselves
// so they rely on someone reloading the data for them
}
if( !mImpl->firstRenderCompleted || mImpl->renderersAdded )
{
// This will perform pre-render steps with the Tizen VR Engine IF using Tizen VR.
- VrManager& vrManager = mImpl->vrManager;
- vrManager.PrepareRender( mImpl->defaultSurfaceRect.width, mImpl->defaultSurfaceRect.height );
+ mImpl->vrManager.PrepareRender( mImpl->defaultSurfaceRect.width, mImpl->defaultSurfaceRect.height );
- if( !vrManager.IsEnabled() )
+ if( !mImpl->vrManager.IsEnabled() )
{
// switch rendering to adaptor provided (default) buffer
GL( mImpl->context.BindFramebuffer( GL_FRAMEBUFFER, 0 ) );
}
// This will Submit frame to the Tizen VR Engine IF using Tizen VR.
- vrManager.SubmitFrame( mImpl->context );
+ mImpl->vrManager.SubmitFrame( mImpl->context );
}
//Notify RenderGeometries that rendering has finished
}
// switch rendering to adaptor provided (default) buffer
-
// Check whether a viewport is specified, otherwise the full surface size is used
if ( instruction.mIsViewportSet )
{
// For glViewport the lower-left corner is (0,0)
- // TODOVR: using 2 buffers, vieport Y starts with 0
- //const int y = 0;//( mImpl->defaultSurfaceRect.height - instruction.mViewport.height ) - instruction.mViewport.y;
- //viewportRect.Set( instruction.mViewport.x, y, instruction.mViewport.width, instruction.mViewport.height );
- viewportRect.Set( 0, 0, 1024, 1024 );
+ if( mImpl->vrManager.IsEnabled() )
+ {
+ // If using VR, get the dimensions from the VR manager.
+ mImpl->vrManager.GetVrViewportDimensions( viewportRect );
+ }
+ else
+ {
+ const int viewPortY = ( mImpl->defaultSurfaceRect.height - instruction.mViewport.height ) - instruction.mViewport.y;
+ viewportRect.Set( instruction.mViewport.x, viewPortY, instruction.mViewport.width, instruction.mViewport.height );
+ }
}
else
{