From d96225a1f014f8b982bc40fae72611d2ff748e69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Wed, 22 Feb 2017 22:26:39 -0800 Subject: [PATCH] Fixing projection matrix in examples. --- examples/07-callback/callback.cpp | 2 +- examples/08-update/update.cpp | 2 +- examples/09-hdr/hdr.cpp | 2 +- examples/10-font/font.cpp | 4 ++-- examples/11-fontsdf/fontsdf.cpp | 2 +- examples/12-lod/lod.cpp | 2 +- examples/15-shadowmaps-simple/shadowmaps_simple.cpp | 2 +- examples/16-shadowmaps/shadowmaps.cpp | 2 +- examples/18-ibl/ibl.cpp | 2 +- examples/22-windows/windows.cpp | 2 +- examples/23-vectordisplay/main.cpp | 2 +- examples/24-nbody/nbody.cpp | 2 +- examples/26-occlusion/occlusion.cpp | 2 +- examples/27-terrain/terrain.cpp | 2 +- examples/28-wireframe/wireframe.cpp | 2 +- examples/29-debugdraw/debugdraw.cpp | 4 ++-- examples/30-picking/picking.cpp | 4 ++-- examples/31-rsm/reflectiveshadowmap.cpp | 2 +- examples/32-particles/particles.cpp | 2 +- examples/common/imgui/imgui.cpp | 2 +- 20 files changed, 23 insertions(+), 23 deletions(-) diff --git a/examples/07-callback/callback.cpp b/examples/07-callback/callback.cpp index 9b2305e81..1789f0cb6 100644 --- a/examples/07-callback/callback.cpp +++ b/examples/07-callback/callback.cpp @@ -403,7 +403,7 @@ int _main_(int _argc, char** _argv) float view[16]; float proj[16]; bx::mtxLookAt(view, eye, at); - bx::mtxProj(proj, 60.0f, float(width)/float(height), 0.1f, 100.0f); + bx::mtxProj(proj, 60.0f, float(width)/float(height), 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth); // Set view and projection matrix for view 0. bgfx::setViewTransform(0, view, proj); diff --git a/examples/08-update/update.cpp b/examples/08-update/update.cpp index 6d72c647f..a2e154c23 100644 --- a/examples/08-update/update.cpp +++ b/examples/08-update/update.cpp @@ -452,7 +452,7 @@ public: float view[16]; float proj[16]; bx::mtxLookAt(view, eye, at); - bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f); + bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth); // Set view and projection matrix for view 0. bgfx::setViewTransform(0, view, proj); diff --git a/examples/09-hdr/hdr.cpp b/examples/09-hdr/hdr.cpp index ba940c886..b67367330 100644 --- a/examples/09-hdr/hdr.cpp +++ b/examples/09-hdr/hdr.cpp @@ -437,7 +437,7 @@ class ExampleHDR : public entry::AppI float view[16]; bx::mtxLookAt(view, temp, at); - bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f); + bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth); // Set view and projection matrix for view hdrMesh. bgfx::setViewTransform(hdrMesh, view, proj); diff --git a/examples/10-font/font.cpp b/examples/10-font/font.cpp index c0f49d8ae..c7baf0078 100644 --- a/examples/10-font/font.cpp +++ b/examples/10-font/font.cpp @@ -215,7 +215,7 @@ int _main_(int _argc, char** _argv) if (NULL != hmd && 0 != (hmd->flags & BGFX_HMD_RENDERING) ) { float proj[16]; - bx::mtxProj(proj, hmd->eye[0].fov, 0.1f, 100.0f); + bx::mtxProj(proj, hmd->eye[0].fov, 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth); static float time = 0.0f; time += 0.05f; @@ -234,7 +234,7 @@ int _main_(int _argc, char** _argv) else { float ortho[16]; - bx::mtxOrtho(ortho, centering, width + centering, height + centering, centering, -1.0f, 1.0f); + bx::mtxOrtho(ortho, centering, width + centering, height + centering, centering, -1.0f, 1.0f, bgfx::getCaps()->homogeneousDepth); bgfx::setViewTransform(0, view, ortho); bgfx::setViewRect(0, 0, 0, uint16_t(width), uint16_t(height) ); } diff --git a/examples/11-fontsdf/fontsdf.cpp b/examples/11-fontsdf/fontsdf.cpp index 0f7a4d78e..d40f0315c 100644 --- a/examples/11-fontsdf/fontsdf.cpp +++ b/examples/11-fontsdf/fontsdf.cpp @@ -173,7 +173,7 @@ int _main_(int _argc, char** _argv) if (NULL != hmd && 0 != (hmd->flags & BGFX_HMD_RENDERING) ) { float proj[16]; - bx::mtxProj(proj, hmd->eye[0].fov, 0.1f, 100.0f); + bx::mtxProj(proj, hmd->eye[0].fov, 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth); static float time = 0.0f; time += 0.05f; diff --git a/examples/12-lod/lod.cpp b/examples/12-lod/lod.cpp index ee1c38064..987d38b48 100644 --- a/examples/12-lod/lod.cpp +++ b/examples/12-lod/lod.cpp @@ -188,7 +188,7 @@ class ExampleLod : public entry::AppI bx::mtxLookAt(view, eye, at); float proj[16]; - bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f); + bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth); bgfx::setViewTransform(0, view, proj); // Set view 0 default viewport. diff --git a/examples/15-shadowmaps-simple/shadowmaps_simple.cpp b/examples/15-shadowmaps-simple/shadowmaps_simple.cpp index 1f8732a6f..56a8b1153 100644 --- a/examples/15-shadowmaps-simple/shadowmaps_simple.cpp +++ b/examples/15-shadowmaps-simple/shadowmaps_simple.cpp @@ -200,7 +200,7 @@ int _main_(int _argc, char** _argv) bx::mtxLookAt(view, eye, at); const float aspect = float(int32_t(width) ) / float(int32_t(height) ); - bx::mtxProj(proj, 60.0f, aspect, 0.1f, 1000.0f, flipV); + bx::mtxProj(proj, 60.0f, aspect, 0.1f, 1000.0f, bgfx::getCaps()->homogeneousDepth); // Time acumulators. float timeAccumulatorLight = 0.0f; diff --git a/examples/16-shadowmaps/shadowmaps.cpp b/examples/16-shadowmaps/shadowmaps.cpp index 1b2494c0e..191a3426d 100644 --- a/examples/16-shadowmaps/shadowmaps.cpp +++ b/examples/16-shadowmaps/shadowmaps.cpp @@ -1958,7 +1958,7 @@ int _main_(int _argc, char** _argv) const float camFar = 2000.0f; const float projHeight = 1.0f/bx::ftan(bx::toRad(camFovy)*0.5f); const float projWidth = projHeight * camAspect; - bx::mtxProj(viewState.m_proj, camFovy, camAspect, camNear, camFar); + bx::mtxProj(viewState.m_proj, camFovy, camAspect, camNear, camFar, bgfx::getCaps()->homogeneousDepth); cameraGetViewMtx(viewState.m_view); float timeAccumulatorLight = 0.0f; diff --git a/examples/18-ibl/ibl.cpp b/examples/18-ibl/ibl.cpp index 0dd96beb7..1608da739 100644 --- a/examples/18-ibl/ibl.cpp +++ b/examples/18-ibl/ibl.cpp @@ -728,7 +728,7 @@ int _main_(int _argc, char** _argv) // View Transform 1. camera.mtxLookAt(view); - bx::mtxProj(proj, 45.0f, float(width)/float(height), 0.1f, 100.0f); + bx::mtxProj(proj, 45.0f, float(width)/float(height), 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth); bgfx::setViewTransform(1, view, proj); // View rect. diff --git a/examples/22-windows/windows.cpp b/examples/22-windows/windows.cpp index 0399b7edf..6bede26b6 100644 --- a/examples/22-windows/windows.cpp +++ b/examples/22-windows/windows.cpp @@ -204,7 +204,7 @@ public: bx::mtxLookAt(view, eye, at); float proj[16]; - bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f); + bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth); bgfx::setViewTransform(0, view, proj); bgfx::setViewRect(0, 0, 0, m_width, m_height); diff --git a/examples/23-vectordisplay/main.cpp b/examples/23-vectordisplay/main.cpp index 0dfa572b2..f1dcd00d9 100644 --- a/examples/23-vectordisplay/main.cpp +++ b/examples/23-vectordisplay/main.cpp @@ -77,7 +77,7 @@ int _main_(int _argc, char** _argv) float view[16]; float proj[16]; bx::mtxLookAt(view, eye, at); - bx::mtxProj(proj, 60.0f, float(width) / float(height), 0.1f, 100.0f); + bx::mtxProj(proj, 60.0f, float(width) / float(height), 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth); // Set view and projection matrix for view 0. bgfx::setViewTransform(0, view, proj); diff --git a/examples/24-nbody/nbody.cpp b/examples/24-nbody/nbody.cpp index 636d8f525..51e4d2cc5 100644 --- a/examples/24-nbody/nbody.cpp +++ b/examples/24-nbody/nbody.cpp @@ -316,7 +316,7 @@ int _main_(int _argc, char** _argv) else { float proj[16]; - bx::mtxProj(proj, 90.0f, float(width)/float(height), 0.1f, 10000.0f); + bx::mtxProj(proj, 90.0f, float(width)/float(height), 0.1f, 10000.0f, bgfx::getCaps()->homogeneousDepth); bgfx::setViewTransform(0, view, proj); // Set view 0 default viewport. diff --git a/examples/26-occlusion/occlusion.cpp b/examples/26-occlusion/occlusion.cpp index 8ae2b3e08..d3b355dd1 100644 --- a/examples/26-occlusion/occlusion.cpp +++ b/examples/26-occlusion/occlusion.cpp @@ -190,7 +190,7 @@ class ExampleOcclusion : public entry::AppI else { float proj[16]; - bx::mtxProj(proj, 90.0f, float(width)/float(height), 0.1f, 10000.0f); + bx::mtxProj(proj, 90.0f, float(width)/float(height), 0.1f, 10000.0f, bgfx::getCaps()->homogeneousDepth); bgfx::setViewTransform(0, view, proj); bgfx::setViewRect(0, 0, 0, width, height); diff --git a/examples/27-terrain/terrain.cpp b/examples/27-terrain/terrain.cpp index 1098ef5b2..72c443a5c 100644 --- a/examples/27-terrain/terrain.cpp +++ b/examples/27-terrain/terrain.cpp @@ -458,7 +458,7 @@ class ExampleTerrain : public entry::AppI bgfx::setViewRect(0, 0, 0, m_width, m_height); cameraGetViewMtx(m_viewMtx); - bx::mtxProj(m_projMtx, 60.0f, float(m_width) / float(m_height), 0.1f, 2000.0f); + bx::mtxProj(m_projMtx, 60.0f, float(m_width) / float(m_height), 0.1f, 2000.0f, bgfx::getCaps()->homogeneousDepth); bgfx::setViewTransform(0, m_viewMtx, m_projMtx); bgfx::setTransform(m_terrain.m_transform); diff --git a/examples/28-wireframe/wireframe.cpp b/examples/28-wireframe/wireframe.cpp index a4f798d11..03d01db0c 100644 --- a/examples/28-wireframe/wireframe.cpp +++ b/examples/28-wireframe/wireframe.cpp @@ -497,7 +497,7 @@ class ExampleWireframe : public entry::AppI m_camera.update(deltaTimeSec); bx::memCopy(m_uniforms.m_camPos, m_camera.m_pos.curr, 3*sizeof(float)); m_camera.mtxLookAt(view); - bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f); + bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth); bgfx::setViewTransform(0, view, proj); m_uniforms.m_drawEdges = (DrawMode::WireframeShaded == m_drawMode) ? 1.0f : 0.0f; diff --git a/examples/29-debugdraw/debugdraw.cpp b/examples/29-debugdraw/debugdraw.cpp index 1c82e0d52..7b8c22071 100644 --- a/examples/29-debugdraw/debugdraw.cpp +++ b/examples/29-debugdraw/debugdraw.cpp @@ -118,7 +118,7 @@ class DebugDrawApp : public entry::AppI } else { - bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f); + bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth); bgfx::setViewTransform(0, view, proj); bgfx::setViewRect(0, 0, 0, m_width, m_height); @@ -129,7 +129,7 @@ class DebugDrawApp : public entry::AppI float mvp[16]; float eye[] = { 5.0f, 10.0f, 5.0f }; bx::mtxLookAt(view, eye, zero); - bx::mtxProj(proj, 45.0f, float(m_width)/float(m_height), 1.0f, 15.0f); + bx::mtxProj(proj, 45.0f, float(m_width)/float(m_height), 1.0f, 15.0f, bgfx::getCaps()->homogeneousDepth); bx::mtxMul(mvp, view, proj); ddBegin(0); diff --git a/examples/30-picking/picking.cpp b/examples/30-picking/picking.cpp index a4fc99ffe..4419f3202 100644 --- a/examples/30-picking/picking.cpp +++ b/examples/30-picking/picking.cpp @@ -207,7 +207,7 @@ class ExamplePicking : public entry::AppI bx::mtxLookAt(view, eye, at); float proj[16]; - bx::mtxProj(proj, 60.0f, float(m_width) / float(m_height), 0.1f, 100.0f); + bx::mtxProj(proj, 60.0f, float(m_width) / float(m_height), 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth); // Set up view rect and transform for the shaded pass bgfx::setViewRect(RENDER_PASS_SHADING, 0, 0, uint16_t(m_width), uint16_t(m_height) ); @@ -238,7 +238,7 @@ class ExamplePicking : public entry::AppI // Tight FOV is best for picking float pickProj[16]; - bx::mtxProj(pickProj, m_fov, 1, 0.1f, 100.0f); + bx::mtxProj(pickProj, m_fov, 1, 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth); // View rect and transforms for picking pass bgfx::setViewRect(RENDER_PASS_ID, 0, 0, ID_DIM, ID_DIM); diff --git a/examples/31-rsm/reflectiveshadowmap.cpp b/examples/31-rsm/reflectiveshadowmap.cpp index 0ceb3d400..40117ffed 100644 --- a/examples/31-rsm/reflectiveshadowmap.cpp +++ b/examples/31-rsm/reflectiveshadowmap.cpp @@ -454,7 +454,7 @@ public: cameraGetViewMtx(view); float proj[16]; - bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f); + bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth); bgfx::setViewRect(RENDER_PASS_GBUFFER, 0, 0, uint16_t(m_width), uint16_t(m_height)); bgfx::setViewTransform(RENDER_PASS_GBUFFER, view, proj); diff --git a/examples/32-particles/particles.cpp b/examples/32-particles/particles.cpp index 47eaad1b8..4f7cc0bd1 100644 --- a/examples/32-particles/particles.cpp +++ b/examples/32-particles/particles.cpp @@ -329,7 +329,7 @@ class Particles : public entry::AppI } else { - bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f); + bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth); bgfx::setViewTransform(0, view, proj); bgfx::setViewRect(0, 0, 0, m_width, m_height); diff --git a/examples/common/imgui/imgui.cpp b/examples/common/imgui/imgui.cpp index 107ab5224..235a91489 100644 --- a/examples/common/imgui/imgui.cpp +++ b/examples/common/imgui/imgui.cpp @@ -812,7 +812,7 @@ struct Imgui m_surfaceWidth = _surfaceWidth / 2; float proj[16]; - bx::mtxProj(proj, hmd->eye[0].fov, 0.1f, 100.0f); + bx::mtxProj(proj, hmd->eye[0].fov, 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth); static float time = 0.0f; time += 0.05f;