From e1acccc9fa2f2d2b968ea906360c67e6bb5d4778 Mon Sep 17 00:00:00 2001 From: Tropby Date: Sun, 16 Apr 2023 17:00:02 +0200 Subject: [PATCH 1/3] Fixed errors with GCC 12, 64Bit on Windows --- demo/gdi/nuklear_gdi.h | 2 +- demo/gdip/nuklear_gdip.h | 9 ++++++--- nuklear.h | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/demo/gdi/nuklear_gdi.h b/demo/gdi/nuklear_gdi.h index 8efc8daf3..55640de57 100644 --- a/demo/gdi/nuklear_gdi.h +++ b/demo/gdi/nuklear_gdi.h @@ -264,7 +264,7 @@ nk_gdi_rect_multi_color(HDC dc, short x, short y, unsigned short w, gTri[1].Vertex2 = 1; gTri[1].Vertex3 = 3; GdiGradientFill(dc, vt, 4, gTri, 2 , GRADIENT_FILL_TRIANGLE); - AlphaBlend(gdi.window_dc, x, y, x+w, y+h,gdi.memory_dc, x, y, x+w, y+h,alphaFunction); + //AlphaBlend(gdi.window_dc, x, y, x+w, y+h,gdi.memory_dc, x, y, x+w, y+h,alphaFunction); } diff --git a/demo/gdip/nuklear_gdip.h b/demo/gdip/nuklear_gdip.h index f83964d0a..c9884c228 100644 --- a/demo/gdip/nuklear_gdip.h +++ b/demo/gdip/nuklear_gdip.h @@ -628,7 +628,7 @@ static void nk_gdip_draw_image(short x, short y, unsigned short w, unsigned short h, struct nk_image img, struct nk_color col) { - GpImage *image = img.handle.ptr; + GpImage *image = (GpImage *)img.handle.ptr; GdipDrawImageRectI(gdip.memory, image, x, y, w, h); } @@ -675,7 +675,10 @@ nk_gdip_load_image_from_memory(const void *membuf, nk_uint membufSize) return nk_image_id(0); status = GdipLoadImageFromStream(stream, &image); - stream->lpVtbl->Release(stream); + + /// TODO: 'IStream' {aka 'struct IStream'} has no member named 'lpVtbl'GCC + stream->Release(); + //stream->lpVtbl->Release(stream); if (status) return nk_image_id(0); @@ -688,7 +691,7 @@ nk_gdip_image_free(struct nk_image image) { if (!image.handle.ptr) return; - GdipDisposeImage(image.handle.ptr); + GdipDisposeImage((GpImage*)image.handle.ptr); } GdipFont* diff --git a/nuklear.h b/nuklear.h index febee39fa..b276b20dc 100644 --- a/nuklear.h +++ b/nuklear.h @@ -373,7 +373,7 @@ extern "C" { #define NK_SIZE_TYPE unsigned __int32 #elif defined(__GNUC__) || defined(__clang__) #if defined(__x86_64__) || defined(__ppc64__) || defined(__aarch64__) - #define NK_SIZE_TYPE unsigned long + #define NK_SIZE_TYPE unsigned long long #else #define NK_SIZE_TYPE unsigned int #endif @@ -388,7 +388,7 @@ extern "C" { #define NK_POINTER_TYPE unsigned __int32 #elif defined(__GNUC__) || defined(__clang__) #if defined(__x86_64__) || defined(__ppc64__) || defined(__aarch64__) - #define NK_POINTER_TYPE unsigned long + #define NK_POINTER_TYPE unsigned long long #else #define NK_POINTER_TYPE unsigned int #endif From 24945d1f15878a2addce1c4704ce563c347790cb Mon Sep 17 00:00:00 2001 From: Tropby Date: Sun, 10 Mar 2024 20:31:58 +0100 Subject: [PATCH 2/3] Fixed ColorPicker for GDI. --- demo/gdi/nuklear_gdi.h | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/demo/gdi/nuklear_gdi.h b/demo/gdi/nuklear_gdi.h index 55640de57..e277a841e 100644 --- a/demo/gdi/nuklear_gdi.h +++ b/demo/gdi/nuklear_gdi.h @@ -221,7 +221,7 @@ nk_gdi_set_vertexColor(PTRIVERTEX tri, struct nk_color col) tri->Red = col.r << 8; tri->Green = col.g << 8; tri->Blue = col.b << 8; - tri->Alpha = 0xff << 8; + tri->Alpha = col.a << 8; } static void @@ -235,26 +235,26 @@ nk_gdi_rect_multi_color(HDC dc, short x, short y, unsigned short w, TRIVERTEX vt[4]; alphaFunction.BlendOp = AC_SRC_OVER; alphaFunction.BlendFlags = 0; - alphaFunction.SourceConstantAlpha = 0; + alphaFunction.SourceConstantAlpha = 255; alphaFunction.AlphaFormat = AC_SRC_ALPHA; /* TODO: This Case Needs Repair.*/ /* Top Left Corner */ - vt[0].x = x; - vt[0].y = y; + vt[0].x = 0; + vt[0].y = 0; nk_gdi_set_vertexColor(&vt[0], left); /* Top Right Corner */ - vt[1].x = x+w; - vt[1].y = y; + vt[1].x = 0+w; + vt[1].y = 0; nk_gdi_set_vertexColor(&vt[1], top); /* Bottom Left Corner */ - vt[2].x = x; - vt[2].y = y+h; + vt[2].x = 0; + vt[2].y = 0+h; nk_gdi_set_vertexColor(&vt[2], right); /* Bottom Right Corner */ - vt[3].x = x+w; - vt[3].y = y+h; + vt[3].x = 0+w; + vt[3].y = 0+h; nk_gdi_set_vertexColor(&vt[3], bottom); gTri[0].Vertex1 = 0; @@ -263,9 +263,17 @@ nk_gdi_rect_multi_color(HDC dc, short x, short y, unsigned short w, gTri[1].Vertex1 = 2; gTri[1].Vertex2 = 1; gTri[1].Vertex3 = 3; - GdiGradientFill(dc, vt, 4, gTri, 2 , GRADIENT_FILL_TRIANGLE); - //AlphaBlend(gdi.window_dc, x, y, x+w, y+h,gdi.memory_dc, x, y, x+w, y+h,alphaFunction); + HDC memdc = CreateCompatibleDC(dc); + HBITMAP bitmap = CreateCompatibleBitmap(dc, w, h); + HGDIOBJ old = SelectObject(memdc, bitmap); + + GdiGradientFill(memdc, vt, 4, gTri, 2 , GRADIENT_FILL_TRIANGLE); + + GdiAlphaBlend(dc, x, y, w, h, memdc, 0, 0, w, h, alphaFunction); + + DeleteDC(memdc); + DeleteObject(bitmap); } static BOOL From 1ba640a9aa2c388991993e4318a6ff6d28e640ae Mon Sep 17 00:00:00 2001 From: Tropby Date: Sun, 10 Mar 2024 20:32:59 +0100 Subject: [PATCH 3/3] Fixed ColorPicker gradients --- nuklear.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nuklear.h b/nuklear.h index b276b20dc..d68b43a2d 100644 --- a/nuklear.h +++ b/nuklear.h @@ -28552,7 +28552,7 @@ nk_draw_color_picker(struct nk_command_buffer *o, const struct nk_rect *matrix, /* draw color matrix */ temp = nk_hsv_f(hsva[0], 1.0f, 1.0f); - nk_fill_rect_multi_color(o, *matrix, white, temp, temp, white); + nk_fill_rect_multi_color(o, *matrix, white, temp, white, temp); nk_fill_rect_multi_color(o, *matrix, black_trans, black_trans, black, black); /* draw cross-hair */