mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 18:45:54 -05:00
Fixed example 24-nbody with OVR.
This commit is contained in:
parent
6e73d4ea34
commit
9d83a5307c
3 changed files with 15 additions and 10 deletions
|
@ -249,7 +249,6 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
||||||
bx::swap(currPositionBuffer0, currPositionBuffer1);
|
bx::swap(currPositionBuffer0, currPositionBuffer1);
|
||||||
bx::swap(prevPositionBuffer0, prevPositionBuffer1);
|
bx::swap(prevPositionBuffer0, prevPositionBuffer1);
|
||||||
|
|
||||||
float eye[3] = { 0.0f, 0.0f, -35.0f };
|
|
||||||
float view[16];
|
float view[16];
|
||||||
|
|
||||||
// Update camera.
|
// Update camera.
|
||||||
|
@ -260,13 +259,17 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
||||||
const bgfx::HMD* hmd = bgfx::getHMD();
|
const bgfx::HMD* hmd = bgfx::getHMD();
|
||||||
if (NULL != hmd)
|
if (NULL != hmd)
|
||||||
{
|
{
|
||||||
float view[16];
|
float viewHead[16];
|
||||||
bx::mtxQuatTranslationHMD(view, hmd->eye[0].rotation, eye);
|
float eye[3] = {};
|
||||||
|
bx::mtxQuatTranslationHMD(viewHead, hmd->eye[0].rotation, eye);
|
||||||
|
|
||||||
|
float tmp[16];
|
||||||
|
bx::mtxMul(tmp, view, viewHead);
|
||||||
|
|
||||||
float proj[16];
|
float proj[16];
|
||||||
bx::mtxProj(proj, hmd->eye[0].fov, 0.1f, 10000.0f);
|
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.
|
// Set view 0 default viewport.
|
||||||
//
|
//
|
||||||
|
|
10
src/ovr.cpp
10
src/ovr.cpp
|
@ -35,11 +35,6 @@ namespace bgfx
|
||||||
|
|
||||||
bool OVR::postReset(void* _nwh, ovrRenderAPIConfig* _config, bool _debug)
|
bool OVR::postReset(void* _nwh, ovrRenderAPIConfig* _config, bool _debug)
|
||||||
{
|
{
|
||||||
if (!m_initialized)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_debug)
|
if (_debug)
|
||||||
{
|
{
|
||||||
switch (_config->Header.API)
|
switch (_config->Header.API)
|
||||||
|
@ -92,6 +87,11 @@ namespace bgfx
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!m_initialized)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!_debug)
|
if (!_debug)
|
||||||
{
|
{
|
||||||
m_hmd = ovrHmd_Create(0);
|
m_hmd = ovrHmd_Create(0);
|
||||||
|
|
|
@ -3249,6 +3249,8 @@ namespace bgfx
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool resetState = viewChanged || wasCompute;
|
||||||
|
|
||||||
if (wasCompute)
|
if (wasCompute)
|
||||||
{
|
{
|
||||||
wasCompute = false;
|
wasCompute = false;
|
||||||
|
@ -3269,7 +3271,7 @@ namespace bgfx
|
||||||
uint64_t changedStencil = currentState.m_stencil ^ draw.m_stencil;
|
uint64_t changedStencil = currentState.m_stencil ^ draw.m_stencil;
|
||||||
currentState.m_stencil = newStencil;
|
currentState.m_stencil = newStencil;
|
||||||
|
|
||||||
if (viewChanged)
|
if (resetState)
|
||||||
{
|
{
|
||||||
currentState.clear();
|
currentState.clear();
|
||||||
currentState.m_scissor = !draw.m_scissor;
|
currentState.m_scissor = !draw.m_scissor;
|
||||||
|
|
Loading…
Reference in a new issue