mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-17 20:52:36 +01:00
Added HMD recenter support. Updated examples to support HMD.
This commit is contained in:
@@ -190,13 +190,39 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
||||
bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Loading textures.");
|
||||
bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs);
|
||||
|
||||
float at[3] = { 0.0f, 0.0f, 0.0f };
|
||||
float at[3] = { 0.0f, 0.0f, 0.0f };
|
||||
float eye[3] = { 0.0f, 0.0f, -7.0f };
|
||||
|
||||
float view[16];
|
||||
float proj[16];
|
||||
bx::mtxLookAt(view, eye, at);
|
||||
bx::mtxProj(proj, 60.0f, float(width)/float(height), 0.1f, 100.0f);
|
||||
// Set view and projection matrix for view 0.
|
||||
const bgfx::HMD* hmd = bgfx::getHMD();
|
||||
if (NULL != hmd)
|
||||
{
|
||||
float view[16];
|
||||
bx::mtxQuatTranslationHMD(view, hmd->eye[0].rotation, eye);
|
||||
|
||||
float proj[16];
|
||||
bx::mtxProj(proj, hmd->eye[0].fov, 0.1f, 100.0f);
|
||||
|
||||
bgfx::setViewTransform(0, view, proj);
|
||||
|
||||
// Set view 0 default viewport.
|
||||
//
|
||||
// Use HMD's width/height since HMD's internal frame buffer size
|
||||
// might be much larger than window size.
|
||||
bgfx::setViewRect(0, 0, 0, hmd->width, hmd->height);
|
||||
}
|
||||
else
|
||||
{
|
||||
float view[16];
|
||||
bx::mtxLookAt(view, eye, at);
|
||||
|
||||
float proj[16];
|
||||
bx::mtxProj(proj, 60.0f, float(width)/float(height), 0.1f, 100.0f);
|
||||
bgfx::setViewTransform(0, view, proj);
|
||||
|
||||
// Set view 0 default viewport.
|
||||
bgfx::setViewRect(0, 0, 0, width, height);
|
||||
}
|
||||
|
||||
float lightPosRadius[4][4];
|
||||
for (uint32_t ii = 0; ii < numLights; ++ii)
|
||||
@@ -219,9 +245,6 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
||||
|
||||
bgfx::setUniform(u_lightRgbInnerR, lightRgbInnerR, numLights);
|
||||
|
||||
// Set view and projection matrix for view 0.
|
||||
bgfx::setViewTransform(0, view, proj);
|
||||
|
||||
const uint16_t instanceStride = 64;
|
||||
const uint16_t numInstances = 3;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user