Immediate-Mode-UI / Nuklear

A single-header ANSI C immediate mode cross-platform GUI library
https://immediate-mode-ui.github.io/Nuklear/doc/index.html
Other
9.25k stars 561 forks source link

GDI color picker not working #457

Open bmuessig opened 2 years ago

bmuessig commented 2 years ago

The color matrix of the color picker is not rendered in the GDI binding: grafik

I believe that the following method is not completely implemented: https://github.com/Immediate-Mode-UI/Nuklear/blob/master/demo/gdi/nuklear_gdi.h#L240

bmuessig commented 2 years ago

I believe this is an issue with transparency handling.

Drawing the color gradient works fine: https://github.com/Immediate-Mode-UI/Nuklear/blob/master/src/nuklear_color_picker.c#L108 The transparent black gradient in the next line does not work and always completely blacks out the color gradient.

bmuessig commented 2 years ago

Okay, I see the issues:

  1. nk_gdi_set_vertexColor does not respect alpha and also only bitshifts to convert 8 to 16 bit color components
  2. Alpha blending is not working properly in GDI
  3. There is no double buffering to a 32-bit RGBA surface
bmuessig commented 2 years ago

I don't think there is a quick fix for this. GDI (without plus) does not appear have enough alpha support to make this feature work. Even with double buffering and alpha blending instead of bit blitting, the alpha channel is simply ignored. This also makes me wonder, if transparent images are supported either. My best guess would be that they don't work.

I've still made a few improvements in this PR: https://github.com/Immediate-Mode-UI/Nuklear/pull/460

BraynStorm commented 2 years ago

It seems that AlphaBlend has a critical limitation: If the source and destination are the same surface, that is, they are both the screen or the same memory bitmap and the source and destination rectangles overlap, an error occurs and the function returns FALSE.

Source: https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-alphablend#remarks

GetLastError() after AlphaBlend() returns error code 87 == ERROR_INVALID_PARAMETER

BraynStorm commented 2 years ago

Nevermind, I'm blind... They are not the same, but the error returned is still there.

BraynStorm commented 2 years ago

Moreover, GetDeviceCaps(gdi.window_dc, SHADEBLENDCAPS) == SB_NONE indicates that the context doesn't support blending. WTF?