40 using namespace OVR::Util::Render;
51 : UpTan(src.UpTan), DownTan(src.DownTan), LeftTan(src.LeftTan), RightTan(src.RightTan)
68 return tanEyeAngle * eyeToSourceNDC.
Scale + eyeToSourceNDC.
Offset;
97 using namespace OVR::CAPI;
112 float orthoDistance,
float eyeViewAdjustX)
115 float orthoHorizontalOffset = eyeViewAdjustX / orthoDistance;
137 ortho.
M[0][0] = projection.
M[0][0] * orthoScale.
x;
138 ortho.
M[0][1] = 0.0f;
139 ortho.
M[0][2] = 0.0f;
140 ortho.
M[0][3] = -projection.
M[0][2] + ( orthoHorizontalOffset * projection.
M[0][0] );
142 ortho.
M[1][0] = 0.0f;
143 ortho.
M[1][1] = -projection.
M[1][1] * orthoScale.
y;
144 ortho.
M[1][2] = 0.0f;
145 ortho.
M[1][3] = -projection.
M[1][2];
165 ortho.
M[2][0] = 0.0f;
166 ortho.
M[2][1] = 0.0f;
168 ortho.
M[2][2] = 0.0f;
169 ortho.
M[2][3] = 0.0f;
173 ortho.
M[3][0] = 0.0f;
174 ortho.
M[3][1] = 0.0f;
175 ortho.
M[3][2] = 0.0f;
176 ortho.
M[3][3] = 1.0f;
192 double newTime = initialTime;
194 while(newTime < absTime)
196 for (
int j = 0; j < 50; j++)
202 return newTime - initialTime;
220 CAPI_SystemInitCalled = 1;
237 if (CAPI_SystemInitCalled)
240 CAPI_SystemInitCalled = 0;
314 return "LibOVR not initialized.";
318 return p->GetLastError();
362 return p->
StartSensor(supportedCaps, requiredCaps);
405 float pixelsPerDisplayPixel)
407 if (!hmd)
return Sizei(0);
420 unsigned int distortionCaps,
425 return ((
HMDState*)hmd)->ConfigureRendering(eyeRenderDescOut, eyeFovIn,
426 apiConfig, distortionCaps);
436 return ((
HMDState*)hmd)->TimeManager.SetVsync(vsync?
true :
false);
567 (
"ovrHmd_BeginFrameTiming called multiple times."));
664 memset(&erd, 0,
sizeof(erd));
673 #define OVR_OFFSET_OF(s, field) ((size_t)&((s*)0)->field)
681 unsigned int distortionCaps,
691 #if defined (OVR_OS_WIN32)
718 int triangleCount = 0;
722 &vertexCount, &triangleCount,
724 hmdri, distortion, eyeToSourceNDC);
764 renderViewport, textureSize );
766 uvScaleOffsetOut[0] = eyeToSourceUV.
Scale;
767 uvScaleOffsetOut[1] = eyeToSourceUV.
Offset;
828 float values[],
unsigned int arraySize)
842 float values[],
unsigned int arraySize)
854 const char* defaultVal)
859 return hmds->
getString(propertyName, defaultVal);
897 if (hmds && hmds->
pHMD)
OVR_EXPORT ovrBool ovrHmd_GetLatencyTestDrawColor(ovrHmd hmd, unsigned char rgbColorOut[3])
FrameTimeRecordSet GetLocklessState()
OVR_EXPORT ovrBool ovrHmd_CreateDistortionMesh(ovrHmd hmd, ovrEyeType eyeType, ovrFovPort fov, unsigned int distortionCaps, ovrDistortionMesh *meshData)
OVR_EXPORT ovrPosef ovrHmd_BeginEyeRender(ovrHmd hmd, ovrEyeType eye)
void GetLatencyTimings(float latencies[3])
double LastFrameTimeSeconds
OVR_EXPORT unsigned int ovrHmd_GetFloatArray(ovrHmd hmd, const char *propertyName, float values[], unsigned int arraySize)
OVR_EXPORT ovrBool ovrHmd_ConfigureRendering(ovrHmd hmd, const ovrRenderAPIConfig *apiConfig, unsigned int distortionCaps, const ovrFovPort eyeFovIn[2], ovrEyeRenderDesc eyeRenderDescOut[2])
#define OVR_ASSERT_LOG(c, args)
OVR_EXPORT ovrSizei ovrHmd_GetFovTextureSize(ovrHmd hmd, ovrEyeType eye, ovrFovPort fov, float pixelsPerDisplayPixel)
Timing GetFrameTiming(unsigned frameIndex)
const char * GetResultsString()
int GetNumValues(const char *key) const
OVR_EXPORT void ovrHmd_SetEnabledCaps(ovrHmd hmd, unsigned int capsBits)
struct ovrSensorState_ ovrSensorState
OVR_EXPORT const char * ovrHmd_GetLatencyTestResult(ovrHmd hmd)
OVR_EXPORT const char * ovrHmd_GetLastError(ovrHmd hmd)
static void OVR_CDECL Init(Log *log=Log::ConfigureDefaultLog(LogMask_Debug), Allocator *palloc=DefaultAllocator::InitSystemSingleton())
static void OVR_CDECL Destroy()
OVR_EXPORT void ovrHmd_GetDesc(ovrHmd hmd, ovrHmdDesc *desc)
ScaleAndOffset2D CreateUVScaleAndOffsetfromNDCScaleandOffset(ScaleAndOffset2D scaleAndOffsetNDC, Recti renderedViewport, Sizei renderTargetSize)
OVR_EXPORT ovrFrameTiming ovrHmd_GetFrameTiming(ovrHmd hmd, unsigned int frameIndex)
OVR_EXPORT ovrSensorState ovrHmd_GetSensorState(ovrHmd hmd, double absTime)
ThreadChecker RenderAPIThreadChecker
OVR::SensorFusion * ovrHmd_GetSensorFusion(ovrHmd hmd)
OVR_EXPORT void ovrHmd_ResetSensor(ovrHmd hmd)
OVR_EXPORT ovrEyeRenderDesc ovrHmd_GetRenderDesc(ovrHmd hmd, ovrEyeType eyeType, ovrFovPort fov)
OVR_EXPORT unsigned int ovrHmd_GetEnabledCaps(ovrHmd hmd)
OVR_EXPORT void ovrHmd_GetEyeTimewarpMatrices(ovrHmd hmd, ovrEyeType eye, ovrPosef renderPose, ovrMatrix4f twmOut[2])
const OVR::HMDInfo & HMDInfo
OVR_EXPORT void ovrHmd_Destroy(ovrHmd hmd)
OVR_EXPORT void ovrHmd_DestroyDistortionMesh(ovrDistortionMesh *meshData)
OVR_EXPORT ovrMatrix4f ovrMatrix4f_Projection(ovrFovPort fov, float znear, float zfar, ovrBool rightHanded)
HMDRenderState RenderState
OVR_EXPORT double ovr_GetTimeInSeconds()
void checkRenderingConfigured(const char *functionName)
Transformf GetEyePredictionPose(ovrHmd hmd, ovrEyeType eye)
DistortionRenderDesc Distortion[2]
OVR_EXPORT double ovr_WaitTillTime(double absTime)
OVR_EXPORT ovrHmd ovrHmd_Create(int index)
OVR_EXPORT ovrPosef ovrHmd_GetEyePose(ovrHmd hmd, ovrEyeType eye)
ovrDistortionVertex * pVertexData
OVR_EXPORT const char * ovrHmd_GetString(ovrHmd hmd, const char *propertyName, const char *defaultVal)
OVR_EXPORT void ovrHmd_GetRenderScaleAndOffset(ovrFovPort fov, ovrSizei textureSize, ovrRecti renderViewport, ovrVector2f uvScaleOffsetOut[2])
OVR_EXPORT ovrFrameTiming ovrHmd_BeginFrameTiming(ovrHmd hmd, unsigned int frameIndex)
OVR_EXPORT void ovr_Shutdown()
unsigned char LatencyTestDrawColor[3]
OVR_EXPORT ovrBool ovr_Initialize()
OVR_EXPORT ovrBool ovrHmd_SetFloatArray(ovrHmd hmd, const char *propertyName, float values[], unsigned int arraySize)
void checkBeginFrameTimingScope(const char *functionName)
unsigned getFloatArray(const char *propertyName, float values[], unsigned arraySize)
Vector2f TanAngleToRendertargetNDC(Vector2f const &tanEyeAngle)
unsigned char GetFrameLatencyTestDrawColor()
bool StartSensor(unsigned supportedCaps, unsigned requiredCaps)
bool setFloatArray(const char *propertyName, float values[], unsigned arraySize)
ThreadId BeginFrameThreadId
double TimewarpPointSeconds
OVR_EXPORT ovrBool ovrHmd_StartSensor(ovrHmd hmd, unsigned int supportedCaps, unsigned int requiredCaps)
double ScanoutMidpointSeconds
OVR_EXPORT int ovrHmd_Detect()
double LastGetFrameTimeSeconds
const char * GetLastError()
OVR_EXPORT void ovrHmd_EndFrameTiming(ovrHmd hmd)
OVR_EXPORT void ovrHmd_StopSensor(ovrHmd hmd)
Matrix4f CreateProjection(bool rightHanded, FovPort tanHalfFov, float zNear, float zFar)
static bool OVR_CDECL IsInitialized()
void SetEnabledHmdCaps(unsigned caps)
#define OVR_OFFSET_OF(s, field)
struct ovrFovPort_ ovrFovPort
OVR_EXPORT ovrFrameTiming ovrHmd_BeginFrame(ovrHmd hmd, unsigned int frameIndex)
void ovrHmd_SetVsync(ovrHmd hmd, ovrBool vsync)
const char * getString(const char *propertyName, const char *defaultVal)
ovrEyeRenderDesc calcRenderDesc(ovrEyeType eyeType, const ovrFovPort &fov)
OVR_EXPORT void ovrHmd_EndFrame(ovrHmd hmd)
OVR_EXPORT ovrBool ovrHmd_SetFloat(ovrHmd hmd, const char *propertyName, float value)
FovPort(float sideTan=0.0f)
void DistortionMeshCreate(DistortionMeshVertexData **ppVertices, UInt16 **ppTriangleListIndices, int *pNumVertices, int *pNumTriangles, const StereoEyeParams &stereoParams, const HmdRenderInfo &hmdRenderInfo)
void DistortionMeshDestroy(DistortionMeshVertexData *pVertices, UInt16 *pTriangleMeshIndices)
ovrPosef BeginEyeRender(ovrEyeType eye)
double BeginFrame(unsigned frameIndex)
ScaleAndOffset2D CreateNDCScaleAndOffsetFromFov(FovPort tanHalfFov)
void UpdateFrameLatencyTrackingAfterEndFrame(unsigned char frameLatencyTestColor, const Util::FrameTimeRecordSet &rs)
OVR_EXPORT void ovrHmd_EndEyeRender(ovrHmd hmd, ovrEyeType eye, ovrPosef renderPose, ovrTexture *eyeTexture)
Ptr< DistortionRenderer > pRenderer
void checkBeginFrameScope(const char *functionName)
Util::LatencyTest LatencyUtil
double EyeScanoutSeconds[2]
void ResetFrameTiming(unsigned frameIndex, bool dynamicPrediction, bool sdkRender)
HMDDevice * CreateDevice(int index)
__BEGIN_NAMESPACE_STD void void __END_NAMESPACE_STD void __BEGIN_NAMESPACE_STD void * memset(void *__s, int __c, size_t __n) __THROW __nonnull((1))
Util::LatencyTest2 LatencyUtil2
OVR_EXPORT void ovrHmd_ResetFrameTiming(ovrHmd hmd, unsigned int frameIndex)
OVR_EXPORT ovrHmd ovrHmd_CreateDebug(ovrHmdType type)
unsigned short * pIndexData
static double OVR_STDCALL GetSeconds()
void EndEyeRender(ovrEyeType eye, ovrPosef renderPose, ovrTexture *eyeTexture)
int char * index(const char *__s, int __c) __THROW __attribute_pure__ __nonnull((1))
FrameTimeManager TimeManager
static ovrBool CAPI_SystemInitCalled
ovrSizei GetFOVTextureSize(int eye, ovrFovPort fov, float pixelsPerDisplayPixel)
OVR_EXPORT unsigned int ovrHmd_GetArraySize(ovrHmd hmd, const char *propertyName)
OVR_EXPORT ovrMatrix4f ovrMatrix4f_OrthoSubProjection(ovrMatrix4f projection, ovrVector2f orthoScale, float orthoDistance, float eyeViewAdjustX)
OVR_EXPORT float ovrHmd_GetFloat(ovrHmd hmd, const char *propertyName, float defaultVal)
unsigned char LatencyTest2DrawColor[3]
bool BeginFrameTimingCalled
static GlobalState * pInstance
static Log * ConfigureDefaultLog(unsigned logMask=LogMask_Debug)
bool setFloatValue(const char *propertyName, float value)
ThreadId GetCurrentThreadId()
bool GetSensorDesc(ovrSensorDesc *descOut)
#define OVR_COMPILER_ASSERT(x)
OVR_EXPORT ovrBool ovrHmd_GetSensorDesc(ovrHmd hmd, ovrSensorDesc *descOut)
ovrSensorState PredictedSensorState(double absTime)
float getFloatValue(const char *propertyName, float defaultVal)
void GetTimewarpMatrices(ovrHmd hmd, ovrEyeType eye, ovrPosef renderPose, ovrMatrix4f twmOut[2])
OVR_EXPORT double ovrHmd_GetMeasuredLatencyTest2(ovrHmd hmd)
struct ovrPosef_ ovrPosef