From eb574849356a4edec42aadb22d11157054248077 Mon Sep 17 00:00:00 2001 From: Xiliusha Date: Fri, 26 Feb 2021 10:40:22 +0800 Subject: [PATCH] Backends: DX9: add missing IMGUI_USE_BGRA_PACKED_COLOR support. Remove dinput.h headers. (#3844) --- backends/imgui_impl_dx9.cpp | 11 +++++++---- docs/CHANGELOG.txt | 1 + examples/example_win32_directx10/main.cpp | 2 -- examples/example_win32_directx11/main.cpp | 2 -- examples/example_win32_directx9/main.cpp | 2 -- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/backends/imgui_impl_dx9.cpp b/backends/imgui_impl_dx9.cpp index 44dea337..7e851ec7 100644 --- a/backends/imgui_impl_dx9.cpp +++ b/backends/imgui_impl_dx9.cpp @@ -11,6 +11,7 @@ // CHANGELOG // (minor and older changes stripped away, please see git history for details) +// 2021-03-03: DirectX9: Added support for IMGUI_USE_BGRA_PACKED_COLOR in user's imconfig file. // 2021-02-18: DirectX9: Change blending equation to preserve alpha in output buffer. // 2019-05-29: DirectX9: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag. // 2019-04-30: DirectX9: Added support for special ImDrawCallback_ResetRenderState callback to reset render state. @@ -28,8 +29,6 @@ // DirectX #include -#define DIRECTINPUT_VERSION 0x0800 -#include // DirectX data static LPDIRECT3DDEVICE9 g_pd3dDevice = NULL; @@ -140,7 +139,7 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data) g_pd3dDevice->GetTransform(D3DTS_PROJECTION, &last_projection); // Copy and convert all vertices into a single contiguous buffer, convert colors to DX9 default format. - // FIXME-OPT: This is a waste of resource, the ideal is to use imconfig.h and + // FIXME-OPT: This is a minor waste of resource, the ideal is to use imconfig.h and // 1) to avoid repacking colors: #define IMGUI_USE_BGRA_PACKED_COLOR // 2) to avoid repacking vertices: #define IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT struct ImDrawVert { ImVec2 pos; float z; ImU32 col; ImVec2 uv; } CUSTOMVERTEX* vtx_dst; @@ -158,7 +157,11 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data) vtx_dst->pos[0] = vtx_src->pos.x; vtx_dst->pos[1] = vtx_src->pos.y; vtx_dst->pos[2] = 0.0f; - vtx_dst->col = (vtx_src->col & 0xFF00FF00) | ((vtx_src->col & 0xFF0000) >> 16) | ((vtx_src->col & 0xFF) << 16); // RGBA --> ARGB for DirectX9 +#ifdef IMGUI_USE_BGRA_PACKED_COLOR + vtx_dst->col = vtx_src->col; +#else + vtx_dst->col = (vtx_src->col & 0xFF00FF00) | ((vtx_src->col & 0xFF0000) >> 16) | ((vtx_src->col & 0xFF) << 16); // RGBA --> ARGB for DirectX9 +#endif vtx_dst->uv[0] = vtx_src->uv.x; vtx_dst->uv[1] = vtx_src->uv.y; vtx_dst++; diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 10761cdb..bc9a75c3 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -62,6 +62,7 @@ Other Changes: preserve alpha in output buffer (using SrcBlendAlpha = ONE, DstBlendAlpha = ONE_MINUS_SRC_ALPHA consistently accross all backends), facilitating compositing of the output buffer with another buffer. (#2693, #2764, #2766, #2873, #3447, #3813, #3816) [@ocornut, @thedmd, @ShawnM427, @Ubpa, @aiekick] +- Backends: DX9: Fix to support IMGUI_USE_BGRA_PACKED_COLOR. (#3844) [@Xiliusha] - Examples: Reworked setup of clear color to be compatible with transparent values. - CI: Use a dedicated "scheduled" workflow to trigger scheduled builds. Forks may disable this workflow if scheduled builds builds are not required. [@rokups] diff --git a/examples/example_win32_directx10/main.cpp b/examples/example_win32_directx10/main.cpp index 2a131c18..b1360018 100644 --- a/examples/example_win32_directx10/main.cpp +++ b/examples/example_win32_directx10/main.cpp @@ -7,8 +7,6 @@ #include "imgui_impl_dx10.h" #include #include -#define DIRECTINPUT_VERSION 0x0800 -#include #include // Data diff --git a/examples/example_win32_directx11/main.cpp b/examples/example_win32_directx11/main.cpp index dd14c2e1..e882f6a1 100644 --- a/examples/example_win32_directx11/main.cpp +++ b/examples/example_win32_directx11/main.cpp @@ -6,8 +6,6 @@ #include "imgui_impl_win32.h" #include "imgui_impl_dx11.h" #include -#define DIRECTINPUT_VERSION 0x0800 -#include #include // Data diff --git a/examples/example_win32_directx9/main.cpp b/examples/example_win32_directx9/main.cpp index 54e7026a..ce59a9a8 100644 --- a/examples/example_win32_directx9/main.cpp +++ b/examples/example_win32_directx9/main.cpp @@ -6,8 +6,6 @@ #include "imgui_impl_dx9.h" #include "imgui_impl_win32.h" #include -#define DIRECTINPUT_VERSION 0x0800 -#include #include // Data