Skip to content

Commit

Permalink
Map integer-boolean native types to boolean. Close #181
Browse files Browse the repository at this point in the history
  • Loading branch information
Spasi committed Apr 18, 2016
1 parent 9327197 commit 2196a26
Show file tree
Hide file tree
Showing 29 changed files with 86 additions and 80 deletions.
2 changes: 1 addition & 1 deletion modules/core/src/main/java/org/lwjgl/opengl/GL.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down
12 changes: 6 additions & 6 deletions modules/core/src/test/java/org/lwjgl/demo/glfw/Events.java
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand All @@ -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");
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions modules/core/src/test/java/org/lwjgl/demo/glfw/Gears.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 ) {
Expand Down Expand Up @@ -144,7 +144,7 @@ private void loop() {
long lastUpdate = System.currentTimeMillis();
int frames = 0;

while ( glfwWindowShouldClose(window) == GLFW_FALSE ) {
while ( !glfwWindowShouldClose(window) ) {
glfwPollEvents();

renderLoop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}
});
Expand Down Expand Up @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions modules/core/src/test/java/org/lwjgl/demo/glfw/Threads.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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 )
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(() -> {
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions modules/core/src/test/java/org/lwjgl/demo/stb/FontDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions modules/core/src/test/java/org/lwjgl/demo/stb/Image.java
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
10 changes: 5 additions & 5 deletions modules/core/src/test/java/org/lwjgl/demo/stb/Vorbis.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down
Loading

0 comments on commit 2196a26

Please sign in to comment.