Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

W11/DX9 color alpha doesn't show correctly i.e. ColorEdit4 #8336

Closed
ClaudiuHKS opened this issue Jan 21, 2025 · 3 comments
Closed

W11/DX9 color alpha doesn't show correctly i.e. ColorEdit4 #8336

ClaudiuHKS opened this issue Jan 21, 2025 · 3 comments

Comments

@ClaudiuHKS
Copy link
Contributor

Version/Branch of Dear ImGui:

Version 1.91.8 WIP (19172), Branch: master

Back-ends:

imgui_impl_win32.cpp + imgui_impl_dx9.cpp

Compiler, OS:

W11 + VS2022

Full config/build information:

Dear ImGui 1.91.8 WIP (19172)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=199711
define: _WIN32
define: _WIN64
define: _MSC_VER=1943
define: _MSVC_LANG=201402
--------------------------------
io.BackendPlatformName: imgui_impl_win32
io.BackendRendererName: imgui_impl_dx9
io.ConfigFlags: 0x00000003
 NavEnableKeyboard
 NavEnableGamepad
io.ConfigNavCaptureKeyboard
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x0000000F
 HasGamepad
 HasMouseCursors
 HasSetMousePos
 RendererHasVtxOffset
--------------------------------
io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,64
io.DisplaySize: 1536.00,793.00
io.DisplayFramebufferScale: 1.00,1.00
--------------------------------
style.WindowPadding: 8.00,8.00
style.WindowBorderSize: 1.00
style.FramePadding: 4.00,3.00
style.FrameRounding: 0.00
style.FrameBorderSize: 0.00
style.ItemSpacing: 8.00,4.00
style.ItemInnerSpacing: 4.00,4.00

Details:

My Issue/Question: No matter how I set alpha value (0-254), the alpha window is still containing white & grey squares. Only if alpha is 255 the white & grey squares are being opaque and displaying the color.

Screenshots/Video:

Image

Minimal, Complete and Verifiable Example code:

No response

@PathogenDavid
Copy link
Contributor

PathogenDavid commented Jan 21, 2025

This was broken by cd6c83c, specifically by this change to ImLerp<T>:

-template<typename T> static inline T ImLerp(T a, T b, float t)                  { return (T)(a + (b - a) * t); }
+template<typename T> static inline T ImLerp(T a, T b, float t)                  { return (T)(a + (b - a) * (T)t); }

Not sure what warning it's trying to silence, but that change is definitely not right. It's causing ImAlphaBlendColors to break, which is the only usage of ImLerp with a type other than float:

imgui/imgui.cpp

Lines 2567 to 2574 in 7ae7c90

IMGUI_API ImU32 ImAlphaBlendColors(ImU32 col_a, ImU32 col_b)
{
float t = ((col_b >> IM_COL32_A_SHIFT) & 0xFF) / 255.f;
int r = ImLerp((int)(col_a >> IM_COL32_R_SHIFT) & 0xFF, (int)(col_b >> IM_COL32_R_SHIFT) & 0xFF, t);
int g = ImLerp((int)(col_a >> IM_COL32_G_SHIFT) & 0xFF, (int)(col_b >> IM_COL32_G_SHIFT) & 0xFF, t);
int b = ImLerp((int)(col_a >> IM_COL32_B_SHIFT) & 0xFF, (int)(col_b >> IM_COL32_B_SHIFT) & 0xFF, t);
return IM_COL32(r, g, b, 0xFF);
}

@ocornut
Copy link
Owner

ocornut commented Jan 21, 2025

Thank you David for finding this! The warning it aimed to fix is listed as #8241

ocornut added a commit that referenced this issue Jan 21, 2025
ocornut pushed a commit that referenced this issue Jan 21, 2025
@ocornut
Copy link
Owner

ocornut commented Jan 21, 2025

Fixed by 2af26b7, thank you David!

@ocornut ocornut closed this as completed Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants