From c9bc61511ef3c95dca09b9df23b8b664bd0d44c0 Mon Sep 17 00:00:00 2001 From: Vadzim Dambrouski Date: Wed, 15 Feb 2023 18:58:19 +0100 Subject: [PATCH] HACK: Temporary workaround for glColor3ub crash on macOS (#17) glColor3ub is causing SEGFAULT on negative values, use glColor3i instead. See https://github.com/LWJGL/lwjgl3/issues/858 This call is rarely used so performance impact should be minimal. --- src/generated/java/org/lwjglx/opengl/GL11.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/generated/java/org/lwjglx/opengl/GL11.java b/src/generated/java/org/lwjglx/opengl/GL11.java index af2f581..36c12b5 100644 --- a/src/generated/java/org/lwjglx/opengl/GL11.java +++ b/src/generated/java/org/lwjglx/opengl/GL11.java @@ -625,8 +625,13 @@ public class GL11 { org.lwjgl.opengl.GL11.glColor3f(red, green, blue); } + private static final int UNSIGNED_BYTE_TO_INT_RATIO = Integer.MAX_VALUE / 255; + public static void glColor3ub(byte red, byte green, byte blue) { - org.lwjgl.opengl.GL11.glColor3ub(red, green, blue); + org.lwjgl.opengl.GL11.glColor3i( + (red & 0xff) * UNSIGNED_BYTE_TO_INT_RATIO, + (green & 0xff) * UNSIGNED_BYTE_TO_INT_RATIO, + (blue & 0xff) * UNSIGNED_BYTE_TO_INT_RATIO); } public static void glColor4b(byte red, byte green, byte blue, byte alpha) {