X Tutup
Skip to content

Commit f428b35

Browse files
fix crash with glColor3ub and glColor4ub on macOS (#54); closes #13, closes #14
1 parent f1e5b5b commit f428b35

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

library/src/main/java/com/basic4gl/library/desktopgl/GLBasicLib_gl.java

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5946,13 +5946,19 @@ public void run(TomVM vm) {
59465946
}
59475947
}
59485948

5949-
public static final class WrapglColor3ub implements Function {
5949+
public final class WrapglColor3ub implements Function {
59505950

59515951
public void run(TomVM vm) {
5952-
glColor3ub(
5953-
vm.getIntParam(3).byteValue(),
5954-
vm.getIntParam(2).byteValue(),
5955-
vm.getIntParam(1).byteValue());
5952+
// glColor3ub crashes on macOS - remap parameters to glColor3ubv
5953+
byteBuffer16.rewind();
5954+
byteBuffer16.put(vm.getIntParam(3).byteValue());
5955+
byteBuffer16.put(vm.getIntParam(2).byteValue());
5956+
byteBuffer16.put(vm.getIntParam(1).byteValue());
5957+
5958+
byteBuffer16.rewind();
5959+
glColor3ubv(byteBuffer16);
5960+
5961+
byteBuffer16.rewind();
59565962
}
59575963
}
59585964

@@ -6352,14 +6358,20 @@ public void run(TomVM vm) {
63526358
}
63536359
}
63546360

6355-
public static final class WrapglColor4ub implements Function {
6361+
public final class WrapglColor4ub implements Function {
63566362

63576363
public void run(TomVM vm) {
6358-
glColor4ub(
6359-
vm.getIntParam(4).byteValue(),
6360-
vm.getIntParam(3).byteValue(),
6361-
vm.getIntParam(2).byteValue(),
6362-
vm.getIntParam(1).byteValue());
6364+
// glColor4ub crashes on macOS - remap parameters to glColor4ubv
6365+
byteBuffer16.rewind();
6366+
byteBuffer16.put(vm.getIntParam(4).byteValue());
6367+
byteBuffer16.put(vm.getIntParam(3).byteValue());
6368+
byteBuffer16.put(vm.getIntParam(2).byteValue());
6369+
byteBuffer16.put(vm.getIntParam(1).byteValue());
6370+
6371+
byteBuffer16.rewind();
6372+
glColor4ubv(byteBuffer16);
6373+
6374+
byteBuffer16.rewind();
63636375
}
63646376
}
63656377

0 commit comments

Comments
 (0)
X Tutup