From 793f260be164cb73163382e32f7fd590f940b8de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Wed, 21 Jun 2017 20:06:01 -0700 Subject: [PATCH] Cleanup. --- examples/19-oit/oit.cpp | 78 ++++++++++++++++----------------- examples/27-terrain/terrain.cpp | 41 ++++++++--------- 2 files changed, 57 insertions(+), 62 deletions(-) diff --git a/examples/19-oit/oit.cpp b/examples/19-oit/oit.cpp index e2b67906e..a6937e66d 100644 --- a/examples/19-oit/oit.cpp +++ b/examples/19-oit/oit.cpp @@ -281,11 +281,11 @@ class ExampleOIT : public entry::AppI ImGui::SetNextWindowPos(ImVec2((float)m_width - (float)m_width / 4.0f - 10.0f, 10.0f) ); ImGui::SetNextWindowSize(ImVec2((float)m_width / 4.0f, (float)m_height / 3.0f) ); ImGui::Begin("Settings" - , NULL - , ImVec2((float)m_width / 4.0f, (float)m_height / 3.0f) - , ImGuiWindowFlags_AlwaysAutoResize - ); - + , NULL + , ImVec2((float)m_width / 4.0f, (float)m_height / 3.0f) + , ImGuiWindowFlags_AlwaysAutoResize + ); + ImGui::Separator(); ImGui::Text("Blend mode:"); @@ -295,7 +295,7 @@ class ExampleOIT : public entry::AppI ImGui::RadioButton("MRT Independent", &m_mode, 2); ImGui::Separator(); - + ImGui::Checkbox("Front to back", &m_frontToBack); ImGui::Checkbox("Fade in/out", &m_fadeInOut); @@ -410,48 +410,48 @@ class ExampleOIT : public entry::AppI ; const uint64_t stateNoDepth = 0 - | BGFX_STATE_CULL_CW - | BGFX_STATE_RGB_WRITE - | BGFX_STATE_ALPHA_WRITE - | BGFX_STATE_DEPTH_TEST_ALWAYS - | BGFX_STATE_MSAA - ; + | BGFX_STATE_CULL_CW + | BGFX_STATE_RGB_WRITE + | BGFX_STATE_ALPHA_WRITE + | BGFX_STATE_DEPTH_TEST_ALWAYS + | BGFX_STATE_MSAA + ; bgfx::ProgramHandle program = BGFX_INVALID_HANDLE; switch (m_mode) { - case 0: - // Set vertex and fragment shaders. - program = m_blend; + case 0: + // Set vertex and fragment shaders. + program = m_blend; - // Set render states. - bgfx::setState(state - | BGFX_STATE_BLEND_ALPHA - ); - break; + // Set render states. + bgfx::setState(state + | BGFX_STATE_BLEND_ALPHA + ); + break; - case 1: - // Set vertex and fragment shaders. - program = m_wbSeparatePass; + case 1: + // Set vertex and fragment shaders. + program = m_wbSeparatePass; - // Set render states. - bgfx::setState(stateNoDepth - | BGFX_STATE_BLEND_FUNC_SEPARATE(BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_ZERO, BGFX_STATE_BLEND_INV_SRC_ALPHA) - ); - break; + // Set render states. + bgfx::setState(stateNoDepth + | BGFX_STATE_BLEND_FUNC_SEPARATE(BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_ZERO, BGFX_STATE_BLEND_INV_SRC_ALPHA) + ); + break; - default: - // Set vertex and fragment shaders. - program = m_wbPass; + default: + // Set vertex and fragment shaders. + program = m_wbPass; - // Set render states. - bgfx::setState(stateNoDepth - | BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_ONE) - | BGFX_STATE_BLEND_INDEPENDENT - , 0 - | BGFX_STATE_BLEND_FUNC_RT_1(BGFX_STATE_BLEND_ZERO, BGFX_STATE_BLEND_SRC_COLOR) - ); - break; + // Set render states. + bgfx::setState(stateNoDepth + | BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_ONE) + | BGFX_STATE_BLEND_INDEPENDENT + , 0 + | BGFX_STATE_BLEND_FUNC_RT_1(BGFX_STATE_BLEND_ZERO, BGFX_STATE_BLEND_SRC_COLOR) + ); + break; } // Submit primitive for rendering to view 0. diff --git a/examples/27-terrain/terrain.cpp b/examples/27-terrain/terrain.cpp index f2502b64c..fa5f696a7 100644 --- a/examples/27-terrain/terrain.cpp +++ b/examples/27-terrain/terrain.cpp @@ -75,11 +75,11 @@ class ExampleTerrain : public entry::AppI // Set view 0 clear state. bgfx::setViewClear(0 - , BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH - , 0x303030ff - , 1.0f - , 0 - ); + , BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH + , 0x303030ff + , 1.0f + , 0 + ); // Create vertex stream declaration. PosTexCoord0Vertex::init(); @@ -104,8 +104,6 @@ class ExampleTerrain : public entry::AppI m_oldHeight = 0; m_oldReset = m_reset; - m_scrollArea = 0; - m_brush.m_power = 0.5f; m_brush.m_size = 10; m_brush.m_raise = true; @@ -393,30 +391,29 @@ class ExampleTerrain : public entry::AppI bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs); 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_buttons[entry::MouseButton::Middle] ? IMGUI_MBUT_MIDDLE : 0) - , m_mouseState.m_mz - , uint16_t(m_width) - , uint16_t(m_height) - ); + , 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_buttons[entry::MouseButton::Middle] ? IMGUI_MBUT_MIDDLE : 0) + , m_mouseState.m_mz + , uint16_t(m_width) + , uint16_t(m_height) + ); ImGui::SetNextWindowPos(ImVec2((float)m_width - (float)m_width / 5.0f - 10.0f, 10.0f) ); ImGui::SetNextWindowSize(ImVec2((float)m_width / 5.0f, (float)m_height / 3.0f) ); ImGui::Begin("Settings" - , NULL - , ImVec2((float)m_width / 5.0f, (float)m_height / 3.0f) - , ImGuiWindowFlags_AlwaysAutoResize - ); - + , NULL + , ImVec2((float)m_width / 5.0f, (float)m_height / 3.0f) + , ImGuiWindowFlags_AlwaysAutoResize + ); ImGui::Separator(); m_terrain.m_dirty |= ImGui::RadioButton("Vertex Buffer", &m_terrain.m_mode, 0); m_terrain.m_dirty |= ImGui::RadioButton("Dynamic Vertex Buffer", &m_terrain.m_mode, 1); m_terrain.m_dirty |= ImGui::RadioButton("Height Texture", &m_terrain.m_mode, 2); - + ImGui::Separator(); ImGui::Checkbox("Raise Terrain", &m_brush.m_raise); @@ -507,8 +504,6 @@ class ExampleTerrain : public entry::AppI uint32_t m_oldHeight; uint32_t m_oldReset; - int32_t m_scrollArea; - TerrainData m_terrain; BrushData m_brush;