mirror of
				https://github.com/ocornut/imgui.git
				synced 2025-10-26 12:27:30 +00:00 
			
		
		
		
	Backends: DX9: add missing IMGUI_USE_BGRA_PACKED_COLOR support. Remove dinput.h headers. (#3844)
This commit is contained in:
		| @@ -11,6 +11,7 @@ | |||||||
|  |  | ||||||
| // CHANGELOG | // CHANGELOG | ||||||
| // (minor and older changes stripped away, please see git history for details) | // (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. | //  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-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. | //  2019-04-30: DirectX9: Added support for special ImDrawCallback_ResetRenderState callback to reset render state. | ||||||
| @@ -28,8 +29,6 @@ | |||||||
|  |  | ||||||
| // DirectX | // DirectX | ||||||
| #include <d3d9.h> | #include <d3d9.h> | ||||||
| #define DIRECTINPUT_VERSION 0x0800 |  | ||||||
| #include <dinput.h> |  | ||||||
|  |  | ||||||
| // DirectX data | // DirectX data | ||||||
| static LPDIRECT3DDEVICE9        g_pd3dDevice = NULL; | static LPDIRECT3DDEVICE9        g_pd3dDevice = NULL; | ||||||
| @@ -140,7 +139,7 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data) | |||||||
|     g_pd3dDevice->GetTransform(D3DTS_PROJECTION, &last_projection); |     g_pd3dDevice->GetTransform(D3DTS_PROJECTION, &last_projection); | ||||||
|  |  | ||||||
|     // Copy and convert all vertices into a single contiguous buffer, convert colors to DX9 default format. |     // 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 |     //  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; } |     //  2) to avoid repacking vertices: #define IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT struct ImDrawVert { ImVec2 pos; float z; ImU32 col; ImVec2 uv; } | ||||||
|     CUSTOMVERTEX* vtx_dst; |     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[0] = vtx_src->pos.x; | ||||||
|             vtx_dst->pos[1] = vtx_src->pos.y; |             vtx_dst->pos[1] = vtx_src->pos.y; | ||||||
|             vtx_dst->pos[2] = 0.0f; |             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[0] = vtx_src->uv.x; | ||||||
|             vtx_dst->uv[1] = vtx_src->uv.y; |             vtx_dst->uv[1] = vtx_src->uv.y; | ||||||
|             vtx_dst++; |             vtx_dst++; | ||||||
|   | |||||||
| @@ -62,6 +62,7 @@ Other Changes: | |||||||
|   preserve alpha in output buffer (using SrcBlendAlpha = ONE, DstBlendAlpha = ONE_MINUS_SRC_ALPHA consistently |   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. |   accross all backends), facilitating compositing of the output buffer with another buffer. | ||||||
|   (#2693, #2764, #2766, #2873, #3447, #3813, #3816) [@ocornut, @thedmd, @ShawnM427, @Ubpa, @aiekick] |   (#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. | - 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 | - CI: Use a dedicated "scheduled" workflow to trigger scheduled builds. Forks may disable this workflow if | ||||||
|   scheduled builds builds are not required. [@rokups] |   scheduled builds builds are not required. [@rokups] | ||||||
|   | |||||||
| @@ -7,8 +7,6 @@ | |||||||
| #include "imgui_impl_dx10.h" | #include "imgui_impl_dx10.h" | ||||||
| #include <d3d10_1.h> | #include <d3d10_1.h> | ||||||
| #include <d3d10.h> | #include <d3d10.h> | ||||||
| #define DIRECTINPUT_VERSION 0x0800 |  | ||||||
| #include <dinput.h> |  | ||||||
| #include <tchar.h> | #include <tchar.h> | ||||||
|  |  | ||||||
| // Data | // Data | ||||||
|   | |||||||
| @@ -6,8 +6,6 @@ | |||||||
| #include "imgui_impl_win32.h" | #include "imgui_impl_win32.h" | ||||||
| #include "imgui_impl_dx11.h" | #include "imgui_impl_dx11.h" | ||||||
| #include <d3d11.h> | #include <d3d11.h> | ||||||
| #define DIRECTINPUT_VERSION 0x0800 |  | ||||||
| #include <dinput.h> |  | ||||||
| #include <tchar.h> | #include <tchar.h> | ||||||
|  |  | ||||||
| // Data | // Data | ||||||
|   | |||||||
| @@ -6,8 +6,6 @@ | |||||||
| #include "imgui_impl_dx9.h" | #include "imgui_impl_dx9.h" | ||||||
| #include "imgui_impl_win32.h" | #include "imgui_impl_win32.h" | ||||||
| #include <d3d9.h> | #include <d3d9.h> | ||||||
| #define DIRECTINPUT_VERSION 0x0800 |  | ||||||
| #include <dinput.h> |  | ||||||
| #include <tchar.h> | #include <tchar.h> | ||||||
|  |  | ||||||
| // Data | // Data | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Xiliusha
					Xiliusha