Skip to content

Commit

Permalink
HACK: Temporary workaround for glColor3ub crash on macOS
Browse files Browse the repository at this point in the history
glColor3ub is causing SEGFAULT on negative values, use glColor3i instead.
See LWJGL/lwjgl3#858

This call is rarely used so performance impact should be minimal.
  • Loading branch information
pftbest committed Feb 15, 2023
1 parent 49e85ce commit e2f0532
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/generated/java/org/lwjglx/opengl/GL11.java
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,13 @@ public static void glColor3f(float red, float green, float blue) {
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) {
Expand Down

0 comments on commit e2f0532

Please sign in to comment.