//todor licence
#include <dali/public-api/math/quaternion.h>
-
-//#include <adaptors/common/tizen-vr-platform-header.h>
-
#include <stdint.h>
namespace Dali
namespace Vr
{
-struct VrEngineInitializeParams
+struct VrEngineEyePose
{
- // Screen settings
- int screenWidth;
- int screenHeight;
-
- // Eye settings
- uint32_t* frameBufferObjects; ///< 2 values
- uint32_t* colorTextures;
- uint32_t* depthTextures; ///< May be null
+ Quaternion rotation;
+ double timestamp;
};
-struct VrEngineEyePose
+struct VrEngineRenderTargetInfo
{
- Quaternion rotation;
- double timestamp;
+ int frameBufferObjects[2];
+ int colorTextures[2]; ///< if -1, then engine will create these buffers
+ int depthTextures[2];
};
-struct VrEngineRenderTargetInfo
+struct Eye
{
- int frameBufferObjects[2];
- int colorTextures[2]; ///< if -1, then engine will create these buffers
- int depthTextures[2];
+ enum Type
+ {
+ LEFT = 0,
+ RIGHT = 1
+ };
};
} // Vr
{
public:
- //todor move to vr-defaults?
- struct Eye
+ struct VrProperty
{
enum Type
{
- LEFT = 0,
- RIGHT = 1
+ ENABLED, ///< todor
+ EYE_BUFFER_COUNT, ///< (int) Number of buffers ( 1 buffer for both eyes )
+
+ // Render target by data structure
+ EYE_RENDER_TARGETS, ///< (VrEngineRenderTargetInfo*)
+ EYE_CURRENT_POSE, ///< (struct VrEngineEyePose)
+
+ // Framebuffers per eye getter properties
+ EYE_LEFT_TEXTURE_ID = 1000, ///< (int) Left eye texture id for buffer ( must be passed as EYE_LEFT_TEXTURE_ID + N )
+ EYE_RIGHT_TEXTURE_ID = 1065, ///< (int) Right eye texture id for buffer ( must be passed as EYE_RIGHT_TEXTURE_ID + N )
};
};
- struct VrProperty
+ /**
+ * @brief todor
+ */
+ struct EyeBufferInfo
{
- enum Type
+ struct EyeInfo
{
- ENABLED, ///< todor
-
- CURRENT_POSE_QUATERNION, // outputs float[4], rw
- EYE_BUFFER_COUNT, // int, number of buffers ( 1 buffer for both eyes ), rw
-
- // render target by data structure
- EYE_RENDER_TARGETS, // [VrEngineRenderTargetInfo*]
-
- EYE_BUFFER_WIDTH, // [int] width of single eye renderable area
- EYE_BUFFER_HEIGHT, // [int] height of single eye renderable area
-
- EYE_CURRENT_POSE, // [ structure VrEngineEyePose ]
-
- /**
- * Framebuffers per eye getter properties
- */
- EYE_LEFT_CURRENT_TEXTURE_ID, // [int] ro, texture id to be written to ( updated with frame index )
- EYE_LEFT_TEXTURE_ID = 1000, // [int] rw, left eye texture id for buffer ( must be passed as EYE_LEFT_TEXTURE_ID+N )
- // helper enums
- EYE_LEFT_TEXTURE0_ID = EYE_LEFT_TEXTURE_ID,
- EYE_LEFT_TEXTURE1_ID = EYE_LEFT_TEXTURE_ID+1,
- EYE_LEFT_TEXTURE2_ID = EYE_LEFT_TEXTURE_ID+2,
- EYE_LEFT_TEXTURE3_ID = EYE_LEFT_TEXTURE_ID+3,
-
- EYE_RIGHT_CURRENT_TEXTURE_ID, // [int] ro, texture id to be written to ( updated with frame index )
- EYE_RIGHT_TEXTURE_ID = 1065, // [int] rw, right eye texture id for buffer ( must be passed as EYE_RIGHT_TEXTURE_ID+N )
- // helper enums
- EYE_RIGHT_TEXTURE0_ID = EYE_RIGHT_TEXTURE_ID,
- EYE_RIGHT_TEXTURE1_ID = EYE_RIGHT_TEXTURE_ID+1,
- EYE_RIGHT_TEXTURE2_ID = EYE_RIGHT_TEXTURE_ID+2,
- EYE_RIGHT_TEXTURE3_ID = EYE_RIGHT_TEXTURE_ID+3,
-
- EYE_LEFT_CURRENT_FBO_ID = 1999,
- EYE_LEFT_FBO_ID = 2000, // [int] left eye fbo for buffer (EYE_LEFT_FBO_ID+N)
- EYE_RIGHT_CURRENT_FBO_ID = 2099,
- EYE_RIGHT_FBO_ID = 2100,// [int] right eye fbo for buffer (EYE_RIGHT_FBO_ID+N)
-
- EYE_LEFT_DEPTH_TEXTURE_ID = 3000, // [int] left eye depth texture for buffer (EYE_LEFT_FBO_ID+N)
- EYE_RIGHT_DEPTH_TEXTURE_ID = 3064,// [int] right eye depth texture for buffer (EYE_RIGHT_FBO_ID+N)
+ int frameBufferObject;
+ int texture;
};
+
+ EyeInfo eye[2];
+ int bufferWidth;
+ int bufferHeight;
};
//todor doxygen all below
{
}
- virtual bool Initialize( Vr::VrEngineInitializeParams* initializeParams ) = 0;
+ virtual bool Initialize( unsigned int screenWidth, unsigned int screenHeight ) = 0;
virtual void Start() = 0;
virtual void Stop() = 0;
virtual void PreRender() = 0;
virtual void PostRender() = 0;
virtual void SubmitFrame() = 0;
-
- // Client must perform output validation if necessary
- virtual bool Get( const int property, void* output, int count ) = 0;
- virtual bool Set( const int property, const void* input, int count ) = 0;
-
- // Helper functions
- bool Get( int property, void* output )
- {
- return Get( property, output, 1 );
- }
-
- bool Set( int property, void* input )
- {
- return Set( property, input, 1 );
- }
-
- inline bool Get( const int* properties, void** outputs, int count )
- {
- // Fill output array
- for( int i = 0; i < count; ++i )
- {
- Get( properties[i], outputs[i], 1 );
- }
- return true;
- }
-
- inline bool Set( const int* properties, const void** inputs, int count )
- {
- // Fill output array
- for( int i = 0; i < count; ++i )
- {
- return Set( properties[i], inputs[i], 1 );
- }
- return true;
- }
-
-private:
+ virtual bool Get( const int property, void* output ) = 0;
+ virtual void GetEyeBufferInfo( EyeBufferInfo& eyeBufferInfo ) = 0;
};
} // Dali
-#endif
+#endif // DALI_VR_ENGINE_H
#include <dali/integration-api/vr-defaults.h>
#include <stdio.h>
#include <stdlib.h>
-//todor
-#include <iostream>
namespace Dali
{
mEnabled( false ),
mEngineInitialized( false )
{
- std::cout << "todor: ##################################### VRMANAGER CTOR" << std::endl;
// We get the enabled state from the VR Engine in adaptor.
vrEngine->Get( Integration::VrEngine::VrProperty::ENABLED, &mEnabled );
}
if( mVrEngine->Get( Dali::Integration::VrEngine::VrProperty::EYE_CURRENT_POSE, &eyePose ) )
{
- //std::cout << "todor: VRMANAGER: UpdateHeadOrientation: Setting orientation: " << eyePose.rotation << std::endl;
mHeadNode->SetOrientation( eyePose.rotation );
}
else
{
- //std::cout << "todor: VRMANAGER: UpdateHeadOrientation: Setting orientation: DEFAULT" << std::endl;
mHeadNode->SetOrientation( Quaternion( 1.0f, 0.0f, 0.0f, 0.0f ) );
}
}
if( !mEngineInitialized )
{
// Initialise VR engine.
- Dali::Integration::Vr::VrEngineInitializeParams params;
- memset( ¶ms, 0, sizeof( Dali::Integration::Vr::VrEngineInitializeParams ) );
- params.screenWidth = surfaceWidth;
- params.screenHeight = surfaceHeight;
-
- mVrEngine->Initialize( ¶ms );
+ mVrEngine->Initialize( surfaceWidth, surfaceHeight );
mEngineInitialized = true;
// Start VR engine.
{
context.GetError();
- // This reads all the required VR information in one go.
- int leftFrameBufferObject( -1 );
- int rightFrameBufferObject( -1 );
- int leftTexture( -1 );
- int rightTexture( -1 );
- int bufferWidth( -1 );
- int bufferHeight( -1 );
-
- static const int properties[] =
- {
- Dali::Integration::VrEngine::VrProperty::EYE_LEFT_CURRENT_FBO_ID, Dali::Integration::VrEngine::VrProperty::EYE_RIGHT_CURRENT_FBO_ID,
- Dali::Integration::VrEngine::VrProperty::EYE_LEFT_CURRENT_TEXTURE_ID, Dali::Integration::VrEngine::VrProperty::EYE_RIGHT_CURRENT_TEXTURE_ID,
- Dali::Integration::VrEngine::VrProperty::EYE_BUFFER_WIDTH, Dali::Integration::VrEngine::VrProperty::EYE_BUFFER_HEIGHT
- };
-
- void* values[] =
- {
- &leftFrameBufferObject, &rightFrameBufferObject, &leftTexture, &rightTexture, &bufferWidth, &bufferHeight
- };
+ Dali::Integration::VrEngine::EyeBufferInfo eyeBufferInfo;
+ mVrEngine->GetEyeBufferInfo( eyeBufferInfo );
+ Dali::Integration::Vr::Eye::Type eye;
if( cameraType == Dali::Camera::VR_EYE_LEFT )
{
+ eye = Dali::Integration::Vr::Eye::LEFT;
vrEye = true;
- mVrEngine->Get( properties, values, 6 );
-
- context.BindFramebuffer( GL_FRAMEBUFFER, leftFrameBufferObject );
- context.Bind2dTexture( leftTexture );
- context.TexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, bufferWidth, bufferHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL );
}
else if( cameraType == Dali::Camera::VR_EYE_RIGHT )
{
+ eye = Dali::Integration::Vr::Eye::RIGHT;
vrEye = true;
- mVrEngine->Get( properties, values, 6 );
+ }
+
+ if( vrEye )
+ {
+ context.BindFramebuffer( GL_FRAMEBUFFER, eyeBufferInfo.eye[eye].frameBufferObject );
+ context.Bind2dTexture( eyeBufferInfo.eye[eye].texture );
- context.BindFramebuffer( GL_FRAMEBUFFER, rightFrameBufferObject);
- context.Bind2dTexture( rightTexture );
- context.TexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, bufferWidth, bufferHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL );
+ context.TexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, eyeBufferInfo.bufferWidth, eyeBufferInfo.bufferHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL );
}
}
}
}
-void VrManager::GetVrViewportDimensions( Rect<int>& viewportDimensions )
+void VrManager::GetVrViewportDimensions( Viewport& viewportDimensions )
{
viewportDimensions = mViewportDimensions;
}