diff options
Diffstat (limited to '3rdparty/bgfx/examples')
-rw-r--r-- | 3rdparty/bgfx/examples/00-helloworld/helloworld.cpp | 191 | ||||
-rw-r--r-- | 3rdparty/bgfx/examples/01-cubes/cubes.cpp | 6 | ||||
-rw-r--r-- | 3rdparty/bgfx/examples/02-metaballs/metaballs.cpp | 6 | ||||
-rw-r--r-- | 3rdparty/bgfx/examples/03-raymarch/raymarch.cpp | 16 | ||||
-rw-r--r-- | 3rdparty/bgfx/examples/04-mesh/mesh.cpp | 6 | ||||
-rw-r--r-- | 3rdparty/bgfx/examples/05-instancing/instancing.cpp | 6 | ||||
-rw-r--r-- | 3rdparty/bgfx/examples/06-bump/bump.cpp | 6 | ||||
-rw-r--r-- | 3rdparty/bgfx/examples/09-hdr/hdr.cpp | 23 | ||||
-rw-r--r-- | 3rdparty/bgfx/examples/12-lod/lod.cpp | 6 | ||||
-rw-r--r-- | 3rdparty/bgfx/examples/14-shadowvolumes/shadowvolumes.cpp | 19 | ||||
-rw-r--r-- | 3rdparty/bgfx/examples/21-deferred/deferred.cpp | 10 | ||||
-rw-r--r-- | 3rdparty/bgfx/examples/21-deferred/fs_deferred_light.sc | 2 | ||||
-rw-r--r-- | 3rdparty/bgfx/examples/24-nbody/nbody.cpp | 6 | ||||
-rw-r--r-- | 3rdparty/bgfx/examples/26-occlusion/occlusion.cpp | 7 | ||||
-rw-r--r-- | 3rdparty/bgfx/examples/27-terrain/terrain.cpp | 7 |
15 files changed, 46 insertions, 271 deletions
diff --git a/3rdparty/bgfx/examples/00-helloworld/helloworld.cpp b/3rdparty/bgfx/examples/00-helloworld/helloworld.cpp index e2e8a599a15..92996ae0314 100644 --- a/3rdparty/bgfx/examples/00-helloworld/helloworld.cpp +++ b/3rdparty/bgfx/examples/00-helloworld/helloworld.cpp @@ -7,7 +7,6 @@ #include "common.h" #include "bgfx_utils.h" #include "logo.h" -#include "imgui/imgui.h" class ExampleHelloWorld : public entry::AppI { @@ -29,111 +28,23 @@ class ExampleHelloWorld : public entry::AppI // Set view 0 clear state. bgfx::setViewClear(0 , BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH - , 0x000000ff + , 0x303030ff , 1.0f , 0 ); - imguiCreate(); - ImGui::GetIO().FontGlobalScale = 1.5; } virtual int shutdown() BX_OVERRIDE { - // Cleanup. - imguiDestroy(); - // Shutdown bgfx. bgfx::shutdown(); return 0; } - void displayMainMenu() - { - if (ImGui::BeginMainMenuBar()) - { - if (ImGui::BeginMenu("Left")) - { - if (ImGui::MenuItem("Brief", "CTRL+1")) {} - if (ImGui::MenuItem("Medium", "CTRL+2")) {} - if (ImGui::MenuItem("Two columns", "CTRL+3")) {} - if (ImGui::MenuItem("Full (name)", "CTRL+4")) {} - if (ImGui::MenuItem("Full (size, time)", "CTRL+5")) {} - if (ImGui::MenuItem("Full (access)", "CTRL+6")) {} - ImGui::Separator(); - if (ImGui::BeginMenu("Sort mode")) - { - ImGui::MenuItem("Name"); - ImGui::MenuItem("Extension"); - ImGui::MenuItem("Modif. Time"); - ImGui::MenuItem("Size"); - ImGui::MenuItem("Unsorted"); - ImGui::EndMenu(); - } - if (ImGui::MenuItem("Change source")) {} - ImGui::EndMenu(); - } - if (ImGui::BeginMenu("Files")) - { - if (ImGui::MenuItem("User menu", "F2")) {} - if (ImGui::MenuItem("View", "F3")) {} - if (ImGui::MenuItem("Edit", "F4")) {} - if (ImGui::MenuItem("Copy", "F5")) {} - if (ImGui::MenuItem("Rename or move", "F6")) {} - if (ImGui::MenuItem("Make directory", "F7")) {} - if (ImGui::MenuItem("Delete", "F8")) {} - ImGui::Separator(); - if (ImGui::MenuItem("File attributes", "CTRL+A")) {} - if (ImGui::MenuItem("Apply command", "CTRL+G")) {} - ImGui::Separator(); - if (ImGui::MenuItem("Select group")) {} - if (ImGui::MenuItem("Unselect group")) {} - if (ImGui::MenuItem("Invert selection")) {} - ImGui::EndMenu(); - } - if (ImGui::BeginMenu("Commands")) - { - if (ImGui::MenuItem("Find file", "ALT+F7")) {} - if (ImGui::MenuItem("History", "ALT+F8")) {} - if (ImGui::MenuItem("Maximize window", "ALT+F9")) {} - ImGui::Separator(); - if (ImGui::MenuItem("Panel on/off", "CTRL+O")) {} - if (ImGui::MenuItem("Equal panels", "CTRL+=")) {} - ImGui::EndMenu(); - } - if (ImGui::BeginMenu("Options")) - { - if (ImGui::MenuItem("Settings")) {} - ImGui::EndMenu(); - } - if (ImGui::BeginMenu("Right")) - { - if (ImGui::MenuItem("Brief", "CTRL+1")) {} - if (ImGui::MenuItem("Medium", "CTRL+2")) {} - if (ImGui::MenuItem("Two columns", "CTRL+3")) {} - if (ImGui::MenuItem("Full (name)", "CTRL+4")) {} - if (ImGui::MenuItem("Full (size, time)", "CTRL+5")) {} - if (ImGui::MenuItem("Full (access)", "CTRL+6")) {} - ImGui::Separator(); - if (ImGui::BeginMenu("Sort mode")) - { - ImGui::MenuItem("Name"); - ImGui::MenuItem("Extension"); - ImGui::MenuItem("Modif. Time"); - ImGui::MenuItem("Size"); - ImGui::MenuItem("Unsorted"); - ImGui::EndMenu(); - } - if (ImGui::MenuItem("Change source")) {} - ImGui::EndMenu(); - } - ImGui::EndMainMenuBar(); - } - } - bool update() BX_OVERRIDE { - if (!entry::processEvents(m_width, m_height, m_debug, m_reset, &m_mouseState) ) + if (!entry::processEvents(m_width, m_height, m_debug, m_reset) ) { // Set view 0 default viewport. bgfx::setViewRect(0, 0, 0, m_width, m_height); @@ -142,91 +53,18 @@ class ExampleHelloWorld : public entry::AppI // if no other draw calls are submitted to view 0. bgfx::touch(0); - imguiBeginFrame(m_mouseState.m_mx - , m_mouseState.m_my - , (m_mouseState.m_buttons[entry::MouseButton::Left] ? IMGUI_MBUT_LEFT : 0) - | (m_mouseState.m_buttons[entry::MouseButton::Right] ? IMGUI_MBUT_RIGHT : 0) - , m_mouseState.m_mz - , m_width - , m_height - ); - displayMainMenu(); - ImGui::SetNextWindowPos(ImVec2(0, 32)); - ImGui::SetNextWindowSize(ImVec2(m_width/2, m_height - 32)); - if (ImGui::Begin("Window1", nullptr, ImVec2(m_width/2, m_height-32), 1.0f, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar)) - { - ImGui::PushStyleVar(ImGuiStyleVar_ChildWindowRounding, 5.0f); - ImGui::BeginChild("Sub1", ImVec2(0, m_height - 48), true); - - - ImGui::Columns(4, "mycolumns"); - ImGui::Separator(); - ImGui::Text("ID"); ImGui::NextColumn(); - ImGui::Text("Name"); ImGui::NextColumn(); - ImGui::Text("Path"); ImGui::NextColumn(); - ImGui::Text("Flags"); ImGui::NextColumn(); - ImGui::Separator(); - const char* names[3] = { "One", "Two", "Three" }; - const char* paths[3] = { "/path/one", "/path/two", "/path/three" }; - static int selected = -1; - for (int i = 0; i < 50; i++) - { - char label[32]; - sprintf(label, "%04d", i); - if (ImGui::Selectable(label, selected == i, ImGuiSelectableFlags_SpanAllColumns)) - selected = i; - ImGui::NextColumn(); - ImGui::Text(names[i%3]); ImGui::NextColumn(); - ImGui::Text(paths[i % 3]); ImGui::NextColumn(); - ImGui::Text("...."); ImGui::NextColumn(); - } - ImGui::Columns(1); - ImGui::Separator(); - - - - ImGui::EndChild(); - ImGui::PopStyleVar(); - } - ImGui::End(); - ImGui::SameLine(); - ImGui::SetNextWindowPos(ImVec2(m_width / 2, 32)); - ImGui::SetNextWindowSize(ImVec2(m_width / 2, m_height - 32)); - if (ImGui::Begin("Window2", nullptr, ImVec2(m_width/2, m_height - 32), 1.0f, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar)) - { - ImGui::PushStyleVar(ImGuiStyleVar_ChildWindowRounding, 5.0f); - ImGui::BeginChild("Sub2", ImVec2(0, m_height - 48), true); - - ImGui::Columns(4, "mycolumns"); - ImGui::Separator(); - ImGui::Text("ID"); ImGui::NextColumn(); - ImGui::Text("Name"); ImGui::NextColumn(); - ImGui::Text("Path"); ImGui::NextColumn(); - ImGui::Text("Flags"); ImGui::NextColumn(); - ImGui::Separator(); - const char* names[3] = { "One", "Two", "Three" }; - const char* paths[3] = { "/path/one", "/path/two", "/path/three" }; - static int selected = -1; - for (int i = 0; i < 3; i++) - { - char label[32]; - sprintf(label, "%04d", i); - if (ImGui::Selectable(label, selected == i, ImGuiSelectableFlags_SpanAllColumns)) - selected = i; - ImGui::NextColumn(); - ImGui::Text(names[i]); ImGui::NextColumn(); - ImGui::Text(paths[i]); ImGui::NextColumn(); - ImGui::Text("...."); ImGui::NextColumn(); - } - ImGui::Columns(1); - ImGui::Separator(); - - - ImGui::EndChild(); - ImGui::PopStyleVar(); - } - ImGui::End(); - imguiEndFrame(); + // Use debug font to print information about this example. + bgfx::dbgTextClear(); + bgfx::dbgTextImage(bx::uint16_max(m_width /2/8, 20)-20 + , bx::uint16_max(m_height/2/16, 6)-6 + , 40 + , 12 + , s_logo + , 160 + ); + bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/00-helloworld"); + bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Initialization and debug text."); + // Advance to next frame. Rendering thread will be kicked to // process submitted rendering primitives. bgfx::frame(); @@ -241,7 +79,6 @@ class ExampleHelloWorld : public entry::AppI uint32_t m_height; uint32_t m_debug; uint32_t m_reset; - entry::MouseState m_mouseState; }; ENTRY_IMPLEMENT_MAIN(ExampleHelloWorld); diff --git a/3rdparty/bgfx/examples/01-cubes/cubes.cpp b/3rdparty/bgfx/examples/01-cubes/cubes.cpp index bf88eb3f7f0..97cf605294c 100644 --- a/3rdparty/bgfx/examples/01-cubes/cubes.cpp +++ b/3rdparty/bgfx/examples/01-cubes/cubes.cpp @@ -143,11 +143,7 @@ class ExampleCubes : public entry::AppI { 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); + bgfx::setViewTransform(0, view, hmd->eye[0].projection); // Set view 0 default viewport. // diff --git a/3rdparty/bgfx/examples/02-metaballs/metaballs.cpp b/3rdparty/bgfx/examples/02-metaballs/metaballs.cpp index bedf55497eb..f0f20e39cc9 100644 --- a/3rdparty/bgfx/examples/02-metaballs/metaballs.cpp +++ b/3rdparty/bgfx/examples/02-metaballs/metaballs.cpp @@ -577,11 +577,7 @@ class ExampleMetaballs : public entry::AppI { 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); + bgfx::setViewTransform(0, view, hmd->eye[0].projection); // Set view 0 default viewport. // diff --git a/3rdparty/bgfx/examples/03-raymarch/raymarch.cpp b/3rdparty/bgfx/examples/03-raymarch/raymarch.cpp index 60a4664546e..0e4a84c3dc9 100644 --- a/3rdparty/bgfx/examples/03-raymarch/raymarch.cpp +++ b/3rdparty/bgfx/examples/03-raymarch/raymarch.cpp @@ -107,7 +107,7 @@ class ExampleRaymarch : public entry::AppI void init(int _argc, char** _argv) BX_OVERRIDE { Args args(_argc, _argv); - + m_width = 1280; m_height = 720; m_debug = BGFX_DEBUG_TEXT; @@ -127,18 +127,8 @@ class ExampleRaymarch : public entry::AppI , 0 ); - // Setup root path for binary shaders. Shader binaries are different - // for each renderer. - switch (bgfx::getRendererType() ) - { - default: - break; - - case bgfx::RendererType::OpenGL: - case bgfx::RendererType::OpenGLES: - s_oglNdc = true; - break; - } + const bgfx::Caps* caps = bgfx::getCaps(); + s_oglNdc = caps->homogeneousDepth; // Create vertex stream declaration. PosColorTexCoord0Vertex::init(); diff --git a/3rdparty/bgfx/examples/04-mesh/mesh.cpp b/3rdparty/bgfx/examples/04-mesh/mesh.cpp index bfe61df6a3f..f7f8b7e96ce 100644 --- a/3rdparty/bgfx/examples/04-mesh/mesh.cpp +++ b/3rdparty/bgfx/examples/04-mesh/mesh.cpp @@ -91,11 +91,7 @@ class ExampleMesh : public entry::AppI { 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); + bgfx::setViewTransform(0, view, hmd->eye[0].projection); // Set view 0 default viewport. // diff --git a/3rdparty/bgfx/examples/05-instancing/instancing.cpp b/3rdparty/bgfx/examples/05-instancing/instancing.cpp index 6e854b20785..1a0f0b69cd8 100644 --- a/3rdparty/bgfx/examples/05-instancing/instancing.cpp +++ b/3rdparty/bgfx/examples/05-instancing/instancing.cpp @@ -160,11 +160,7 @@ class ExampleInstancing : public entry::AppI { 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); + bgfx::setViewTransform(0, view, hmd->eye[0].projection); // Set view 0 default viewport. // diff --git a/3rdparty/bgfx/examples/06-bump/bump.cpp b/3rdparty/bgfx/examples/06-bump/bump.cpp index bc5f9e74b7e..da6cff3d78e 100644 --- a/3rdparty/bgfx/examples/06-bump/bump.cpp +++ b/3rdparty/bgfx/examples/06-bump/bump.cpp @@ -225,11 +225,7 @@ class ExampleBump : public entry::AppI { 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); + bgfx::setViewTransform(0, view, hmd->eye[0].projection); // Set view 0 default viewport. // diff --git a/3rdparty/bgfx/examples/09-hdr/hdr.cpp b/3rdparty/bgfx/examples/09-hdr/hdr.cpp index bee42aed2bf..dfe6f7dd390 100644 --- a/3rdparty/bgfx/examples/09-hdr/hdr.cpp +++ b/3rdparty/bgfx/examples/09-hdr/hdr.cpp @@ -8,7 +8,6 @@ #include "imgui/imgui.h" static float s_texelHalf = 0.0f; -static bool s_originBottomLeft = false; struct PosColorTexCoord0Vertex { @@ -230,9 +229,8 @@ class ExampleHDR : public entry::AppI // Imgui. imguiCreate(); - const bgfx::RendererType::Enum renderer = bgfx::getRendererType(); - s_texelHalf = bgfx::RendererType::Direct3D9 == renderer ? 0.5f : 0.0f; - s_originBottomLeft = bgfx::RendererType::OpenGL == renderer || bgfx::RendererType::OpenGLES == renderer; + m_caps = bgfx::getCaps(); + s_texelHalf = bgfx::RendererType::Direct3D9 == m_caps->rendererType ? 0.5f : 0.0f; m_oldWidth = 0; m_oldHeight = 0; @@ -441,35 +439,35 @@ class ExampleHDR : public entry::AppI setOffsets2x2Lum(u_offset, 128, 128); bgfx::setTexture(0, s_texColor, m_fbtextures[0]); bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE); - screenSpaceQuad(128.0f, 128.0f, s_originBottomLeft); + screenSpaceQuad(128.0f, 128.0f, m_caps->originBottomLeft); bgfx::submit(2, m_lumProgram); // Downscale luminance 0. setOffsets4x4Lum(u_offset, 128, 128); bgfx::setTexture(0, s_texColor, m_lum[0]); bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE); - screenSpaceQuad(64.0f, 64.0f, s_originBottomLeft); + screenSpaceQuad(64.0f, 64.0f, m_caps->originBottomLeft); bgfx::submit(3, m_lumAvgProgram); // Downscale luminance 1. setOffsets4x4Lum(u_offset, 64, 64); bgfx::setTexture(0, s_texColor, m_lum[1]); bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE); - screenSpaceQuad(16.0f, 16.0f, s_originBottomLeft); + screenSpaceQuad(16.0f, 16.0f, m_caps->originBottomLeft); bgfx::submit(4, m_lumAvgProgram); // Downscale luminance 2. setOffsets4x4Lum(u_offset, 16, 16); bgfx::setTexture(0, s_texColor, m_lum[2]); bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE); - screenSpaceQuad(4.0f, 4.0f, s_originBottomLeft); + screenSpaceQuad(4.0f, 4.0f, m_caps->originBottomLeft); bgfx::submit(5, m_lumAvgProgram); // Downscale luminance 3. setOffsets4x4Lum(u_offset, 4, 4); bgfx::setTexture(0, s_texColor, m_lum[3]); bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE); - screenSpaceQuad(1.0f, 1.0f, s_originBottomLeft); + screenSpaceQuad(1.0f, 1.0f, m_caps->originBottomLeft); bgfx::submit(6, m_lumAvgProgram); float tonemap[4] = { m_middleGray, square(m_white), m_threshold, m_time }; @@ -480,13 +478,13 @@ class ExampleHDR : public entry::AppI bgfx::setTexture(0, s_texColor, m_fbtextures[0]); bgfx::setTexture(1, s_texLum, m_lum[4]); bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE); - screenSpaceQuad( (float)m_width/2.0f, (float)m_height/2.0f, s_originBottomLeft); + screenSpaceQuad( (float)m_width/2.0f, (float)m_height/2.0f, m_caps->originBottomLeft); bgfx::submit(7, m_brightProgram); // m_blur m_bright pass vertically. bgfx::setTexture(0, s_texColor, m_bright); bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE); - screenSpaceQuad( (float)m_width/8.0f, (float)m_height/8.0f, s_originBottomLeft); + screenSpaceQuad( (float)m_width/8.0f, (float)m_height/8.0f, m_caps->originBottomLeft); bgfx::submit(8, m_blurProgram); // m_blur m_bright pass horizontally, do tonemaping and combine. @@ -494,7 +492,7 @@ class ExampleHDR : public entry::AppI bgfx::setTexture(1, s_texLum, m_lum[4]); bgfx::setTexture(2, s_texBlur, m_blur); bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE); - screenSpaceQuad( (float)m_width, (float)m_height, s_originBottomLeft); + screenSpaceQuad( (float)m_width, (float)m_height, m_caps->originBottomLeft); bgfx::submit(9, m_tonemapProgram); if (bgfx::isValid(m_rb) ) @@ -558,6 +556,7 @@ class ExampleHDR : public entry::AppI int32_t m_scrollArea; + const bgfx::Caps* m_caps; float m_time; }; diff --git a/3rdparty/bgfx/examples/12-lod/lod.cpp b/3rdparty/bgfx/examples/12-lod/lod.cpp index ef37d254c11..c66db5a24dc 100644 --- a/3rdparty/bgfx/examples/12-lod/lod.cpp +++ b/3rdparty/bgfx/examples/12-lod/lod.cpp @@ -174,11 +174,7 @@ class ExampleLod : public entry::AppI { 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); + bgfx::setViewTransform(0, view, hmd->eye[0].projection); // Set view 0 default viewport. // diff --git a/3rdparty/bgfx/examples/14-shadowvolumes/shadowvolumes.cpp b/3rdparty/bgfx/examples/14-shadowvolumes/shadowvolumes.cpp index fbdc8804b02..093b168d42f 100644 --- a/3rdparty/bgfx/examples/14-shadowvolumes/shadowvolumes.cpp +++ b/3rdparty/bgfx/examples/14-shadowvolumes/shadowvolumes.cpp @@ -1866,22 +1866,9 @@ int _main_(int _argc, char** _argv) // Enable debug text. bgfx::setDebug(debug); - // Setup root path for binary shaders. Shader binaries are different - // for each renderer. - switch (bgfx::getRendererType() ) - { - case bgfx::RendererType::Direct3D9: - s_texelHalf = 0.5f; - break; - - case bgfx::RendererType::OpenGL: - case bgfx::RendererType::OpenGLES: - s_oglNdc = true; - break; - - default: - break; - } + const bgfx::Caps* caps = bgfx::getCaps(); + s_oglNdc = caps->homogeneousDepth; + s_texelHalf = bgfx::RendererType::Direct3D9 == caps->rendererType ? 0.5f : 0.0f; // Imgui imguiCreate(); diff --git a/3rdparty/bgfx/examples/21-deferred/deferred.cpp b/3rdparty/bgfx/examples/21-deferred/deferred.cpp index 2f8fb5d3816..fbf5c546022 100644 --- a/3rdparty/bgfx/examples/21-deferred/deferred.cpp +++ b/3rdparty/bgfx/examples/21-deferred/deferred.cpp @@ -16,7 +16,6 @@ #define RENDER_PASS_DEBUG_GBUFFER_ID 4 static float s_texelHalf = 0.0f; -static bool s_originBottomLeft = false; struct PosNormalTangentTexcoordVertex { @@ -218,7 +217,7 @@ class ExampleDeferred : public entry::AppI void init(int _argc, char** _argv) BX_OVERRIDE { Args args(_argc, _argv); - + m_width = 1280; m_height = 720; m_debug = BGFX_DEBUG_TEXT; @@ -311,7 +310,6 @@ class ExampleDeferred : public entry::AppI m_timeOffset = bx::getHPCounter(); const bgfx::RendererType::Enum renderer = bgfx::getRendererType(); s_texelHalf = bgfx::RendererType::Direct3D9 == renderer ? 0.5f : 0.0f; - s_originBottomLeft = bgfx::RendererType::OpenGL == renderer || bgfx::RendererType::OpenGLES == renderer; // Get renderer capabilities info. m_caps = bgfx::getCaps(); @@ -501,7 +499,7 @@ class ExampleDeferred : public entry::AppI bgfx::setViewFrameBuffer(RENDER_PASS_LIGHT_ID, m_lightBuffer); float proj[16]; - bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f, s_originBottomLeft); + bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f, m_caps->homogeneousDepth); bgfx::setViewFrameBuffer(RENDER_PASS_GEOMETRY_ID, m_gbuffer); bgfx::setViewTransform(RENDER_PASS_GEOMETRY_ID, view, proj); @@ -695,7 +693,7 @@ class ExampleDeferred : public entry::AppI | BGFX_STATE_ALPHA_WRITE | BGFX_STATE_BLEND_ADD ); - screenSpaceQuad( (float)m_width, (float)m_height, s_texelHalf, s_originBottomLeft); + screenSpaceQuad( (float)m_width, (float)m_height, s_texelHalf, m_caps->originBottomLeft); bgfx::submit(RENDER_PASS_LIGHT_ID, m_lightProgram); } } @@ -707,7 +705,7 @@ class ExampleDeferred : public entry::AppI | BGFX_STATE_RGB_WRITE | BGFX_STATE_ALPHA_WRITE ); - screenSpaceQuad( (float)m_width, (float)m_height, s_texelHalf, s_originBottomLeft); + screenSpaceQuad( (float)m_width, (float)m_height, s_texelHalf, m_caps->originBottomLeft); bgfx::submit(RENDER_PASS_COMBINE_ID, m_combineProgram); if (m_showGBuffer) diff --git a/3rdparty/bgfx/examples/21-deferred/fs_deferred_light.sc b/3rdparty/bgfx/examples/21-deferred/fs_deferred_light.sc index 378f1eded71..81f9ad25984 100644 --- a/3rdparty/bgfx/examples/21-deferred/fs_deferred_light.sc +++ b/3rdparty/bgfx/examples/21-deferred/fs_deferred_light.sc @@ -72,7 +72,7 @@ vec3 clipToWorld(mat4 _invViewProj, vec3 _clipPos) void main() { vec3 normal = decodeNormalUint(texture2D(s_normal, v_texcoord0).xyz); - float deviceDepth = texture2D(s_depth, v_texcoord0).x; + float deviceDepth = texture2D(s_depth, v_texcoord0).x; float depth = toClipSpaceDepth(deviceDepth); vec3 clip = vec3(v_texcoord0 * 2.0 - 1.0, depth); diff --git a/3rdparty/bgfx/examples/24-nbody/nbody.cpp b/3rdparty/bgfx/examples/24-nbody/nbody.cpp index 79f722f962e..f04766a5823 100644 --- a/3rdparty/bgfx/examples/24-nbody/nbody.cpp +++ b/3rdparty/bgfx/examples/24-nbody/nbody.cpp @@ -305,11 +305,7 @@ int _main_(int _argc, char** _argv) 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, tmp, proj); + bgfx::setViewTransform(0, tmp, hmd->eye[0].projection); // Set view 0 default viewport. // diff --git a/3rdparty/bgfx/examples/26-occlusion/occlusion.cpp b/3rdparty/bgfx/examples/26-occlusion/occlusion.cpp index 81e00f0c5fe..8f03686ede1 100644 --- a/3rdparty/bgfx/examples/26-occlusion/occlusion.cpp +++ b/3rdparty/bgfx/examples/26-occlusion/occlusion.cpp @@ -181,13 +181,10 @@ class ExampleOcclusion : public entry::AppI 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, tmp, proj); + bgfx::setViewTransform(0, tmp, hmd->eye[0].projection); bgfx::setViewRect(0, 0, 0, hmd->width, hmd->height); - bgfx::setViewTransform(1, tmp, proj); + bgfx::setViewTransform(1, tmp, hmd->eye[1].projection); bgfx::setViewRect(1, 0, 0, hmd->width, hmd->height); } else diff --git a/3rdparty/bgfx/examples/27-terrain/terrain.cpp b/3rdparty/bgfx/examples/27-terrain/terrain.cpp index 74d88ac350d..0f50be2d4b3 100644 --- a/3rdparty/bgfx/examples/27-terrain/terrain.cpp +++ b/3rdparty/bgfx/examples/27-terrain/terrain.cpp @@ -12,8 +12,6 @@ #include <bx/debug.h> #include <bx/fpumath.h> -static float s_texelHalf = 0.0f; -static bool s_originBottomLeft = false; static uint32_t s_terrainSize = 256; struct PosTexCoord0Vertex @@ -94,9 +92,6 @@ class ExampleTerrain : public entry::AppI imguiCreate(); m_timeOffset = bx::getHPCounter(); - const bgfx::RendererType::Enum renderer = bgfx::getRendererType(); - s_texelHalf = bgfx::RendererType::Direct3D9 == renderer ? 0.5f : 0.0f; - s_originBottomLeft = bgfx::RendererType::OpenGL == renderer || bgfx::RendererType::OpenGLES == renderer; m_vbh.idx = bgfx::invalidHandle; m_ibh.idx = bgfx::invalidHandle; @@ -463,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, s_originBottomLeft); + bx::mtxProj(m_projMtx, 60.0f, float(m_width) / float(m_height), 0.1f, 2000.0f); bgfx::setViewTransform(0, m_viewMtx, m_projMtx); bgfx::setTransform(m_terrain.m_transform); |