diff options
Diffstat (limited to '3rdparty/bgfx/examples/common')
-rw-r--r-- | 3rdparty/bgfx/examples/common/cube_atlas.cpp | 25 | ||||
-rw-r--r-- | 3rdparty/bgfx/examples/common/entry/entry.cpp | 10 | ||||
-rw-r--r-- | 3rdparty/bgfx/examples/common/entry/entry_windows.cpp | 2 | ||||
-rw-r--r-- | 3rdparty/bgfx/examples/common/imgui/ocornut_imgui.cpp | 70 |
4 files changed, 87 insertions, 20 deletions
diff --git a/3rdparty/bgfx/examples/common/cube_atlas.cpp b/3rdparty/bgfx/examples/common/cube_atlas.cpp index ac7343b9b21..7b83f6f7518 100644 --- a/3rdparty/bgfx/examples/common/cube_atlas.cpp +++ b/3rdparty/bgfx/examples/common/cube_atlas.cpp @@ -81,7 +81,7 @@ RectanglePacker::RectanglePacker(uint32_t _width, uint32_t _height) { // We want a one pixel border around the whole atlas to avoid any artefact when // sampling texture - m_skyline.push_back(Node(1, 1, _width - 2) ); + m_skyline.push_back(Node(1, 1, uint16_t(_width - 2) ) ); } void RectanglePacker::init(uint32_t _width, uint32_t _height) @@ -95,38 +95,35 @@ void RectanglePacker::init(uint32_t _width, uint32_t _height) m_skyline.clear(); // We want a one pixel border around the whole atlas to avoid any artifact when // sampling texture - m_skyline.push_back(Node(1, 1, _width - 2) ); + m_skyline.push_back(Node(1, 1, uint16_t(_width - 2) ) ); } bool RectanglePacker::addRectangle(uint16_t _width, uint16_t _height, uint16_t& _outX, uint16_t& _outY) { - int yy, best_height, best_index; + int best_height, best_index; int32_t best_width; Node* node; Node* prev; _outX = 0; _outY = 0; - uint32_t ii; - best_height = INT_MAX; best_index = -1; best_width = INT_MAX; - for (ii = 0; ii < m_skyline.size(); ++ii) + for (uint16_t ii = 0, num = uint16_t(m_skyline.size() ); ii < num; ++ii) { - yy = fit(ii, _width, _height); + int32_t yy = fit(ii, _width, _height); if (yy >= 0) { node = &m_skyline[ii]; if ( ( (yy + _height) < best_height) - || ( ( (yy + _height) == best_height) - && (node->width < best_width) ) ) + || ( ( (yy + _height) == best_height) && (node->width < best_width) ) ) { - best_height = yy + _height; + best_height = uint16_t(yy) + _height; best_index = ii; best_width = node->width; _outX = node->x; - _outY = yy; + _outY = uint16_t(yy); } } } @@ -139,13 +136,13 @@ bool RectanglePacker::addRectangle(uint16_t _width, uint16_t _height, uint16_t& Node newNode(_outX, _outY + _height, _width); m_skyline.insert(m_skyline.begin() + best_index, newNode); - for (ii = best_index + 1; ii < m_skyline.size(); ++ii) + for (uint16_t ii = uint16_t(best_index + 1), num = uint16_t(m_skyline.size() ); ii < num; ++ii) { node = &m_skyline[ii]; prev = &m_skyline[ii - 1]; if (node->x < (prev->x + prev->width) ) { - int shrink = prev->x + prev->width - node->x; + uint16_t shrink = uint16_t(prev->x + prev->width - node->x); node->x += shrink; node->width -= shrink; if (node->width <= 0) @@ -187,7 +184,7 @@ void RectanglePacker::clear() // We want a one pixel border around the whole atlas to avoid any artefact when // sampling texture - m_skyline.push_back(Node(1, 1, m_width - 2) ); + m_skyline.push_back(Node(1, 1, uint16_t(m_width - 2) ) ); } int32_t RectanglePacker::fit(uint32_t _skylineNodeIndex, uint16_t _width, uint16_t _height) diff --git a/3rdparty/bgfx/examples/common/entry/entry.cpp b/3rdparty/bgfx/examples/common/entry/entry.cpp index 919a783c9dc..0e03876a17e 100644 --- a/3rdparty/bgfx/examples/common/entry/entry.cpp +++ b/3rdparty/bgfx/examples/common/entry/entry.cpp @@ -188,7 +188,7 @@ BX_PRAGMA_DIAGNOSTIC_POP(); const bool isNumber = (Key::Key0 <= _key && _key <= Key::Key9); if (isNumber) { - return '0' + (_key - Key::Key0); + return '0' + char(_key - Key::Key0); } const bool isChar = (Key::KeyA <= _key && _key <= Key::KeyZ); @@ -197,7 +197,7 @@ BX_PRAGMA_DIAGNOSTIC_POP(); enum { ShiftMask = Modifier::LeftShift|Modifier::RightShift }; const bool shift = !!(_modifiers&ShiftMask); - return (shift ? 'A' : 'a') + (_key - Key::KeyA); + return (shift ? 'A' : 'a') + char(_key - Key::KeyA); } switch (_key) @@ -538,7 +538,7 @@ BX_PRAGMA_DIAGNOSTIC_POP(); { _reset = s_reset; bgfx::reset(_width, _height, _reset); - inputSetMouseResolution(_width, _height); + inputSetMouseResolution(uint16_t(_width), uint16_t(_height) ); } _debug = s_debug; @@ -692,7 +692,7 @@ BX_PRAGMA_DIAGNOSTIC_POP(); if (handle.idx == 0) { - inputSetMouseResolution(win.m_width, win.m_height); + inputSetMouseResolution(uint16_t(win.m_width), uint16_t(win.m_height) ); } } @@ -700,7 +700,7 @@ BX_PRAGMA_DIAGNOSTIC_POP(); { _reset = s_reset; bgfx::reset(s_window[0].m_width, s_window[0].m_height, _reset); - inputSetMouseResolution(s_window[0].m_width, s_window[0].m_height); + inputSetMouseResolution(uint16_t(s_window[0].m_width), uint16_t(s_window[0].m_height) ); } _debug = s_debug; diff --git a/3rdparty/bgfx/examples/common/entry/entry_windows.cpp b/3rdparty/bgfx/examples/common/entry/entry_windows.cpp index 37f403ee480..9d0308e9617 100644 --- a/3rdparty/bgfx/examples/common/entry/entry_windows.cpp +++ b/3rdparty/bgfx/examples/common/entry/entry_windows.cpp @@ -823,7 +823,7 @@ namespace entry WindowHandle findHandle(HWND _hwnd) { bx::LwMutexScope scope(m_lock); - for (uint32_t ii = 0, num = m_windowAlloc.getNumHandles(); ii < num; ++ii) + for (uint16_t ii = 0, num = m_windowAlloc.getNumHandles(); ii < num; ++ii) { uint16_t idx = m_windowAlloc.getHandleAt(ii); if (_hwnd == m_hwnd[idx]) diff --git a/3rdparty/bgfx/examples/common/imgui/ocornut_imgui.cpp b/3rdparty/bgfx/examples/common/imgui/ocornut_imgui.cpp index f6f0a4e2bdd..5c320d5227a 100644 --- a/3rdparty/bgfx/examples/common/imgui/ocornut_imgui.cpp +++ b/3rdparty/bgfx/examples/common/imgui/ocornut_imgui.cpp @@ -364,6 +364,8 @@ struct OcornutImguiContext io.DeltaTime = 1.0f / 60.0f; io.IniFilename = NULL; + setupStyle(true); + #if defined(SCI_NAMESPACE) io.KeyMap[ImGuiKey_Tab] = (int)entry::Key::Tab; io.KeyMap[ImGuiKey_LeftArrow] = (int)entry::Key::Left; @@ -509,6 +511,74 @@ struct OcornutImguiContext m_allocator = NULL; } + void setupStyle(bool _dark) + { + // Doug Binks' color scheme + // https://gist.github.com/dougbinks/8089b4bbaccaaf6fa204236978d165a9 + ImGuiStyle& style = ImGui::GetStyle(); + + style.FrameRounding = 3.0f; + style.Colors[ImGuiCol_Text] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f); + style.Colors[ImGuiCol_TextDisabled] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f); + style.Colors[ImGuiCol_WindowBg] = ImVec4(0.94f, 0.94f, 0.94f, 1.00f); + style.Colors[ImGuiCol_ChildWindowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); + style.Colors[ImGuiCol_Border] = ImVec4(0.00f, 0.00f, 0.00f, 0.39f); + style.Colors[ImGuiCol_BorderShadow] = ImVec4(1.00f, 1.00f, 1.00f, 0.10f); + style.Colors[ImGuiCol_FrameBg] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); + style.Colors[ImGuiCol_FrameBgHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f); + style.Colors[ImGuiCol_FrameBgActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f); + style.Colors[ImGuiCol_TitleBg] = ImVec4(0.96f, 0.96f, 0.96f, 1.00f); + style.Colors[ImGuiCol_TitleBgCollapsed] = ImVec4(1.00f, 1.00f, 1.00f, 0.51f); + style.Colors[ImGuiCol_TitleBgActive] = ImVec4(0.82f, 0.82f, 0.82f, 1.00f); + style.Colors[ImGuiCol_MenuBarBg] = ImVec4(0.86f, 0.86f, 0.86f, 1.00f); + style.Colors[ImGuiCol_ScrollbarBg] = ImVec4(0.98f, 0.98f, 0.98f, 0.53f); + style.Colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.69f, 0.69f, 0.69f, 0.80f); + style.Colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.49f, 0.49f, 0.49f, 0.80f); + style.Colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.49f, 0.49f, 0.49f, 1.00f); + style.Colors[ImGuiCol_ComboBg] = ImVec4(0.86f, 0.86f, 0.86f, 0.99f); + style.Colors[ImGuiCol_CheckMark] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + style.Colors[ImGuiCol_SliderGrab] = ImVec4(0.26f, 0.59f, 0.98f, 0.78f); + style.Colors[ImGuiCol_SliderGrabActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + style.Colors[ImGuiCol_Button] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f); + style.Colors[ImGuiCol_ButtonHovered] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + style.Colors[ImGuiCol_ButtonActive] = ImVec4(0.06f, 0.53f, 0.98f, 1.00f); + style.Colors[ImGuiCol_Header] = ImVec4(0.26f, 0.59f, 0.98f, 0.31f); + style.Colors[ImGuiCol_HeaderHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f); + style.Colors[ImGuiCol_HeaderActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + style.Colors[ImGuiCol_Column] = ImVec4(0.39f, 0.39f, 0.39f, 1.00f); + style.Colors[ImGuiCol_ColumnHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.78f); + style.Colors[ImGuiCol_ColumnActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + style.Colors[ImGuiCol_ResizeGrip] = ImVec4(1.00f, 1.00f, 1.00f, 0.50f); + style.Colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f); + style.Colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f); + style.Colors[ImGuiCol_CloseButton] = ImVec4(0.59f, 0.59f, 0.59f, 0.50f); + style.Colors[ImGuiCol_CloseButtonHovered] = ImVec4(0.98f, 0.39f, 0.36f, 1.00f); + style.Colors[ImGuiCol_CloseButtonActive] = ImVec4(0.98f, 0.39f, 0.36f, 1.00f); + style.Colors[ImGuiCol_PlotLines] = ImVec4(0.39f, 0.39f, 0.39f, 1.00f); + style.Colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f); + style.Colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); + style.Colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f); + style.Colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f); + style.Colors[ImGuiCol_PopupBg] = ImVec4(1.00f, 1.00f, 1.00f, 0.94f); + style.Colors[ImGuiCol_ModalWindowDarkening] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f); + + if (_dark) + { + for (int i = 0; i <= ImGuiCol_COUNT; i++) + { + ImVec4& col = style.Colors[i]; + float H, S, V; + ImGui::ColorConvertRGBtoHSV( col.x, col.y, col.z, H, S, V ); + + if( S < 0.1f ) + { + V = 1.0f - V; + } + ImGui::ColorConvertHSVtoRGB( H, S, V, col.x, col.y, col.z ); + } + } + } + void beginFrame(int32_t _mx, int32_t _my, uint8_t _button, int32_t _scroll, int _width, int _height, char _inputChar, uint8_t _viewId) { m_viewId = _viewId; |