diff options
Diffstat (limited to '3rdparty/bgfx/examples/12-lod/lod.cpp')
-rw-r--r-- | 3rdparty/bgfx/examples/12-lod/lod.cpp | 75 |
1 files changed, 40 insertions, 35 deletions
diff --git a/3rdparty/bgfx/examples/12-lod/lod.cpp b/3rdparty/bgfx/examples/12-lod/lod.cpp index 510565d0e2f..19ac984817e 100644 --- a/3rdparty/bgfx/examples/12-lod/lod.cpp +++ b/3rdparty/bgfx/examples/12-lod/lod.cpp @@ -9,6 +9,9 @@ #include <bx/readerwriter.h> +namespace +{ + struct KnightPos { int32_t m_x; @@ -25,13 +28,19 @@ static const KnightPos knightTour[8*4] = class ExampleLod : public entry::AppI { - void init(int _argc, char** _argv) BX_OVERRIDE +public: + ExampleLod(const char* _name, const char* _description) + : entry::AppI(_name, _description) + { + } + + void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) override { Args args(_argc, _argv); - m_width = 1280; - m_height = 720; - m_debug = BGFX_DEBUG_TEXT; + m_width = _width; + m_height = _height; + m_debug = BGFX_DEBUG_NONE; m_reset = BGFX_RESET_VSYNC; bgfx::init(args.m_type, args.m_pciId); @@ -90,7 +99,7 @@ class ExampleLod : public entry::AppI m_targetLod = 0; } - virtual int shutdown() BX_OVERRIDE + virtual int shutdown() override { imguiDestroy(); @@ -101,15 +110,15 @@ class ExampleLod : public entry::AppI } // Cleanup. - bgfx::destroyProgram(m_program); + bgfx::destroy(m_program); - bgfx::destroyUniform(s_texColor); - bgfx::destroyUniform(s_texStipple); - bgfx::destroyUniform(u_stipple); + bgfx::destroy(s_texColor); + bgfx::destroy(s_texStipple); + bgfx::destroy(u_stipple); - bgfx::destroyTexture(m_textureStipple); - bgfx::destroyTexture(m_textureLeafs); - bgfx::destroyTexture(m_textureBark); + bgfx::destroy(m_textureStipple); + bgfx::destroy(m_textureLeafs); + bgfx::destroy(m_textureBark); // Shutdown bgfx. bgfx::shutdown(); @@ -117,7 +126,7 @@ class ExampleLod : public entry::AppI return 0; } - bool update() BX_OVERRIDE + bool update() override { if (!entry::processEvents(m_width, m_height, m_debug, m_reset, &m_mouseState) ) { @@ -131,18 +140,25 @@ class ExampleLod : public entry::AppI , uint16_t(m_height) ); - imguiBeginScrollArea("Toggle transitions", m_width - m_width / 5 - 10, 10, m_width / 5, m_height / 6, &m_scrollArea); - imguiSeparatorLine(); + showExampleDialog(this); - if (imguiButton(m_transitions ? "ON" : "OFF") ) - { - m_transitions = !m_transitions; - } + ImGui::SetNextWindowPos( + ImVec2(m_width - m_width / 5.0f - 10.0f, 10.0f) + , ImGuiSetCond_FirstUseEver + ); + ImGui::Begin("Settings" + , NULL + , ImVec2(m_width / 5.0f, m_height / 6.0f) + , ImGuiWindowFlags_AlwaysAutoResize + ); + + ImGui::Checkbox("Transition", &m_transitions); static float distance = 2.0f; - imguiSlider("Distance", distance, 2.0f, 6.0f, 0.01f); + ImGui::SliderFloat("Distance", &distance, 2.0f, 6.0f); + + ImGui::End(); - imguiEndScrollArea(); imguiEndFrame(); // Set view 0 default viewport. @@ -152,19 +168,6 @@ class ExampleLod : public entry::AppI // if no other draw calls are submitted to view 0. bgfx::touch(0); - int64_t now = bx::getHPCounter(); - static int64_t last = now; - const int64_t frameTime = now - last; - last = now; - const double freq = double(bx::getHPFrequency() ); - const double toMs = 1000.0/freq; - - // Use debug font to print information about this example. - bgfx::dbgTextClear(); - bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/12-lod"); - bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Mesh LOD transitions."); - bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs); - float at[3] = { 0.0f, 1.0f, 0.0f }; float eye[3] = { 0.0f, 2.0f, -distance }; @@ -312,4 +315,6 @@ class ExampleLod : public entry::AppI bool m_transitions; }; -ENTRY_IMPLEMENT_MAIN(ExampleLod); +} // namespace + +ENTRY_IMPLEMENT_MAIN(ExampleLod, "12-lod", "Mesh LOD transitions."); |