From 85130ebd90634008b70453a3211ef95814133617 Mon Sep 17 00:00:00 2001 From: Caspian Rychlik-Prince Date: Sun, 4 Apr 2004 12:53:45 +0000 Subject: [PATCH] Rules with mighty fist. New API killed off before it even sees light of day. Some refactoring. --- src/java/org/lwjgl/opengl/Window.java | 232 ++++++------------ .../org/lwjgl/test/input/ControllerTest.java | 2 +- .../org/lwjgl/test/input/HWCursorTest.java | 2 +- .../org/lwjgl/test/input/KeyboardTest.java | 2 +- src/java/org/lwjgl/test/input/MouseTest.java | 2 +- .../org/lwjgl/test/openal/PositionTest.java | 4 +- .../lwjgl/test/opengl/BouncingWindowTest.java | 109 -------- .../test/opengl/FullScreenWindowedTest.java | 2 +- src/java/org/lwjgl/test/opengl/Game.java | 2 +- src/java/org/lwjgl/test/opengl/Grass.java | 2 +- .../org/lwjgl/test/opengl/PbufferTest.java | 2 +- .../org/lwjgl/test/opengl/VBOIndexTest.java | 2 +- src/java/org/lwjgl/test/opengl/VBOTest.java | 2 +- .../test/opengl/shaders/ShadersTest.java | 2 +- src/native/common/org_lwjgl_opengl_Window.h | 30 +-- src/native/linux/org_lwjgl_opengl_Window.cpp | 41 +--- src/native/win32/org_lwjgl_opengl_Window.cpp | 43 +--- 17 files changed, 113 insertions(+), 368 deletions(-) delete mode 100644 src/java/org/lwjgl/test/opengl/BouncingWindowTest.java diff --git a/src/java/org/lwjgl/opengl/Window.java b/src/java/org/lwjgl/opengl/Window.java index aa28140a..10febfc1 100644 --- a/src/java/org/lwjgl/opengl/Window.java +++ b/src/java/org/lwjgl/opengl/Window.java @@ -36,9 +36,6 @@ package org.lwjgl.opengl; * This is the abstract class for a Window in LWJGL. LWJGL windows have some * peculiar characteristics: * - * - width and height are always fixed and cannot be changed - * - the position of the window may or may not be programmable but once specified - * cannot be changed programmatically * - the window may be closeable by the user or operating system, and may be minimized * by the user or operating system * - only one window may ever be open at once @@ -81,9 +78,6 @@ public final class Window { /** Fullscreen */ private static boolean fullscreen; - /** Undecorated */ - private static boolean undecorated; - /** Tracks VBO state for the window context */ private static VBOTracker vbo_tracker; @@ -188,43 +182,26 @@ public final class Window { private static native boolean nIsCloseRequested(); /** - * @return true if the window is minimized or otherwise not visible + * @return true if the window is visible, false if not */ - public static boolean isMinimized() { + public static boolean isVisible() { if (!isCreated()) throw new IllegalStateException("Cannot determine minimized state of uncreated window"); - return nIsMinimized(); + return nIsVisible(); } - private static native boolean nIsMinimized(); + private static native boolean nIsVisible(); /** - * @return true if window is focused + * @return true if window is active, that is, the foreground display of the operating system. */ - public static boolean isFocused() { + public static boolean isActive() { if (!isCreated()) throw new IllegalStateException("Cannot determine focused state of uncreated window"); - return nIsFocused(); + return nIsActive(); } - private static native boolean nIsFocused(); - - /** - * Minimize the game and allow the operating system's default display to become - * visible. It is the responsibility of LWJGL's native code to restore the display - * to its normal display settings. - * - * If the display is already minimized then this is a no-op. - */ - public static native void minimize(); - - /** - * Restore the game and hide the operating system away. It is the responsibility of - * LWJGL's native code to restore the display to its game display settings. - * - * If the display is not minimized then this is a no-op/ - */ - public static native void restore(); + private static native boolean nIsActive(); /** * Determine if the window's contents have been damaged by external events. @@ -253,7 +230,7 @@ public final class Window { if (!isCreated()) throw new IllegalStateException("Cannot update uncreated window"); nUpdate(); - if ((isDirty() && !isMinimized()) || (isFocused() && !isMinimized())) { + if ((isDirty() && isVisible()) || (isActive() && isVisible())) { Util.checkGLError(); swapBuffers(); } @@ -347,7 +324,6 @@ public final class Window { if (isCreated()) throw new IllegalStateException("Only one LWJGL window may be instantiated at any one time."); Window.fullscreen = true; - Window.undecorated = true; Window.x = 0; Window.y = 0; Window.width = Display.getWidth(); @@ -374,31 +350,9 @@ public final class Window { * the minimum requirements could not be met satisfactorily */ public static void create(String title, int x, int y, int width, int height, int bpp, int alpha, int depth, int stencil) throws LWJGLException { - create(title, x, y, width, height, false, bpp, alpha, depth, stencil); + create(title, x, y, width, height, bpp, alpha, depth, stencil); } - /** - * Create a window. If the underlying OS does not have "floating" windows, then a fullscreen - * display will be created instead. If this fails too then an LWJGLException will be thrown. - * If the window is created fullscreen, then its size may not match the specified size - * here. - *

The window created will be set up in orthographic 2D projection, with 1:1 pixel ratio with GL coordinates. - * @param title The title of the window - * @param x The position of the window on the x axis. May be ignored. - * @param y The position of the window on the y axis. May be ignored. - * @param width The width of the window's client area - * @param height The height of the window's client area - * @param undecorated A hint to specify that the window should not have OS decorations such as drag bar and close box - * @param bpp Minimum bits per pixel - * @param alpha Minimum bits per pixel in alpha buffer - * @param depth Minimum bits per pixel in depth buffer - * @throws LWJGLException if the window could not be created for any reason; typically because - * the minimum requirements could not be met satisfactorily - */ - public static void create(String title, int x, int y, int width, int height, boolean undecorated, int bpp, int alpha, int depth, int stencil) throws LWJGLException { - create(title, x, y, width, height, undecorated, bpp, alpha, depth, stencil, 0); - } - /** * Create a window. If the underlying OS does not have "floating" windows, then a fullscreen * display will be created instead. If this fails too then an LWJGLException will be thrown. @@ -422,42 +376,7 @@ public final class Window { public static void create(String title, int x, int y, int width, int height, int bpp, int alpha, int depth, int stencil, int samples) throws LWJGLException { - create(title, x, y, width, height, false, bpp, alpha, depth, stencil, samples); - } - - /** - * Create a window. If the underlying OS does not have "floating" windows, then a fullscreen - * display will be created instead. If this fails too then an LWJGLException will be thrown. - * If the window is created fullscreen, then its size may not match the specified size - * here. - *

The window created will be set up in orthographic 2D projection, with 1:1 pixel ratio with GL coordinates. - * @param title The title of the window - * @param x The position of the window on the x axis. May be ignored. - * @param y The position of the window on the y axis. May be ignored. - * @param width The width of the window's client area - * @param height The height of the window's client area - * @param undecorated A hint to specify that the window should not have OS decorations such as drag bar and close box - * @param bpp Minimum bits per pixel - * @param alpha Minimum bits per pixel in alpha buffer - * @param depth Minimum bits per pixel in depth buffer - * @param stencil Minimum bits per pixel in stencil buffer - * @param samples Minimum samples in multisample buffer (corresponds to GL_SAMPLES_ARB in GL_ARB_multisample spec). - Pass 0 to disable multisampling. This parameter is ignored if GL_ARB_multisample is not supported. - * @throws LWJGLException if the window could not be created for any reason; typically because - * the minimum requirements could not be met satisfactorily - */ - public static void create(String title, int x, int y, int width, int height, boolean undecorated, int bpp, int alpha, int depth, int stencil, int samples) - throws LWJGLException { - if (isCreated()) - throw new IllegalStateException("Only one LWJGL window may be instantiated at any one time."); - Window.fullscreen = false; - Window.undecorated = undecorated; - Window.x = x; - Window.y = y; - Window.width = width; - Window.height = height; - Window.title = title; - createWindow(bpp, alpha, depth, stencil, samples); + create(title, x, y, width, height, bpp, alpha, depth, stencil, samples); } /** @@ -471,7 +390,6 @@ public final class Window { int width, int height, boolean fullscreen, - boolean undecorated, int bpp, int alpha, int depth, @@ -480,7 +398,7 @@ public final class Window { throws LWJGLException; private static void createWindow(int bpp, int alpha, int depth, int stencil, int samples) throws LWJGLException { - nCreate(title, x, y, width, height, fullscreen, undecorated, bpp, alpha, depth, stencil, samples); + nCreate(title, x, y, width, height, fullscreen, bpp, alpha, depth, stencil, samples); context = new Window(); makeCurrent(); @@ -621,68 +539,68 @@ public final class Window { private static native void nSetVSyncEnabled(boolean sync); - /** - * Set the window's location. This is a no-op on fullscreen windows. - * The window is clamped to remain entirely on the screen. If you attempt - * to position the window such that it would extend off the screen, the window - * is simply placed as close to the edge as possible. - * @param x, y The new window location - */ - public static void setLocation(int x, int y) { - if (!isCreated()) - throw new IllegalStateException("Cannot move uncreated window"); - if (fullscreen) { - return; - } - Window.x = Math.max(0, Math.min(Display.getWidth() - Window.width, x)); - Window.y = Math.max(0, Math.min(Display.getHeight() - Window.height, y)); - nReshape(Window.x, Window.y, Window.width, Window.height); - } - - /** - * Set the window's size. This is a no-op on fullscreen windows. - * The window is clamped to remain entirely on the screen. If you attempt - * to position the window such that it would extend off the screen, the window - * is simply placed as close to the edge as possible. - * @param width, height The new window dimensions - */ - public static void setSize(int width, int height) { - if (!isCreated()) - throw new IllegalStateException("Cannot resize uncreated window"); - if (fullscreen) { - return; - } - Window.width = Math.max(0, Math.min(Display.getWidth() - Window.x, width)); - Window.height = Math.max(0, Math.min(Display.getHeight() - Window.y, height)); - nReshape(Window.x, Window.y, Window.width, Window.height); - } - - /** - * Set the window's bounds. This is a no-op on fullscreen windows. - * The window is clamped to remain entirely on the screen. - * @param x, y The new window location - * @param width, height The new window dimensions - */ - public static void setBounds(int x, int y, int width, int height) { - if (!isCreated()) - throw new IllegalStateException("Cannot reshape uncreated window"); - if (fullscreen) { - return; - } - width = Math.max(0, Math.min(Display.getWidth(), width)); - height = Math.max(0, Math.min(Display.getHeight(), height)); - Window.x = Math.max(0, Math.min(Display.getWidth() - width, x)); - Window.y = Math.max(0, Math.min(Display.getHeight() - height, y)); - Window.width = Math.max(0, Math.min(Display.getWidth() - Window.x, width)); - Window.height = Math.max(0, Math.min(Display.getHeight() - Window.y, height)); - nReshape(Window.x, Window.y, Window.width, Window.height); - } - - /** - * Native method to reshape the window - * @param x, y The new window location - * @param width, height The new window dimensions - */ - private static native void nReshape(int x, int y, int width, int height); +// /** +// * Set the window's location. This is a no-op on fullscreen windows. +// * The window is clamped to remain entirely on the screen. If you attempt +// * to position the window such that it would extend off the screen, the window +// * is simply placed as close to the edge as possible. +// * @param x, y The new window location +// */ +// public static void setLocation(int x, int y) { +// if (!isCreated()) +// throw new IllegalStateException("Cannot move uncreated window"); +// if (fullscreen) { +// return; +// } +// Window.x = Math.max(0, Math.min(Display.getWidth() - Window.width, x)); +// Window.y = Math.max(0, Math.min(Display.getHeight() - Window.height, y)); +// nReshape(Window.x, Window.y, Window.width, Window.height); +// } +// +// /** +// * Set the window's size. This is a no-op on fullscreen windows. +// * The window is clamped to remain entirely on the screen. If you attempt +// * to position the window such that it would extend off the screen, the window +// * is simply placed as close to the edge as possible. +// * @param width, height The new window dimensions +// */ +// public static void setSize(int width, int height) { +// if (!isCreated()) +// throw new IllegalStateException("Cannot resize uncreated window"); +// if (fullscreen) { +// return; +// } +// Window.width = Math.max(0, Math.min(Display.getWidth() - Window.x, width)); +// Window.height = Math.max(0, Math.min(Display.getHeight() - Window.y, height)); +// nReshape(Window.x, Window.y, Window.width, Window.height); +// } +// +// /** +// * Set the window's bounds. This is a no-op on fullscreen windows. +// * The window is clamped to remain entirely on the screen. +// * @param x, y The new window location +// * @param width, height The new window dimensions +// */ +// public static void setBounds(int x, int y, int width, int height) { +// if (!isCreated()) +// throw new IllegalStateException("Cannot reshape uncreated window"); +// if (fullscreen) { +// return; +// } +// width = Math.max(0, Math.min(Display.getWidth(), width)); +// height = Math.max(0, Math.min(Display.getHeight(), height)); +// Window.x = Math.max(0, Math.min(Display.getWidth() - width, x)); +// Window.y = Math.max(0, Math.min(Display.getHeight() - height, y)); +// Window.width = Math.max(0, Math.min(Display.getWidth() - Window.x, width)); +// Window.height = Math.max(0, Math.min(Display.getHeight() - Window.y, height)); +// nReshape(Window.x, Window.y, Window.width, Window.height); +// } +// +// /** +// * Native method to reshape the window +// * @param x, y The new window location +// * @param width, height The new window dimensions +// */ +// private static native void nReshape(int x, int y, int width, int height); } diff --git a/src/java/org/lwjgl/test/input/ControllerTest.java b/src/java/org/lwjgl/test/input/ControllerTest.java index c10729d0..30fd1db4 100644 --- a/src/java/org/lwjgl/test/input/ControllerTest.java +++ b/src/java/org/lwjgl/test/input/ControllerTest.java @@ -161,7 +161,7 @@ public class ControllerTest { // pause and continue if minimized - if(Window.isMinimized()) { + if(!Window.isVisible()) { pause(100); render(); continue; diff --git a/src/java/org/lwjgl/test/input/HWCursorTest.java b/src/java/org/lwjgl/test/input/HWCursorTest.java index 5b1236ca..8a5e87f8 100644 --- a/src/java/org/lwjgl/test/input/HWCursorTest.java +++ b/src/java/org/lwjgl/test/input/HWCursorTest.java @@ -211,7 +211,7 @@ public class HWCursorTest { // allow subsystem to get a chance to run too Window.update(); - if (!Window.isMinimized()) { + if (Window.isVisible()) { // check keyboard input processKeyboard(); diff --git a/src/java/org/lwjgl/test/input/KeyboardTest.java b/src/java/org/lwjgl/test/input/KeyboardTest.java index 814ead2e..935a02b7 100644 --- a/src/java/org/lwjgl/test/input/KeyboardTest.java +++ b/src/java/org/lwjgl/test/input/KeyboardTest.java @@ -117,7 +117,7 @@ public class KeyboardTest { while (!Window.isCloseRequested()) { Window.update(); - if (Window.isMinimized()) { + if (!Window.isVisible()) { try { Thread.sleep(100); } catch (InterruptedException inte) { diff --git a/src/java/org/lwjgl/test/input/MouseTest.java b/src/java/org/lwjgl/test/input/MouseTest.java index 577ae069..2f5b9e4b 100644 --- a/src/java/org/lwjgl/test/input/MouseTest.java +++ b/src/java/org/lwjgl/test/input/MouseTest.java @@ -173,7 +173,7 @@ public class MouseTest { // pause and continue if minimized - if(Window.isMinimized()) { + if(!Window.isVisible()) { if(Window.isDirty()) { render(); } diff --git a/src/java/org/lwjgl/test/openal/PositionTest.java b/src/java/org/lwjgl/test/openal/PositionTest.java index a53d8183..2407c132 100644 --- a/src/java/org/lwjgl/test/openal/PositionTest.java +++ b/src/java/org/lwjgl/test/openal/PositionTest.java @@ -229,7 +229,7 @@ public class PositionTest extends BasicTest { Window.update(); // render and paint if !minimized and not dirty - if(!Window.isMinimized()) { + if(Window.isVisible()) { render(); } else { // sleeeeeep @@ -237,7 +237,7 @@ public class PositionTest extends BasicTest { } // act on pause mode - paused(Window.isMinimized() || !Window.isFocused()); + paused(!(Window.isVisible() || Window.isActive())); // start sound after first paint, since we don't want // the delay before something is painted on the screen diff --git a/src/java/org/lwjgl/test/opengl/BouncingWindowTest.java b/src/java/org/lwjgl/test/opengl/BouncingWindowTest.java deleted file mode 100644 index c2381448..00000000 --- a/src/java/org/lwjgl/test/opengl/BouncingWindowTest.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2002 Lightweight Java Game Library Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'Light Weight Java Game Library' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package org.lwjgl.test.opengl; - -import org.lwjgl.Display; -import org.lwjgl.LWJGLException; -import org.lwjgl.input.Keyboard; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.Window; - -/** - * $Id$ - * - * Tests the windowing functions. ESCAPE quits. - * - * @author $author$ - * @version $revision$ - */ -public class BouncingWindowTest { - public static void main(String[] args) { - - int x = 0, y = 0, dx = 1, dy = 1; - try { - Window.create("Bouncing Window Test", 0, 0, 64, 64, true, 16, 0, 16, 8, 0); - } catch (LWJGLException e) { - e.printStackTrace(System.err); - System.exit(-1); - } - - Window.setVSyncEnabled(true); - - float angle = 0.0f; - float color = 0.0f; - while (!Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) && !Window.isCloseRequested()) { - Window.update(); - x += dx; - y += dy; - if (x < 0) { - x = 1; - dx = 1; - } else if (x >= Display.getWidth() - Window.getWidth()) { - x = Display.getWidth() - Window.getWidth() - 1; - dx = -1; - } - if (y < 0) { - y = 1; - dy = 1; - } else if (y >= Display.getHeight() - Window.getHeight()) { - y = Display.getHeight() - Window.getHeight() - 1; - dy = -1; - } - - Window.setLocation(x, y); - angle += 1.0f; - if (angle >= 360.0f) { - angle = 0.0f; - } - color += 0.01f; - GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); - GL11.glPushMatrix(); - GL11.glTranslatef(Window.getWidth() / 2.0f, Window.getHeight() / 2.0f, 0.0f); - GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f); - GL11.glColor3f( - (float)Math.abs(Math.sin(color)), - (float)Math.abs(Math.cos(color)), - (float)Math.abs(Math.sin(color) * Math.cos(color)) - ); - GL11.glBegin(GL11.GL_QUADS); - { - GL11.glVertex2f(-20.0f, -20.0f); - GL11.glVertex2f(20.0f, -20.0f); - GL11.glVertex2f(20.0f, 20.0f); - GL11.glVertex2f(-20.0f, 20.0f); - } - GL11.glEnd(); - GL11.glPopMatrix(); - } - - } -} diff --git a/src/java/org/lwjgl/test/opengl/FullScreenWindowedTest.java b/src/java/org/lwjgl/test/opengl/FullScreenWindowedTest.java index 2cbd3ab1..c8b19651 100644 --- a/src/java/org/lwjgl/test/opengl/FullScreenWindowedTest.java +++ b/src/java/org/lwjgl/test/opengl/FullScreenWindowedTest.java @@ -95,7 +95,7 @@ public class FullScreenWindowedTest { */ private void mainLoop() { while (!Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) && !Window.isCloseRequested()) { - if (!Window.isMinimized()) { + if (Window.isVisible()) { // check keyboard input processKeyboard(); // do "game" logic, and render it diff --git a/src/java/org/lwjgl/test/opengl/Game.java b/src/java/org/lwjgl/test/opengl/Game.java index cf5c4cd0..aed04cbe 100644 --- a/src/java/org/lwjgl/test/opengl/Game.java +++ b/src/java/org/lwjgl/test/opengl/Game.java @@ -94,7 +94,7 @@ public final class Game { try { init(); while (!finished) { - if (Window.isMinimized()) { + if (!Window.isVisible()) { Thread.sleep(200); } else if (Window.isCloseRequested()) { finished = true; diff --git a/src/java/org/lwjgl/test/opengl/Grass.java b/src/java/org/lwjgl/test/opengl/Grass.java index 448f6da5..dc236a46 100644 --- a/src/java/org/lwjgl/test/opengl/Grass.java +++ b/src/java/org/lwjgl/test/opengl/Grass.java @@ -192,7 +192,7 @@ public class Grass { while (!finished) { if (Window.isCloseRequested()) { finished = true; - } else if (!Window.isMinimized()) { + } else if (Window.isVisible()) { keyPoll(); float degree = (1.0f + (aslod.value * 20.0f)) * 0.01745329f; diff --git a/src/java/org/lwjgl/test/opengl/PbufferTest.java b/src/java/org/lwjgl/test/opengl/PbufferTest.java index e46e0479..fd4a63c8 100644 --- a/src/java/org/lwjgl/test/opengl/PbufferTest.java +++ b/src/java/org/lwjgl/test/opengl/PbufferTest.java @@ -123,7 +123,7 @@ public class PbufferTest { */ private void mainLoop() { while (!Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) && !Window.isCloseRequested()) { - if (!Window.isMinimized()) { + if (!Window.isVisible()) { // check keyboard input processKeyboard(); // do "game" logic, and render it diff --git a/src/java/org/lwjgl/test/opengl/VBOIndexTest.java b/src/java/org/lwjgl/test/opengl/VBOIndexTest.java index a52b136a..7697fe24 100644 --- a/src/java/org/lwjgl/test/opengl/VBOIndexTest.java +++ b/src/java/org/lwjgl/test/opengl/VBOIndexTest.java @@ -114,7 +114,7 @@ public final class VBOIndexTest { while ( !finished ) { Window.update(); - if ( Window.isMinimized() ) + if ( !Window.isVisible() ) Thread.sleep(200); else if ( Window.isCloseRequested() ) System.exit(0); diff --git a/src/java/org/lwjgl/test/opengl/VBOTest.java b/src/java/org/lwjgl/test/opengl/VBOTest.java index aaf61a82..c413b930 100644 --- a/src/java/org/lwjgl/test/opengl/VBOTest.java +++ b/src/java/org/lwjgl/test/opengl/VBOTest.java @@ -110,7 +110,7 @@ public final class VBOTest { while ( !finished ) { Window.update(); - if ( Window.isMinimized() ) + if ( !Window.isVisible() ) Thread.sleep(200); else if ( Window.isCloseRequested() ) System.exit(0); diff --git a/src/java/org/lwjgl/test/opengl/shaders/ShadersTest.java b/src/java/org/lwjgl/test/opengl/shaders/ShadersTest.java index a58228b5..71f0bab5 100644 --- a/src/java/org/lwjgl/test/opengl/shaders/ShadersTest.java +++ b/src/java/org/lwjgl/test/opengl/shaders/ShadersTest.java @@ -77,7 +77,7 @@ public final class ShadersTest { long lastFrameTime = 0; while ( run ) { - if ( Window.isMinimized() ) + if (!Window.isVisible() ) Thread.yield(); else { // This is the current frame time. diff --git a/src/native/common/org_lwjgl_opengl_Window.h b/src/native/common/org_lwjgl_opengl_Window.h index 5ed54491..ecbf7fcf 100644 --- a/src/native/common/org_lwjgl_opengl_Window.h +++ b/src/native/common/org_lwjgl_opengl_Window.h @@ -36,34 +36,18 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsCloseRequested /* * Class: org_lwjgl_opengl_Window - * Method: nIsMinimized + * Method: nIsVisible * Signature: ()Z */ -JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsMinimized +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsVisible (JNIEnv *, jclass); /* * Class: org_lwjgl_opengl_Window - * Method: nIsFocused + * Method: nIsActive * Signature: ()Z */ -JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsFocused - (JNIEnv *, jclass); - -/* - * Class: org_lwjgl_opengl_Window - * Method: minimize - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_minimize - (JNIEnv *, jclass); - -/* - * Class: org_lwjgl_opengl_Window - * Method: restore - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_restore +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsActive (JNIEnv *, jclass); /* @@ -93,10 +77,10 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nMakeCurrent /* * Class: org_lwjgl_opengl_Window * Method: nCreate - * Signature: (Ljava/lang/String;IIIIZZIIIII)V + * Signature: (Ljava/lang/String;IIIIZIIIII)V */ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nCreate - (JNIEnv *, jclass, jstring, jint, jint, jint, jint, jboolean, jboolean, jint, jint, jint, jint, jint); + (JNIEnv *, jclass, jstring, jint, jint, jint, jint, jboolean, jint, jint, jint, jint, jint); /* * Class: org_lwjgl_opengl_Window @@ -134,9 +118,9 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nSetVSyncEnabled * Class: org_lwjgl_opengl_Window * Method: nReshape * Signature: (IIII)V - */ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nReshape (JNIEnv *, jclass, jint, jint, jint, jint); + */ #ifdef __cplusplus } diff --git a/src/native/linux/org_lwjgl_opengl_Window.cpp b/src/native/linux/org_lwjgl_opengl_Window.cpp index 452d9863..fc8907a0 100644 --- a/src/native/linux/org_lwjgl_opengl_Window.cpp +++ b/src/native/linux/org_lwjgl_opengl_Window.cpp @@ -456,15 +456,14 @@ static bool initWindowGLX(JNIEnv *env, Display *disp, int screen, jstring title, } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nCreate - (JNIEnv * env, jclass clazz, jstring title, jint x, jint y, jint width, jint height, jboolean fullscreen, jboolean undecorated, jint bpp, jint alpha, jint depth, jint stencil, jint samples) + (JNIEnv * env, jclass clazz, jstring title, jint x, jint y, jint width, jint height, jboolean fullscreen, jint bpp, jint alpha, jint depth, jint stencil, jint samples) { int screen; Display *disp; bool fscreen = false; if (fullscreen == JNI_TRUE) fscreen = true; - if (undecorated == JNI_TRUE) - isUndecorated = true; + isUndecorated = getBooleanProperty(env, "org.lwjgl.opengl.Window.undecorated"); if (!extgl_Open()) { throwException(env, "Could not load gl libs"); @@ -520,23 +519,6 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_swapBuffers(JNIEnv * env, jc glXSwapBuffers(getCurrentDisplay(), getCurrentWindow()); } -/* - * Class: org_lwjgl_opengl_Window - * Method: minimize - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_minimize - (JNIEnv *env, jclass clazz) { -} - -/* - * Class: org_lwjgl_opengl_Window - * Method: restore - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_restore - (JNIEnv *env, jclass clazz) { -} /* * Class: org_lwjgl_opengl_Window @@ -547,17 +529,17 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsDirty (JNIEnv *env, jclass clazz) { bool result = dirty; dirty = false; - return result; + return result ? JNI_TRUE : JNI_FALSE; } /* * Class: org_lwjgl_opengl_Window - * Method: nIsMinimized + * Method: nIsVisible * Signature: ()Z */ -JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsMinimized +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsVisible (JNIEnv *env, jclass clazz) { - return minimized; + return minimized ? JNI_FALSE : JNI_TRUE; } /* @@ -574,12 +556,12 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsCloseRequested /* * Class: org_lwjgl_opengl_Window - * Method: nIsFocused + * Method: nIsActive * Signature: ()Z */ -JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsFocused +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsActive (JNIEnv *env, jclass clazz) { - return focused; + return focused ? JNI_TRUE : JNI_FALSE; } JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsVSyncEnabled @@ -601,8 +583,3 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nSetVSyncEnabled } } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nReshape - (JNIEnv *env, jclass clazz, jint x, jint y, jint width, jint height) -{ - XMoveResizeWindow(current_disp, current_win, x, y, width, height); -} diff --git a/src/native/win32/org_lwjgl_opengl_Window.cpp b/src/native/win32/org_lwjgl_opengl_Window.cpp index 847cb32e..b1c1a950 100755 --- a/src/native/win32/org_lwjgl_opengl_Window.cpp +++ b/src/native/win32/org_lwjgl_opengl_Window.cpp @@ -480,33 +480,6 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nUpdate } -/* - * Class: org_lwjgl_Window - * Method: minimize - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_minimize - (JNIEnv * env, jclass clazz) -{ - if (isMinimized) - return; - ShowWindow(hwnd, SW_MINIMIZE); -} - -/* - * Class: org_lwjgl_Window - * Method: minimize - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_restore - (JNIEnv * env, jclass clazz) -{ - if (!isMinimized) - return; - - ShowWindow(hwnd, SW_RESTORE); -} - /* * Class: org_lwjgl_Window * Method: swapBuffers @@ -526,14 +499,14 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_swapBuffers * Signature: (Ljava/lang/String;IIIIZIIII)V */ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nCreate - (JNIEnv * env, jclass clazz, jstring title, jint x, jint y, jint width, jint height, jboolean fullscreen, jboolean undecorated, jint bpp, jint alpha, jint depth, jint stencil, jint samples) + (JNIEnv * env, jclass clazz, jstring title, jint x, jint y, jint width, jint height, jboolean fullscreen, jint bpp, jint alpha, jint depth, jint stencil, jint samples) { closerequested = false; isMinimized = false; isFocused = true; isDirty = true; isFullScreen = fullscreen == JNI_TRUE; - isUndecorated = undecorated == JNI_TRUE; + isUndecorated = getBooleanProperty(env, "org.lwjgl.opengl.Window.undecorated"); vsync = JNI_FALSE; // Speacial option for allowing software opengl @@ -626,12 +599,12 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsDirty /* * Class: org_lwjgl_opengl_Window - * Method: nIsMinimized + * Method: nIsVisible * Signature: ()Z */ -JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsMinimized +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsVisible (JNIEnv *env, jclass clazz) { - return isMinimized; + return isMinimized ? JNI_FALSE : JNI_TRUE; } /* @@ -648,10 +621,10 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsCloseRequested /* * Class: org_lwjgl_opengl_Window - * Method: nIsFocused + * Method: nIsActive * Signature: ()Z */ -JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsFocused +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsActive (JNIEnv *env, jclass clazz) { return isFocused; } @@ -691,6 +664,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nMakeCurrent wglMakeCurrent(hdc, hglrc); } +/* JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nReshape (JNIEnv *env, jclass clazz, jint x, jint y, jint width, jint height) { @@ -725,3 +699,4 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nReshape SetWindowPos(hwnd, HWND_TOP, x, y, clientSize.right - clientSize.left, clientSize.bottom - clientSize.top, SWP_NOZORDER); } +*/ \ No newline at end of file