diff --git a/modules/core/src/main/java/org/lwjgl/opengl/GL.java b/modules/core/src/main/java/org/lwjgl/opengl/GL.java index ad08331587..4fef81c683 100644 --- a/modules/core/src/main/java/org/lwjgl/opengl/GL.java +++ b/modules/core/src/main/java/org/lwjgl/opengl/GL.java @@ -473,7 +473,7 @@ private static WGLCapabilities createCapabilitiesWGLDummy() { if ( DescribePixelFormat(hdc, pixelFormat, pfd) == 0 ) windowsThrowException("Failed to obtain pixel format information"); - if ( SetPixelFormat(hdc, pixelFormat, pfd) == 0 ) + if ( !SetPixelFormat(hdc, pixelFormat, pfd) ) windowsThrowException("Failed to set the pixel format"); hglrc = checkPointer(wglCreateContext(hdc)); diff --git a/modules/core/src/main/java/org/lwjgl/system/windows/WindowsLibrary.java b/modules/core/src/main/java/org/lwjgl/system/windows/WindowsLibrary.java index 80869a3e32..2332faa64e 100644 --- a/modules/core/src/main/java/org/lwjgl/system/windows/WindowsLibrary.java +++ b/modules/core/src/main/java/org/lwjgl/system/windows/WindowsLibrary.java @@ -58,7 +58,7 @@ public long getFunctionAddress(ByteBuffer functionName) { @Override public void free() { - if ( FreeLibrary(address()) == FALSE ) + if ( !FreeLibrary(address()) ) windowsThrowException("Failed to unload library: " + getName()); } diff --git a/modules/core/src/test/java/org/lwjgl/demo/glfw/Events.java b/modules/core/src/test/java/org/lwjgl/demo/glfw/Events.java index 468b3f45cb..08db1c88d2 100644 --- a/modules/core/src/test/java/org/lwjgl/demo/glfw/Events.java +++ b/modules/core/src/test/java/org/lwjgl/demo/glfw/Events.java @@ -43,10 +43,10 @@ public final class Events { "refreshed", window )); private static final GLFWWindowFocusCallback windowFocusCB = GLFWWindowFocusCallback.create((window, focused) -> printEvent( - focused == 0 ? "lost focus" : "gained focus", window + focused ? "gained focus" : "lost focus", window )); private static final GLFWWindowIconifyCallback windowIconifyCB = GLFWWindowIconifyCallback.create((window, iconified) -> printEvent( - iconified == 0 ? "restored" : "iconified", window + iconified ? "iconified" : "restored", window )); private static final GLFWFramebufferSizeCallback framebufferSizeCB = GLFWFramebufferSizeCallback.create((window, width, height) -> printEvent( @@ -73,7 +73,7 @@ public final class Events { printEvent("key %s[%s - %d] was %s", window, getModState(mods), KEY_CODES.get(key), scancode, state); if ( key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE ) - glfwSetWindowShouldClose(window, 1); + glfwSetWindowShouldClose(window, true); }); private static final GLFWCharCallback charCB = GLFWCharCallback.create((window, codepoint) -> printEvent( @@ -104,7 +104,7 @@ public final class Events { )); private static final GLFWCursorEnterCallback cursorEnterCB = GLFWCursorEnterCallback.create((window, entered) -> printEvent( - "cursor %s", window, entered == 0 ? "left" : "entered" + "cursor %s", window, entered ? "entered" : "left" )); private static final GLFWScrollCallback scrollCB = GLFWScrollCallback.create((window, xoffset, yoffset) -> printEvent( @@ -128,7 +128,7 @@ public static void main(String[] args) { glfwDefaultWindowHints(); System.err.println("---- [ Error callback done ] ----"); - if ( glfwInit() == 0 ) + if ( !glfwInit() ) throw new IllegalStateException("Failed to initialize GLFW."); System.out.println("GLFW initialized"); @@ -244,7 +244,7 @@ private static void demo() { glfwSwapInterval(1); glClearColor(1.0f, 1.0f, 1.0f, 0.0f); - while ( glfwWindowShouldClose(window) == 0 ) { + while ( !glfwWindowShouldClose(window) ) { glfwWaitEvents(); glClear(GL_COLOR_BUFFER_BIT); diff --git a/modules/core/src/test/java/org/lwjgl/demo/glfw/Gears.java b/modules/core/src/test/java/org/lwjgl/demo/glfw/Gears.java index 4c67c35472..8218046e69 100644 --- a/modules/core/src/test/java/org/lwjgl/demo/glfw/Gears.java +++ b/modules/core/src/test/java/org/lwjgl/demo/glfw/Gears.java @@ -51,7 +51,7 @@ private void run() { private void init() { errorCB = GLFWErrorCallback.createPrint().set(); - if ( glfwInit() != GLFW_TRUE ) + if ( !glfwInit() ) throw new IllegalStateException("Unable to initialize glfw"); glfwDefaultWindowHints(); @@ -92,7 +92,7 @@ public void invoke(long window, int key, int scancode, int action, int mods) { switch ( key ) { case GLFW_KEY_ESCAPE: - glfwSetWindowShouldClose(window, GLFW_TRUE); + glfwSetWindowShouldClose(window, true); break; case GLFW_KEY_F: if ( glfwGetWindowMonitor(window) == NULL ) { @@ -144,7 +144,7 @@ private void loop() { long lastUpdate = System.currentTimeMillis(); int frames = 0; - while ( glfwWindowShouldClose(window) == GLFW_FALSE ) { + while ( !glfwWindowShouldClose(window) ) { glfwPollEvents(); renderLoop(); diff --git a/modules/core/src/test/java/org/lwjgl/demo/glfw/MultipleWindows.java b/modules/core/src/test/java/org/lwjgl/demo/glfw/MultipleWindows.java index 5d4afec987..7c7e0bac24 100644 --- a/modules/core/src/test/java/org/lwjgl/demo/glfw/MultipleWindows.java +++ b/modules/core/src/test/java/org/lwjgl/demo/glfw/MultipleWindows.java @@ -25,7 +25,7 @@ private MultipleWindows() { public static void main(String[] args) { GLFWErrorCallback errorfun = GLFWErrorCallback.createPrint(); glfwSetErrorCallback(errorfun); - if ( glfwInit() == 0 ) + if ( !glfwInit() ) throw new IllegalStateException("Failed to initialize GLFW."); try { @@ -55,8 +55,8 @@ private static void demo() { glfwSetCursorEnterCallback(handle, window.cursorenterfun = new GLFWCursorEnterCallback() { @Override - public void invoke(long window, int entered) { - if ( entered == GLFW_TRUE ) + public void invoke(long window, boolean entered) { + if ( entered ) System.out.println("Mouse entered window: " + windowIndex); } }); @@ -91,7 +91,7 @@ public void invoke(long window, int entered) { glClear(GL_COLOR_BUFFER_BIT); glfwSwapBuffers(window.handle); - if ( glfwWindowShouldClose(window.handle) != 0 ) { + if ( !glfwWindowShouldClose(window.handle) ) { glfwDestroyWindow(window.handle); windows[i] = null; diff --git a/modules/core/src/test/java/org/lwjgl/demo/glfw/Threads.java b/modules/core/src/test/java/org/lwjgl/demo/glfw/Threads.java index 13ba80cbee..2ca5dee17f 100644 --- a/modules/core/src/test/java/org/lwjgl/demo/glfw/Threads.java +++ b/modules/core/src/test/java/org/lwjgl/demo/glfw/Threads.java @@ -35,7 +35,7 @@ private Threads() { public static void main(String[] args) { GLFWErrorCallback errorfun = GLFWErrorCallback.createPrint(); glfwSetErrorCallback(errorfun); - if ( glfwInit() != GLFW_TRUE ) + if ( !glfwInit() ) throw new IllegalStateException("Failed to initialize GLFW."); glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); @@ -51,7 +51,7 @@ public static void main(String[] args) { GLFWKeyCallback keyfun; glfwSetKeyCallback(window, keyfun = GLFWKeyCallback.create((window1, key, scancode, action, mods) -> { if ( key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE ) - glfwSetWindowShouldClose(window1, GLFW_TRUE); + glfwSetWindowShouldClose(window1, true); })); glfwSetWindowPos(window, 200 + 250 * i, 200); glfwShowWindow(window); @@ -65,7 +65,7 @@ public static void main(String[] args) { glfwWaitEvents(); for ( int i = 0; i < titles.length; i++ ) { - if ( glfwWindowShouldClose(threads[i].window) == GLFW_TRUE ) { + if ( !glfwWindowShouldClose(threads[i].window) ) { quit.countDown(); break out; } diff --git a/modules/core/src/test/java/org/lwjgl/demo/nanovg/ExampleFBO.java b/modules/core/src/test/java/org/lwjgl/demo/nanovg/ExampleFBO.java index 70ce8267bd..5eb0e1e784 100644 --- a/modules/core/src/test/java/org/lwjgl/demo/nanovg/ExampleFBO.java +++ b/modules/core/src/test/java/org/lwjgl/demo/nanovg/ExampleFBO.java @@ -109,7 +109,7 @@ public static void main(String[] args) { GLFWErrorCallback errorcb; glfwSetErrorCallback(errorcb = GLFWErrorCallback.createThrow()); - if ( glfwInit() == GLFW_FALSE ) + if ( !glfwInit() ) throw new RuntimeException("Failed to init GLFW."); GPUtimer gpuTimer = new GPUtimer(); @@ -142,7 +142,7 @@ public static void main(String[] args) { GLFWKeyCallback key; glfwSetKeyCallback(window, key = GLFWKeyCallback.create((windowHandle, keyCode, scancode, action, mods) -> { if ( keyCode == GLFW_KEY_ESCAPE && action == GLFW_PRESS ) - glfwSetWindowShouldClose(windowHandle, GL_TRUE); + glfwSetWindowShouldClose(windowHandle, true); })); glfwMakeContextCurrent(window); @@ -175,7 +175,7 @@ public static void main(String[] args) { glfwSetTime(0); double prevt = glfwGetTime(); - while ( glfwWindowShouldClose(window) == GLFW_FALSE ) { + while ( !glfwWindowShouldClose(window) ) { double t = glfwGetTime(); double dt = t - prevt; prevt = t; diff --git a/modules/core/src/test/java/org/lwjgl/demo/nanovg/ExampleGL2.java b/modules/core/src/test/java/org/lwjgl/demo/nanovg/ExampleGL2.java index bb3a5a0e28..3dff649802 100644 --- a/modules/core/src/test/java/org/lwjgl/demo/nanovg/ExampleGL2.java +++ b/modules/core/src/test/java/org/lwjgl/demo/nanovg/ExampleGL2.java @@ -53,7 +53,7 @@ public static void main(String[] args) { GLFWErrorCallback errorcb; glfwSetErrorCallback(errorcb = GLFWErrorCallback.createThrow()); - if ( glfwInit() == GLFW_FALSE ) + if ( !glfwInit() ) throw new RuntimeException("Failed to init GLFW."); DemoData data = new DemoData(); @@ -75,7 +75,7 @@ public static void main(String[] args) { GLFWKeyCallback key; glfwSetKeyCallback(window, key = GLFWKeyCallback.create((windowHandle, keyCode, scancode, action, mods) -> { if ( keyCode == GLFW_KEY_ESCAPE && action == GLFW_PRESS ) - glfwSetWindowShouldClose(windowHandle, GLFW_TRUE); + glfwSetWindowShouldClose(windowHandle, true); if ( keyCode == GLFW_KEY_SPACE && action == GLFW_PRESS ) blowup = !blowup; if ( keyCode == GLFW_KEY_S && action == GLFW_PRESS ) @@ -102,7 +102,7 @@ public static void main(String[] args) { glfwSetTime(0); double prevt = glfwGetTime(); - while ( glfwWindowShouldClose(window) == GLFW_FALSE ) { + while ( !glfwWindowShouldClose(window) ) { double t = glfwGetTime(); double dt = t - prevt; prevt = t; diff --git a/modules/core/src/test/java/org/lwjgl/demo/nanovg/ExampleGL3.java b/modules/core/src/test/java/org/lwjgl/demo/nanovg/ExampleGL3.java index cf4388db29..041443daf7 100644 --- a/modules/core/src/test/java/org/lwjgl/demo/nanovg/ExampleGL3.java +++ b/modules/core/src/test/java/org/lwjgl/demo/nanovg/ExampleGL3.java @@ -54,7 +54,7 @@ public static void main(String[] args) { GLFWErrorCallback errorcb; glfwSetErrorCallback(errorcb = GLFWErrorCallback.createThrow()); - if ( glfwInit() == GLFW_FALSE ) + if ( !glfwInit() ) throw new RuntimeException("Failed to init GLFW."); DemoData data = new DemoData(); @@ -89,7 +89,7 @@ public static void main(String[] args) { GLFWKeyCallback key; glfwSetKeyCallback(window, key = GLFWKeyCallback.create((windowHandle, keyCode, scancode, action, mods) -> { if ( keyCode == GLFW_KEY_ESCAPE && action == GLFW_PRESS ) - glfwSetWindowShouldClose(windowHandle, GLFW_TRUE); + glfwSetWindowShouldClose(windowHandle, true); if ( keyCode == GLFW_KEY_SPACE && action == GLFW_PRESS ) blowup = !blowup; if ( keyCode == GLFW_KEY_S && action == GLFW_PRESS ) @@ -119,7 +119,7 @@ public static void main(String[] args) { glfwSetTime(0); double prevt = glfwGetTime(); - while ( glfwWindowShouldClose(window) == GLFW_FALSE ) { + while ( !glfwWindowShouldClose(window) ) { double t, dt; float pxRatio; diff --git a/modules/core/src/test/java/org/lwjgl/demo/opencl/CLGLInteropDemo.java b/modules/core/src/test/java/org/lwjgl/demo/opencl/CLGLInteropDemo.java index adea7f1d06..ad55ddd0e2 100644 --- a/modules/core/src/test/java/org/lwjgl/demo/opencl/CLGLInteropDemo.java +++ b/modules/core/src/test/java/org/lwjgl/demo/opencl/CLGLInteropDemo.java @@ -86,7 +86,7 @@ public static void main(String... args) { GLFWErrorCallback errorfun; glfwSetErrorCallback(errorfun = GLFWErrorCallback.createPrint()); - if ( glfwInit() != GLFW_TRUE ) { + if ( !glfwInit() ) { System.out.println("Unable to initialize glfw"); System.exit(-1); } diff --git a/modules/core/src/test/java/org/lwjgl/demo/opencl/Mandelbrot.java b/modules/core/src/test/java/org/lwjgl/demo/opencl/Mandelbrot.java index 80e15ffd1a..50713871e6 100644 --- a/modules/core/src/test/java/org/lwjgl/demo/opencl/Mandelbrot.java +++ b/modules/core/src/test/java/org/lwjgl/demo/opencl/Mandelbrot.java @@ -392,7 +392,7 @@ public Mandelbrot(long platform, CLCapabilities platformCaps, GLFWWindow window, switch ( key ) { case GLFW_KEY_ESCAPE: - glfwSetWindowShouldClose(windowHandle, GLFW_TRUE); + glfwSetWindowShouldClose(windowHandle, true); break; case GLFW_KEY_D: events.offer(() -> { @@ -489,7 +489,7 @@ void renderLoop() { long startTime = System.currentTimeMillis() + 5000; long fps = 0; - while ( glfwWindowShouldClose(window.handle) == GLFW_FALSE ) { + while ( !glfwWindowShouldClose(window.handle) ) { Runnable event; while ( (event = events.poll()) != null ) event.run(); diff --git a/modules/core/src/test/java/org/lwjgl/demo/stb/EasyFont.java b/modules/core/src/test/java/org/lwjgl/demo/stb/EasyFont.java index c1d6922f99..ee09b9c989 100644 --- a/modules/core/src/test/java/org/lwjgl/demo/stb/EasyFont.java +++ b/modules/core/src/test/java/org/lwjgl/demo/stb/EasyFont.java @@ -43,7 +43,7 @@ protected void loop() { glClearColor(43f / 255f, 43f / 255f, 43f / 255f, 0f); // BG color glColor3f(169f / 255f, 183f / 255f, 198f / 255f); // Text color - while ( glfwWindowShouldClose(getWindow()) == GLFW_FALSE ) { + while ( !glfwWindowShouldClose(getWindow()) ) { glfwPollEvents(); glClear(GL_COLOR_BUFFER_BIT); diff --git a/modules/core/src/test/java/org/lwjgl/demo/stb/FontDemo.java b/modules/core/src/test/java/org/lwjgl/demo/stb/FontDemo.java index 68522155f7..698b6f6a3c 100644 --- a/modules/core/src/test/java/org/lwjgl/demo/stb/FontDemo.java +++ b/modules/core/src/test/java/org/lwjgl/demo/stb/FontDemo.java @@ -95,7 +95,7 @@ protected FontDemo(int fontHeight, String filePath) { switch ( key ) { case GLFW_KEY_ESCAPE: - glfwSetWindowShouldClose(windowHandle, GLFW_TRUE); + glfwSetWindowShouldClose(windowHandle, true); break; case GLFW_KEY_PAGE_UP: setLineOffset(lineOffset - wh / FontDemo.this.lineHeight); @@ -169,7 +169,7 @@ protected void run(String title) { private void init(String title) { errorfun.set(); - if ( glfwInit() != GLFW_TRUE ) + if ( !glfwInit() ) throw new IllegalStateException("Unable to initialize GLFW"); glfwDefaultWindowHints(); diff --git a/modules/core/src/test/java/org/lwjgl/demo/stb/Image.java b/modules/core/src/test/java/org/lwjgl/demo/stb/Image.java index 54bdad0f46..416644bd13 100644 --- a/modules/core/src/test/java/org/lwjgl/demo/stb/Image.java +++ b/modules/core/src/test/java/org/lwjgl/demo/stb/Image.java @@ -106,7 +106,7 @@ public void invoke(long window, int key, int scancode, int action, int mods) { switch ( key ) { case GLFW_KEY_ESCAPE: - glfwSetWindowShouldClose(window, GLFW_TRUE); + glfwSetWindowShouldClose(window, true); break; case GLFW_KEY_KP_ADD: case GLFW_KEY_EQUAL: @@ -160,7 +160,7 @@ private void run() { private void init() { errorfun.set(); - if ( glfwInit() != GLFW_TRUE ) + if ( !glfwInit() ) throw new IllegalStateException("Unable to initialize GLFW"); glfwDefaultWindowHints(); @@ -222,7 +222,7 @@ private void loop() { glEnable(GL_TEXTURE_2D); - while ( glfwWindowShouldClose(window) == GLFW_FALSE ) { + while ( !glfwWindowShouldClose(window) ) { glfwPollEvents(); glClear(GL_COLOR_BUFFER_BIT); diff --git a/modules/core/src/test/java/org/lwjgl/demo/stb/Truetype.java b/modules/core/src/test/java/org/lwjgl/demo/stb/Truetype.java index b1d0b20ae0..461c7a7023 100644 --- a/modules/core/src/test/java/org/lwjgl/demo/stb/Truetype.java +++ b/modules/core/src/test/java/org/lwjgl/demo/stb/Truetype.java @@ -72,7 +72,7 @@ protected void loop() { STBTTBakedChar.Buffer cdata = init(BITMAP_W, BITMAP_H); - while ( glfwWindowShouldClose(getWindow()) == GLFW_FALSE ) { + while ( !glfwWindowShouldClose(getWindow()) ) { glfwPollEvents(); glClear(GL_COLOR_BUFFER_BIT); diff --git a/modules/core/src/test/java/org/lwjgl/demo/stb/TruetypeOversample.java b/modules/core/src/test/java/org/lwjgl/demo/stb/TruetypeOversample.java index b98ba1214b..f4c41ac123 100644 --- a/modules/core/src/test/java/org/lwjgl/demo/stb/TruetypeOversample.java +++ b/modules/core/src/test/java/org/lwjgl/demo/stb/TruetypeOversample.java @@ -115,7 +115,7 @@ public void invoke(long window, int key, int scancode, int action, int mods) { switch ( key ) { case GLFW_KEY_ESCAPE: - glfwSetWindowShouldClose(window, GLFW_TRUE); + glfwSetWindowShouldClose(window, true); break; case GLFW_KEY_O: font = (font + 1) % 3 + (font / 3) * 3; @@ -337,7 +337,7 @@ private void loopmode(float dt) { private void createWindow(String title) { glfwSetErrorCallback(errorfun); - if ( glfwInit() != GLFW_TRUE ) + if ( !glfwInit() ) throw new IllegalStateException("Unable to initialize GLFW"); glfwDefaultWindowHints(); @@ -381,7 +381,7 @@ private void run(String title) { load_fonts(); long time = System.nanoTime(); - while ( glfwWindowShouldClose(window) == GLFW_FALSE ) { + while ( !glfwWindowShouldClose(window) ) { glfwPollEvents(); long t = System.nanoTime(); diff --git a/modules/core/src/test/java/org/lwjgl/demo/stb/Vorbis.java b/modules/core/src/test/java/org/lwjgl/demo/stb/Vorbis.java index 7c2ea81d4f..37ee68ad06 100644 --- a/modules/core/src/test/java/org/lwjgl/demo/stb/Vorbis.java +++ b/modules/core/src/test/java/org/lwjgl/demo/stb/Vorbis.java @@ -75,13 +75,13 @@ public static void main(String[] args) { if ( !decoder.play(source, buffers) ) { System.err.println("Playback failed."); - glfwSetWindowShouldClose(window, GLFW_TRUE); + glfwSetWindowShouldClose(window, true); } - while ( glfwWindowShouldClose(window) == GLFW_FALSE ) { + while ( !glfwWindowShouldClose(window) ) { if ( !renderer.paused && !decoder.update(source, true) ) { System.err.println("Playback failed."); - glfwSetWindowShouldClose(window, GLFW_TRUE); + glfwSetWindowShouldClose(window, true); } float progress = decoder.getProgress(); @@ -292,7 +292,7 @@ private static class Renderer { Renderer(Decoder decoder, String title) { errorCallback = GLFWErrorCallback.createPrint().set(); - if ( glfwInit() != GLFW_TRUE ) + if ( !glfwInit() ) throw new IllegalStateException("Unable to initialize GLFW"); glfwDefaultWindowHints(); @@ -318,7 +318,7 @@ public void invoke(long window, int key, int scancode, int action, int mods) { switch ( key ) { case GLFW_KEY_ESCAPE: - glfwSetWindowShouldClose(window, GLFW_TRUE); + glfwSetWindowShouldClose(window, true); break; case GLFW_KEY_HOME: decoder.rewind(); diff --git a/modules/core/src/test/java/org/lwjgl/demo/system/jawt/LWJGLCanvas.java b/modules/core/src/test/java/org/lwjgl/demo/system/jawt/LWJGLCanvas.java index 18d247f1f5..32c2e6b0ca 100644 --- a/modules/core/src/test/java/org/lwjgl/demo/system/jawt/LWJGLCanvas.java +++ b/modules/core/src/test/java/org/lwjgl/demo/system/jawt/LWJGLCanvas.java @@ -75,7 +75,7 @@ public void paint(Graphics g) { createContext(dsi_win); gears.initGLState(); } else { - if ( wglMakeCurrent(hdc, hglrc) == 0 ) + if ( !wglMakeCurrent(hdc, hglrc) ) throw new IllegalStateException("wglMakeCurrent() failed"); GL.setCapabilities(caps); @@ -129,7 +129,7 @@ private void createContext(JAWTWin32DrawingSurfaceInfo dsi_win) { if ( pixelFormat < 1 ) throw new IllegalStateException("ChoosePixelFormat() failed: " + WinBase.getLastError()); - if ( SetPixelFormat(hdc, pixelFormat, null) == 0 ) + if ( !SetPixelFormat(hdc, pixelFormat, null) ) throw new IllegalStateException("SetPixelFormat() failed: " + WinBase.getLastError()); } @@ -138,7 +138,7 @@ private void createContext(JAWTWin32DrawingSurfaceInfo dsi_win) { if ( hglrc == NULL ) throw new IllegalStateException("wglCreateContext() failed"); - if ( wglMakeCurrent(hdc, hglrc) == 0 ) + if ( !wglMakeCurrent(hdc, hglrc) ) throw new IllegalStateException("wglMakeCurrent() failed"); caps = GL.createCapabilities(); diff --git a/modules/core/src/test/java/org/lwjgl/demo/util/nfd/HelloNFD.java b/modules/core/src/test/java/org/lwjgl/demo/util/nfd/HelloNFD.java index 84cba24c43..415fbcdf07 100644 --- a/modules/core/src/test/java/org/lwjgl/demo/util/nfd/HelloNFD.java +++ b/modules/core/src/test/java/org/lwjgl/demo/util/nfd/HelloNFD.java @@ -42,7 +42,7 @@ public void invoke(long window, int key, int scancode, int action, int mods) { switch ( key ) { case GLFW_KEY_ESCAPE: - glfwSetWindowShouldClose(window, GLFW_TRUE); + glfwSetWindowShouldClose(window, true); break; case GLFW_KEY_O: if ( (mods & mod) != 0 ) { @@ -61,7 +61,7 @@ public void invoke(long window, int key, int scancode, int action, int mods) { }; errorfun.set(); - if ( glfwInit() != GLFW_TRUE ) + if ( !glfwInit() ) throw new IllegalStateException("Unable to initialize GLFW"); long window = glfwCreateWindow(300, 300, "Hello NativeFileDialog!", NULL, NULL); @@ -86,7 +86,7 @@ public void invoke(long window, int key, int scancode, int action, int mods) { System.out.println("Press " + modDescr + "+O to launch the single file open dialog."); System.out.println("Press " + modDescr + "+Shift+O to launch the multi file open dialog."); System.out.println("Press " + modDescr + "+S to launch the file save dialog."); - while ( glfwWindowShouldClose(window) == GLFW_FALSE ) { + while ( !glfwWindowShouldClose(window) ) { glfwPollEvents(); glClear(GL_COLOR_BUFFER_BIT); diff --git a/modules/core/src/test/java/org/lwjgl/demo/util/par/ParShapesDemo.java b/modules/core/src/test/java/org/lwjgl/demo/util/par/ParShapesDemo.java index e12b9544f4..8edc278deb 100644 --- a/modules/core/src/test/java/org/lwjgl/demo/util/par/ParShapesDemo.java +++ b/modules/core/src/test/java/org/lwjgl/demo/util/par/ParShapesDemo.java @@ -131,7 +131,7 @@ public void invoke(long window, int key, int scancode, int action, int mods) { updateHUD(mesh == null); break; case GLFW_KEY_ESCAPE: - glfwSetWindowShouldClose(window, GLFW_TRUE); + glfwSetWindowShouldClose(window, true); break; } } @@ -155,7 +155,7 @@ public void invoke(long window, int width, int height) { private void init() { errorCB.set(); - if ( glfwInit() != GLFW_TRUE ) + if ( !glfwInit() ) throw new IllegalStateException("Unable to initialize GLFW"); glfwDefaultWindowHints(); @@ -484,7 +484,7 @@ private void cleanup() { private void run() { init(); - while ( glfwWindowShouldClose(window) == GLFW_FALSE ) { + while ( !glfwWindowShouldClose(window) ) { glfwPollEvents(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); diff --git a/modules/core/src/test/java/org/lwjgl/demo/vulkan/HelloVulkan.java b/modules/core/src/test/java/org/lwjgl/demo/vulkan/HelloVulkan.java index 3f793122da..848df0a970 100644 --- a/modules/core/src/test/java/org/lwjgl/demo/vulkan/HelloVulkan.java +++ b/modules/core/src/test/java/org/lwjgl/demo/vulkan/HelloVulkan.java @@ -311,10 +311,10 @@ private static void check(int errcode) { private void demo_init_connection() { errorCB = GLFWErrorCallback.createPrint().set(); - if ( glfwInit() != GLFW_TRUE ) + if ( !glfwInit() ) throw new IllegalStateException("Unable to initialize GLFW"); - if ( glfwVulkanSupported() != GLFW_TRUE ) + if ( !glfwVulkanSupported() ) throw new IllegalStateException("Cannot find a compatible Vulkan installable client driver (ICD)"); } @@ -544,7 +544,7 @@ private void demo_init() { @Override public void invoke(long window, int key, int scancode, int action, int mods) { if ( key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE ) - glfwSetWindowShouldClose(window, GLFW_TRUE); + glfwSetWindowShouldClose(window, true); } }; @@ -1937,7 +1937,7 @@ private void demo_resize() { private void demo_run() { int c = 0; long t = System.nanoTime(); - while ( glfwWindowShouldClose(window) == GLFW_FALSE ) { + while ( !glfwWindowShouldClose(window) ) { glfwPollEvents(); demo_draw(); diff --git a/modules/templates/src/main/kotlin/org/lwjgl/generator/CallbackFunction.kt b/modules/templates/src/main/kotlin/org/lwjgl/generator/CallbackFunction.kt index b14a99271e..d5fbb4589f 100644 --- a/modules/templates/src/main/kotlin/org/lwjgl/generator/CallbackFunction.kt +++ b/modules/templates/src/main/kotlin/org/lwjgl/generator/CallbackFunction.kt @@ -22,7 +22,7 @@ class CallbackFunction( } private val signatureJava: String = signature.asSequence().map { - "${it.nativeMethodType} ${it.name}" + "${if ( it.nativeType.mapping == PrimitiveMapping.BOOLEAN4 ) "boolean" else it.nativeMethodType} ${it.name}" }.joinToString(", ") val NativeType.dyncall: Char @@ -32,6 +32,7 @@ class CallbackFunction( PrimitiveMapping.BOOLEAN -> 'B' PrimitiveMapping.BYTE -> 'c' PrimitiveMapping.SHORT -> 's' + PrimitiveMapping.BOOLEAN4, PrimitiveMapping.INT -> 'i' PrimitiveMapping.LONG -> 'l' PrimitiveMapping.POINTER -> 'p' @@ -86,7 +87,11 @@ ${access.modifier}abstract class $className extends Callback.${returns.mapping.j print("return ") print("""invoke( ${signature.asSequence().withIndex().map { - "\t\t\tdcbArg${it.value.nativeType.argType}(args)${if ( it.value.nativeType.mapping == PrimitiveMapping.BOOLEAN ) " != 0" else ""}" + "\t\t\tdcbArg${it.value.nativeType.argType}(args)${when ( it.value.nativeType.mapping ) { + PrimitiveMapping.BOOLEAN, + PrimitiveMapping.BOOLEAN4 -> " != 0" + else -> "" + }}" }.joinToString(",\n")} ); } diff --git a/modules/templates/src/main/kotlin/org/lwjgl/generator/Functions.kt b/modules/templates/src/main/kotlin/org/lwjgl/generator/Functions.kt index 24a974d7af..06cf5eea5b 100644 --- a/modules/templates/src/main/kotlin/org/lwjgl/generator/Functions.kt +++ b/modules/templates/src/main/kotlin/org/lwjgl/generator/Functions.kt @@ -832,6 +832,8 @@ class NativeClassFunction( } print(")") } + if ( returns.nativeType.mapping == PrimitiveMapping.BOOLEAN4 ) + print(" != 0") println(";") } diff --git a/modules/templates/src/main/kotlin/org/lwjgl/generator/Parameters.kt b/modules/templates/src/main/kotlin/org/lwjgl/generator/Parameters.kt index dbac3b54e6..638d6ebbc1 100644 --- a/modules/templates/src/main/kotlin/org/lwjgl/generator/Parameters.kt +++ b/modules/templates/src/main/kotlin/org/lwjgl/generator/Parameters.kt @@ -24,6 +24,8 @@ abstract class QualifiedType( nativeType is StructType -> nativeType.definition.className nativeType.mapping === PointerMapping.DATA -> "ByteBuffer" + nativeType.mapping === PrimitiveMapping.BOOLEAN4 + -> "boolean" else -> nativeType.javaMethodType.simpleName } @@ -108,26 +110,20 @@ class Parameter( get() = "$nativeMethodType $name" fun asNativeMethodCallParam(func: NativeClassFunction, mode: GenerationMode) = when { - // Object parameter - nativeType is StructType || nativeType is ObjectType - -> + nativeType is StructType || nativeType is ObjectType -> if ( has(nullable) ) "$name == null ? NULL : $name.$ADDRESS" else if ( nativeType is ObjectType && func.hasUnsafeMethod && func.nativeClass.binding!!.hasParameterCapabilities ) name else "$name.$ADDRESS" - - // Data pointer - nativeType.isPointerData -> { + nativeType.isPointerData -> if ( !isAutoSizeResultOut && (has(nullable) || (has(optional) && mode === GenerationMode.NORMAL)) ) "memAddressSafe($name)" else "memAddress($name)" - } - - // Normal parameter - else -> name + nativeType.mapping == PrimitiveMapping.BOOLEAN4 -> "$name ? 1 : 0" + else -> name } } diff --git a/modules/templates/src/main/kotlin/org/lwjgl/generator/Types.kt b/modules/templates/src/main/kotlin/org/lwjgl/generator/Types.kt index c75641c10f..e4522a7f1b 100644 --- a/modules/templates/src/main/kotlin/org/lwjgl/generator/Types.kt +++ b/modules/templates/src/main/kotlin/org/lwjgl/generator/Types.kt @@ -216,6 +216,7 @@ open class PrimitiveMapping( companion object { val BOOLEAN = PrimitiveMapping("jboolean", Boolean::class, 1, PointerMapping.DATA_BOOLEAN) + val BOOLEAN4 = PrimitiveMapping("jint", Int::class, 4, PointerMapping.DATA_INT) val BYTE = PrimitiveMapping("jbyte", Byte::class, 1, PointerMapping.DATA_BYTE) val SHORT = PrimitiveMapping("jshort", Short::class, 2, PointerMapping.DATA_SHORT) diff --git a/modules/templates/src/main/kotlin/org/lwjgl/glfw/GLFWTypes.kt b/modules/templates/src/main/kotlin/org/lwjgl/glfw/GLFWTypes.kt index 61dccf2579..4492e27470 100644 --- a/modules/templates/src/main/kotlin/org/lwjgl/glfw/GLFWTypes.kt +++ b/modules/templates/src/main/kotlin/org/lwjgl/glfw/GLFWTypes.kt @@ -28,6 +28,8 @@ fun config() { val GLFW_BINDING = simpleBinding("glfw", """Configuration.GLFW_LIBRARY_NAME.get(Pointer.BITS64 ? "glfw" : "glfw32")""") val GLFW_BINDING_DELEGATE = GLFW_BINDING.delegate("GLFW.getLibrary()") +val GLFWboolean = PrimitiveType("int", PrimitiveMapping.BOOLEAN4) // This type does not exist in GLFW. + val GLFWmonitor = "GLFWmonitor".p val GLFWmonitor_p = GLFWmonitor.p @@ -300,7 +302,7 @@ val GLFWwindowfocusfun = "GLFWwindowfocusfun".callback( GLFW_PACKAGE, void, "GLFWWindowFocusCallback", "Will be called when the specified window gains or loses focus.", GLFWwindow.IN("window", "the window that was focused or defocused"), - int.IN("focused", "GL11##GL_TRUE if the window was focused, or GL11##GL_FALSE if it was defocused") + GLFWboolean.IN("focused", "GL11##GL_TRUE if the window was focused, or GL11##GL_FALSE if it was defocused") ) { javaImport("org.lwjgl.opengl.GL11") documentation = "Instances of this interface may be passed to the #SetWindowFocusCallback() method." @@ -318,7 +320,7 @@ val GLFWwindowiconifyfun = "GLFWwindowiconifyfun".callback( GLFW_PACKAGE, void, "GLFWWindowIconifyCallback", "Will be called when the specified window is iconified or restored.", GLFWwindow.IN("window", "the window that was iconified or restored."), - int.IN("iconified", "GL11#GL_TRUE if the window was iconified, or GL11#GL_FALSE if it was restored") + GLFWboolean.IN("iconified", "GL11#GL_TRUE if the window was iconified, or GL11#GL_FALSE if it was restored") ) { javaImport("org.lwjgl.opengl.GL11") documentation = "Instances of this interface may be passed to the #SetWindowIconifyCallback() method." @@ -451,7 +453,7 @@ val GLFWcursorenterfun = "GLFWcursorenterfun".callback( GLFW_PACKAGE, void, "GLFWCursorEnterCallback", "Will be called when the cursor enters or leaves the client area of the window.", GLFWwindow.IN("window", "the window that received the event"), - int.IN("entered", "GL11##GL_TRUE if the cursor entered the window's client area, or GL11##GL_FALSE if it left it") + GLFWboolean.IN("entered", "GL11##GL_TRUE if the cursor entered the window's client area, or GL11##GL_FALSE if it left it") ) { javaImport("org.lwjgl.opengl.GL11") documentation = "Instances of this interface may be passed to the #SetCursorEnterCallback() method." diff --git a/modules/templates/src/main/kotlin/org/lwjgl/glfw/templates/GLFW.kt b/modules/templates/src/main/kotlin/org/lwjgl/glfw/templates/GLFW.kt index 43b027dbb3..67aaa88c46 100644 --- a/modules/templates/src/main/kotlin/org/lwjgl/glfw/templates/GLFW.kt +++ b/modules/templates/src/main/kotlin/org/lwjgl/glfw/templates/GLFW.kt @@ -548,7 +548,7 @@ val GLFW = "GLFW".nativeClass(packageName = GLFW_PACKAGE, prefix = "GLFW", bindi "RELEASE_BEHAVIOR_NONE"..0x00035002 ).javaDocLinks - int( + GLFWboolean( "Init", """ Initializes the GLFW library. Before most GLFW functions can be used, GLFW must be initialized, and before an application terminates GLFW should be @@ -1026,7 +1026,7 @@ val GLFW = "GLFW".nativeClass(packageName = GLFW_PACKAGE, prefix = "GLFW", bindi since = "version 1.0" ) - int( + GLFWboolean( "WindowShouldClose", """ Returns the value of the close flag of the specified window. @@ -1050,7 +1050,7 @@ val GLFW = "GLFW".nativeClass(packageName = GLFW_PACKAGE, prefix = "GLFW", bindi """, GLFWwindow.IN("window", "the window whose flag to change"), - int.IN("value", "the new value"), + GLFWboolean.IN("value", "the new value"), since = "version 3.0" ) @@ -2402,7 +2402,7 @@ val GLFW = "GLFW".nativeClass(packageName = GLFW_PACKAGE, prefix = "GLFW", bindi since = "version 1.0" ) - int( + GLFWboolean( "ExtensionSupported", """ Returns whether the specified API extension is supported by the current diff --git a/modules/templates/src/main/kotlin/org/lwjgl/glfw/templates/GLFWVulkan.kt b/modules/templates/src/main/kotlin/org/lwjgl/glfw/templates/GLFWVulkan.kt index 5564979147..46761d13dc 100644 --- a/modules/templates/src/main/kotlin/org/lwjgl/glfw/templates/GLFWVulkan.kt +++ b/modules/templates/src/main/kotlin/org/lwjgl/glfw/templates/GLFWVulkan.kt @@ -15,7 +15,7 @@ val GLFWVulkan = dependsOn(Binding.VULKAN) { documentation = "Native bindings to the GLFW library's Vulkan functions." - int( + GLFWboolean( "VulkanSupported", """ Returns whether the Vulkan loader has been found. This check is performed by GLFW#Init(). @@ -97,7 +97,7 @@ val GLFWVulkan = dependsOn(Binding.VULKAN) { since = "version 3.2" ) - int( + GLFWboolean( "GetPhysicalDevicePresentationSupport", """ Returns whether the specified queue family of the specified physical device supports presentation to the platform GLFW was built for. diff --git a/modules/templates/src/main/kotlin/org/lwjgl/system/windows/WindowsTypes.kt b/modules/templates/src/main/kotlin/org/lwjgl/system/windows/WindowsTypes.kt index daef7be340..d1a498750b 100644 --- a/modules/templates/src/main/kotlin/org/lwjgl/system/windows/WindowsTypes.kt +++ b/modules/templates/src/main/kotlin/org/lwjgl/system/windows/WindowsTypes.kt @@ -24,7 +24,7 @@ val VOID = NativeType("VOID", TypeMapping.VOID) val HANDLE = "HANDLE".opaque_p val HANDLE_p = HANDLE.p -val BOOL = PrimitiveType("BOOL", PrimitiveMapping.INT) +val BOOL = PrimitiveType("BOOL", PrimitiveMapping.BOOLEAN4) val BYTE = IntegerType("BYTE", PrimitiveMapping.BYTE) val WORD = IntegerType("WORD", PrimitiveMapping.SHORT) val SHORT = IntegerType("SHORT", PrimitiveMapping.SHORT)