Fixed example 24-nbody with OVR.

This commit is contained in:
Branimir Karadžić 2014-12-28 10:12:24 -08:00
parent 6e73d4ea34
commit 9d83a5307c
3 changed files with 15 additions and 10 deletions

View file

@ -249,7 +249,6 @@ int _main_(int /*_argc*/, char** /*_argv*/)
bx::swap(currPositionBuffer0, currPositionBuffer1);
bx::swap(prevPositionBuffer0, prevPositionBuffer1);
float eye[3] = { 0.0f, 0.0f, -35.0f };
float view[16];
// Update camera.
@ -260,13 +259,17 @@ int _main_(int /*_argc*/, char** /*_argv*/)
const bgfx::HMD* hmd = bgfx::getHMD();
if (NULL != hmd)
{
float view[16];
bx::mtxQuatTranslationHMD(view, hmd->eye[0].rotation, eye);
float viewHead[16];
float eye[3] = {};
bx::mtxQuatTranslationHMD(viewHead, hmd->eye[0].rotation, eye);
float tmp[16];
bx::mtxMul(tmp, view, viewHead);
float proj[16];
bx::mtxProj(proj, hmd->eye[0].fov, 0.1f, 10000.0f);
bgfx::setViewTransform(0, view, proj);
bgfx::setViewTransform(0, tmp, proj);
// Set view 0 default viewport.
//

View file

@ -35,11 +35,6 @@ namespace bgfx
bool OVR::postReset(void* _nwh, ovrRenderAPIConfig* _config, bool _debug)
{
if (!m_initialized)
{
return false;
}
if (_debug)
{
switch (_config->Header.API)
@ -92,6 +87,11 @@ namespace bgfx
return false;
}
if (!m_initialized)
{
return false;
}
if (!_debug)
{
m_hmd = ovrHmd_Create(0);

View file

@ -3249,6 +3249,8 @@ namespace bgfx
continue;
}
bool resetState = viewChanged || wasCompute;
if (wasCompute)
{
wasCompute = false;
@ -3269,7 +3271,7 @@ namespace bgfx
uint64_t changedStencil = currentState.m_stencil ^ draw.m_stencil;
currentState.m_stencil = newStencil;
if (viewChanged)
if (resetState)
{
currentState.clear();
currentState.m_scissor = !draw.m_scissor;