diff --git a/src/java/org/lwjgl/test/DisplayTest.java b/src/java/org/lwjgl/test/DisplayTest.java index e4fe617d..8c76c3ca 100644 --- a/src/java/org/lwjgl/test/DisplayTest.java +++ b/src/java/org/lwjgl/test/DisplayTest.java @@ -31,8 +31,9 @@ */ package org.lwjgl.test; -import org.lwjgl.Display; -import org.lwjgl.DisplayMode; +import org.lwjgl.LWJGLException; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.DisplayMode; /** * $Id$ @@ -69,10 +70,10 @@ public class DisplayTest { System.out.println("Info about current:"); System.out.println("Graphics card: " + Display.getAdapter() + ", version: " + Display.getVersion()); System.out.println("Resolution: " + - Display.getWidth() + "x" + - Display.getHeight() + "x" + - Display.getDepth() + "@" + - Display.getFrequency() + "Hz"); + Display.getDisplayMode().getWidth() + "x" + + Display.getDisplayMode().getHeight() + "x" + + Display.getDisplayMode().getBitsPerPixel() + "@" + + Display.getDisplayMode().getFrequency() + "Hz"); System.out.println("---- Test Current ----"); } @@ -125,10 +126,10 @@ public class DisplayTest { // find a mode System.out.print("Looking for 640x480x16@60..."); for(int i=0; i= 16) { + if (modes[i].getWidth() == 640 + && modes[i].getHeight() == 480 + && modes[i].getBitsPerPixel() >= 16) { displayMode = modes[i]; break; } } try { - if(fullscreen) { Display.setDisplayMode(displayMode); - Window.create("ControllerCreationTest", 16, 0, 0, 0, 0); - } else { - Window.create("ControllerCreationTest", 50, 50, 640, 480, 16, 0, 0, 0, 0); - } + Display.setFullscreen(fullscreen); + Display.create(); } catch (Exception e) { e.printStackTrace(); @@ -105,12 +102,12 @@ public class ControllerCreationTest { // recreate display in fullscreen mode System.out.print("Destroying display..."); - Window.destroy(); + Display.destroy(); System.out.println("success"); System.out.print("Entering fullscreen mode..."); try { - Window.destroy(); + Display.destroy(); initialize(true); Display.setDisplayMode(displayMode); } catch (Exception e) { @@ -129,8 +126,7 @@ public class ControllerCreationTest { System.out.println("Test completed successfully!"); System.out.print("Shutting down..."); - Display.resetDisplayMode(); - Window.destroy(); + Display.destroy(); System.out.println("shutdown complete"); } @@ -142,7 +138,7 @@ public class ControllerCreationTest { while (Sys.getTime() < endtime) { - Window.update(); + Display.update(); //controller is a bit fuzzy if(Controller.getX() > 100) { diff --git a/src/java/org/lwjgl/test/input/ControllerFieldTest.java b/src/java/org/lwjgl/test/input/ControllerFieldTest.java index f15d5afd..493aa547 100644 --- a/src/java/org/lwjgl/test/input/ControllerFieldTest.java +++ b/src/java/org/lwjgl/test/input/ControllerFieldTest.java @@ -40,7 +40,7 @@ import java.awt.event.WindowEvent; import org.lwjgl.LWJGLException; import org.lwjgl.input.Controller; -import org.lwjgl.opengl.Window; +import org.lwjgl.opengl.Display; /** @@ -71,7 +71,7 @@ public class ControllerFieldTest { * */ private void destroy() { - Window.destroy(); + Display.destroy(); } /** @@ -83,7 +83,7 @@ public class ControllerFieldTest { String buttons; while(frame.isVisible()) { buttons = ""; - Window.update(); + Display.update(); labels[0].setText("" + Controller.getX()); labels[1].setText("" + Controller.getRx()); @@ -107,7 +107,7 @@ public class ControllerFieldTest { private void initialize() { try { - Window.create("debug", 10, 10, 10, 10, 16, 0, 0, 0); + Display.create(); } catch (LWJGLException lwjgle) { lwjgle.printStackTrace(); return; diff --git a/src/java/org/lwjgl/test/input/ControllerTest.java b/src/java/org/lwjgl/test/input/ControllerTest.java index ee8b575d..8891882f 100644 --- a/src/java/org/lwjgl/test/input/ControllerTest.java +++ b/src/java/org/lwjgl/test/input/ControllerTest.java @@ -34,7 +34,7 @@ package org.lwjgl.test.input; import org.lwjgl.input.Controller; import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.Window; +import org.lwjgl.opengl.Display; import org.lwjgl.util.vector.Vector2f; import org.lwjgl.util.vector.Vector3f; @@ -113,11 +113,11 @@ public class ControllerTest { private void setupDisplay() { try { if (FULLSCREEN) { - Window.create("ControllerTest", 16, 0, 0, 0, 0); + Display.create(); } else { - Window.create("ControllerTest", 50, 50, WINDOW_WIDTH, WINDOW_HEIGHT, 16, 0, 0, 0, 0); + Display.create(); } - Window.setVSyncEnabled(true); + Display.setVSyncEnabled(true); } catch (Exception e) { e.printStackTrace(); System.exit(-1); @@ -142,7 +142,7 @@ public class ControllerTest { runTest(); - Window.destroy(); + Display.destroy(); } /** * Runs the test @@ -161,7 +161,7 @@ public class ControllerTest { // pause and continue if minimized - if(!Window.isVisible()) { + if(!Display.isVisible()) { pause(100); render(); continue; @@ -192,8 +192,8 @@ public class ControllerTest { * Handles the window */ private void handleWindow() { - Window.update(); - closing = Window.isCloseRequested(); + Display.update(); + closing = Display.isCloseRequested(); } /** diff --git a/src/java/org/lwjgl/test/input/HWCursorTest.java b/src/java/org/lwjgl/test/input/HWCursorTest.java index f15852c9..de37c456 100644 --- a/src/java/org/lwjgl/test/input/HWCursorTest.java +++ b/src/java/org/lwjgl/test/input/HWCursorTest.java @@ -35,13 +35,13 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.IntBuffer; -import org.lwjgl.Display; -import org.lwjgl.DisplayMode; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.DisplayMode; import org.lwjgl.input.Cursor; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.Window; +import org.lwjgl.opengl.Display; import org.lwjgl.opengl.glu.GLU; /** @@ -83,9 +83,10 @@ public class HWCursorTest { try { //find displaymode mode = findDisplayMode(800, 600, 16); + Display.setDisplayMode(mode); // start of in windowed mode - Window.create("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0, 0); + Display.create(); glInit(); @@ -201,11 +202,11 @@ public class HWCursorTest { */ private void mainLoop() { while (!Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) - && !Window.isCloseRequested()) { + && !Display.isCloseRequested()) { // allow subsystem to get a chance to run too - Window.update(); + Display.update(); - if (Window.isVisible()) { + if (Display.isVisible()) { // check keyboard input processKeyboard(); processMouse(); @@ -214,7 +215,7 @@ public class HWCursorTest { } else { // no need to render/paint if nothing has changed (ie. window dragged over) - if (Window.isDirty()) { + if (Display.isDirty()) { render(); } @@ -286,10 +287,7 @@ public class HWCursorTest { for(int i=0; i= bpp) { + if (modes[i].getWidth() == width + && modes[i].getHeight() == height + && modes[i].getBitsPerPixel() >= bpp) { return modes[i]; } } @@ -393,16 +386,16 @@ public class HWCursorTest { // Go into orthographic projection mode. GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); - GLU.gluOrtho2D(0, mode.width, 0, mode.height); + GLU.gluOrtho2D(0, mode.getWidth(), 0, mode.getHeight()); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); - GL11.glViewport(0, 0, mode.width, mode.height); + GL11.glViewport(0, 0, mode.getWidth(), mode.getHeight()); //set clear color to black GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); //sync frame (only works on windows) - Window.setVSyncEnabled(true); + Display.setVSyncEnabled(true); } /** diff --git a/src/java/org/lwjgl/test/input/KeyboardTest.java b/src/java/org/lwjgl/test/input/KeyboardTest.java index 5af39318..b32aad30 100644 --- a/src/java/org/lwjgl/test/input/KeyboardTest.java +++ b/src/java/org/lwjgl/test/input/KeyboardTest.java @@ -31,10 +31,10 @@ */ package org.lwjgl.test.input; -import org.lwjgl.DisplayMode; +import org.lwjgl.opengl.DisplayMode; import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.Window; +import org.lwjgl.opengl.Display; import org.lwjgl.opengl.glu.GLU; import org.lwjgl.util.vector.Vector2f; @@ -76,7 +76,7 @@ public class KeyboardTest { private void setupDisplay(boolean fullscreen) { try { - Window.create("KeyboardTest", 50, 50, 640, 480, 16, 0, 0, 0, 0); + Display.create(); } catch (Exception e) { e.printStackTrace(); System.exit(-1); @@ -98,7 +98,7 @@ public class KeyboardTest { wiggleKeyboard(); Keyboard.destroy(); - Window.destroy(); + Display.destroy(); } private void createKeyboard() { @@ -114,10 +114,10 @@ public class KeyboardTest { private void wiggleKeyboard() { - while (!Window.isCloseRequested()) { - Window.update(); + while (!Display.isCloseRequested()) { + Display.update(); - if (!Window.isVisible()) { + if (!Display.isVisible()) { try { Thread.sleep(100); } catch (InterruptedException inte) { diff --git a/src/java/org/lwjgl/test/input/MouseCreationTest.java b/src/java/org/lwjgl/test/input/MouseCreationTest.java index 14558538..0aa757c9 100644 --- a/src/java/org/lwjgl/test/input/MouseCreationTest.java +++ b/src/java/org/lwjgl/test/input/MouseCreationTest.java @@ -31,12 +31,12 @@ */ package org.lwjgl.test.input; -import org.lwjgl.Display; -import org.lwjgl.DisplayMode; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.DisplayMode; import org.lwjgl.Sys; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.Window; +import org.lwjgl.opengl.Display; import org.lwjgl.util.vector.Vector2f; /** @@ -62,21 +62,18 @@ public class MouseCreationTest { // find first display mode that allows us 640*480*16 DisplayMode[] modes = Display.getAvailableDisplayModes(); for (int i = 0; i < modes.length; i++) { - if (modes[i].width == 640 - && modes[i].height == 480 - && modes[i].bpp >= 16) { + if (modes[i].getWidth() == 640 + && modes[i].getHeight() == 480 + && modes[i].getBitsPerPixel() >= 16) { displayMode = modes[i]; break; } } try { - if(fullscreen) { Display.setDisplayMode(displayMode); - Window.create("MouseCreationTest", 16, 0, 0, 0, 0); - } else { - Window.create("MouseCreationTest", 50, 50, 640, 480, 16, 0, 0, 0, 0); - } + Display.setFullscreen(fullscreen); + Display.create(); } catch (Exception e) { e.printStackTrace(); @@ -110,7 +107,7 @@ public class MouseCreationTest { System.out.print("Entering fullscreen mode..."); try { - Window.destroy(); + Display.destroy(); initialize(true); Display.setDisplayMode(displayMode); } catch (Exception e) { @@ -129,8 +126,7 @@ public class MouseCreationTest { System.out.println("Test completed successfully!"); System.out.print("Shutting down..."); - Display.resetDisplayMode(); - Window.destroy(); + Display.destroy(); System.out.println("shutdown complete"); } @@ -141,7 +137,7 @@ public class MouseCreationTest { long endtime = Sys.getTime() + Sys.getTimerResolution() * 5; while (Sys.getTime() < endtime) { - Window.update(); + Display.update(); position.x += Mouse.getDX(); position.y += Mouse.getDY(); diff --git a/src/java/org/lwjgl/test/input/MouseTest.java b/src/java/org/lwjgl/test/input/MouseTest.java index 132d202a..13363cb4 100644 --- a/src/java/org/lwjgl/test/input/MouseTest.java +++ b/src/java/org/lwjgl/test/input/MouseTest.java @@ -34,7 +34,7 @@ package org.lwjgl.test.input; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.Window; +import org.lwjgl.opengl.Display; import org.lwjgl.util.vector.Vector2f; import org.lwjgl.util.vector.Vector3f; @@ -112,11 +112,11 @@ public class MouseTest { private void setupDisplay() { try { if (FULLSCREEN) { - Window.create("MouseTest", 16, 0, 0, 0, 0); + Display.create(); } else { - Window.create("MouseTest", 50, 50, WINDOW_WIDTH, WINDOW_HEIGHT, 16, 0, 0, 0, 0); + Display.create(); } - Window.setVSyncEnabled(true); + Display.setVSyncEnabled(true); } catch (Exception e) { e.printStackTrace(); System.exit(-1); @@ -141,7 +141,7 @@ public class MouseTest { runTest(); - Window.destroy(); + Display.destroy(); } /** @@ -173,8 +173,8 @@ public class MouseTest { // pause and continue if minimized - if(!Window.isVisible()) { - if(Window.isDirty()) { + if(!Display.isVisible()) { + if(Display.isDirty()) { render(); } pause(100); @@ -206,8 +206,8 @@ public class MouseTest { * Handles the window */ private void handleWindow() { - Window.update(); - closing = Window.isCloseRequested(); + Display.update(); + closing = Display.isCloseRequested(); } /** diff --git a/src/java/org/lwjgl/test/openal/MovingSoundTest.java b/src/java/org/lwjgl/test/openal/MovingSoundTest.java index 999701f3..be7384b5 100644 --- a/src/java/org/lwjgl/test/openal/MovingSoundTest.java +++ b/src/java/org/lwjgl/test/openal/MovingSoundTest.java @@ -38,7 +38,7 @@ import org.lwjgl.openal.AL10; import org.lwjgl.openal.eax.EAX; import org.lwjgl.openal.eax.EAX20; import org.lwjgl.openal.eax.EAXListenerProperties; -import org.lwjgl.opengl.Window; +import org.lwjgl.opengl.Display; import org.lwjgl.util.vector.Vector3f; /** @@ -71,7 +71,7 @@ public class MovingSoundTest extends BasicTest { } try { - Window.create("Moving Sound Test", 100, 100, 320, 240, 32, 0 ,0 ,0, 0); + Display.create(); } catch (Exception e) { e.printStackTrace(); } @@ -157,7 +157,7 @@ public class MovingSoundTest extends BasicTest { System.out.println("Move source with arrow keys\nMove listener with right shift and arrowkeys\nEnable EAX effect by pressing e (if available)\nExit with ESC"); while(!Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) { - Window.update(); + Display.update(); Keyboard.poll(); if(Keyboard.isKeyDown(Keyboard.KEY_LEFT)) { @@ -192,7 +192,7 @@ public class MovingSoundTest extends BasicTest { eaxApplied = !eaxApplied; } - if(Window.isCloseRequested()) { + if(Display.isCloseRequested()) { break; } diff --git a/src/java/org/lwjgl/test/openal/PositionTest.java b/src/java/org/lwjgl/test/openal/PositionTest.java index 4442137e..2350769f 100644 --- a/src/java/org/lwjgl/test/openal/PositionTest.java +++ b/src/java/org/lwjgl/test/openal/PositionTest.java @@ -34,14 +34,14 @@ package org.lwjgl.test.openal; import java.nio.FloatBuffer; import java.nio.IntBuffer; -import org.lwjgl.Display; +import org.lwjgl.opengl.Display; import org.lwjgl.Sys; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.openal.AL; import org.lwjgl.openal.AL10; import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.Window; +import org.lwjgl.opengl.Display; import org.lwjgl.opengl.glu.GLU; /** @@ -147,11 +147,11 @@ public class PositionTest extends BasicTest { Sys.log("Setting up window"); // calc center - int centerX = (Display.getWidth() - WINDOW_WIDTH) / 2; - int centerY = (Display.getHeight() - WINDOW_HEIGHT) / 2; + int centerX = (Display.getDisplayMode().getWidth() - WINDOW_WIDTH) / 2; + int centerY = (Display.getDisplayMode().getHeight() - WINDOW_HEIGHT) / 2; // setup window - Window.create("PositionTest", centerX, centerY, WINDOW_WIDTH, WINDOW_HEIGHT, Display.getDepth(), 0, 8, 0, 0); + Display.create(); // ----------------------------------------------------- // Setup OpenGL @@ -168,7 +168,7 @@ public class PositionTest extends BasicTest { GL11.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glut = this.new GLUT(); - Window.setVSyncEnabled(true); + Display.setVSyncEnabled(true); // ----------------------------------------------------- // Setup OpenAL @@ -257,10 +257,10 @@ public class PositionTest extends BasicTest { handleInput(); // allow window to process internal messages - Window.update(); + Display.update(); // render and paint if !minimized and not dirty - if(Window.isVisible()) { + if(Display.isVisible()) { render(); } else { // sleeeeeep @@ -268,7 +268,7 @@ public class PositionTest extends BasicTest { } // act on pause mode - paused(!(Window.isVisible() || Window.isActive())); + paused(!(Display.isVisible() || Display.isActive())); // start sound after first paint, since we don't want // the delay before something is painted on the screen @@ -318,7 +318,7 @@ public class PositionTest extends BasicTest { */ private void handleInput() { // User wants to exit? - finished = Window.isCloseRequested() || Keyboard.isKeyDown(Keyboard.KEY_ESCAPE); + finished = Display.isCloseRequested() || Keyboard.isKeyDown(Keyboard.KEY_ESCAPE); if (finished) { return; } @@ -466,7 +466,7 @@ public class PositionTest extends BasicTest { AL.destroy(); Sys.log("Shutting down Window"); - Window.destroy(); + Display.destroy(); } /** diff --git a/src/java/org/lwjgl/test/opengl/FullScreenWindowedTest.java b/src/java/org/lwjgl/test/opengl/FullScreenWindowedTest.java index 5d04f3a9..b9782638 100644 --- a/src/java/org/lwjgl/test/opengl/FullScreenWindowedTest.java +++ b/src/java/org/lwjgl/test/opengl/FullScreenWindowedTest.java @@ -31,11 +31,11 @@ */ package org.lwjgl.test.opengl; -import org.lwjgl.Display; -import org.lwjgl.DisplayMode; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.DisplayMode; import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.Window; +import org.lwjgl.opengl.Display; import org.lwjgl.opengl.glu.GLU; import org.lwjgl.util.vector.Vector2f; @@ -82,7 +82,7 @@ public class FullScreenWindowedTest { //find displaymode mode = findDisplayMode(800, 600, 16); // start of in windowed mode - Window.create("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0, 0); + Display.create(); glInit(); quadPosition = new Vector2f(100f, 100f); quadVelocity = new Vector2f(1.0f, 1.0f); @@ -94,8 +94,8 @@ public class FullScreenWindowedTest { * Runs the main loop of the "test" */ private void mainLoop() { - while (!Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) && !Window.isCloseRequested()) { - if (Window.isVisible()) { + while (!Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) && !Display.isCloseRequested()) { + if (Display.isVisible()) { // check keyboard input processKeyboard(); // do "game" logic, and render it @@ -104,7 +104,7 @@ public class FullScreenWindowedTest { } else { // no need to render/paint if nothing has changed (ie. window // dragged over) - if (Window.isDirty()) { + if (Display.isDirty()) { render(); } // don't waste cpu time, sleep more @@ -114,7 +114,7 @@ public class FullScreenWindowedTest { } } // Update window - Window.update(); + Display.update(); } } /** @@ -128,11 +128,11 @@ public class FullScreenWindowedTest { quadPosition.x += quadVelocity.x; quadPosition.y += quadVelocity.y; //check colision with vertical border border - if (quadPosition.x + 50 >= mode.width || quadPosition.x - 50 <= 0) { + if (quadPosition.x + 50 >= mode.getWidth() || quadPosition.x - 50 <= 0) { quadVelocity.x *= -1; } //check collision with horizontal border - if (quadPosition.y + 50 >= mode.height || quadPosition.y - 50 <= 0) { + if (quadPosition.y + 50 >= mode.getHeight() || quadPosition.y - 50 <= 0) { quadVelocity.y *= -1; } } @@ -163,10 +163,7 @@ public class FullScreenWindowedTest { //check for fullscreen key if (Keyboard.isKeyDown(Keyboard.KEY_F)) { try { - Window.destroy(); - Display.setDisplayMode(mode); - Window.create("Test", mode.bpp, 0, 0, 0, 0); - glInit(); + Display.setFullscreen(true); } catch (Exception e) { e.printStackTrace(); } @@ -174,10 +171,7 @@ public class FullScreenWindowedTest { //check for window key if (Keyboard.isKeyDown(Keyboard.KEY_W)) { try { - Window.destroy(); - Display.resetDisplayMode(); - Window.create("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0, 0); - glInit(); + Display.setFullscreen(false); } catch (Exception e) { e.printStackTrace(); } @@ -240,7 +234,7 @@ public class FullScreenWindowedTest { private DisplayMode findDisplayMode(int width, int height, int bpp) { DisplayMode[] modes = Display.getAvailableDisplayModes(); for (int i = 0; i < modes.length; i++) { - if (modes[i].width == width && modes[i].height == height && modes[i].bpp >= bpp && modes[i].freq <= 60) { + if (modes[i].getWidth() == width && modes[i].getHeight() == height && modes[i].getBitsPerPixel() >= bpp && modes[i].getFrequency() <= 60) { return modes[i]; } } @@ -253,14 +247,14 @@ public class FullScreenWindowedTest { // Go into orthographic projection mode. GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); - GLU.gluOrtho2D(0, mode.width, 0, mode.height); + GLU.gluOrtho2D(0, mode.getWidth(), 0, mode.getHeight()); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); - GL11.glViewport(0, 0, mode.width, mode.height); + GL11.glViewport(0, 0, mode.getWidth(), mode.getHeight()); //set clear color to black GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); //sync frame (only works on windows) - Window.setVSyncEnabled(true); + Display.setVSyncEnabled(true); } /** * Test entry point diff --git a/src/java/org/lwjgl/test/opengl/Game.java b/src/java/org/lwjgl/test/opengl/Game.java index a1a63c99..685bd22c 100644 --- a/src/java/org/lwjgl/test/opengl/Game.java +++ b/src/java/org/lwjgl/test/opengl/Game.java @@ -39,15 +39,15 @@ */ package org.lwjgl.test.opengl; -import org.lwjgl.Display; -import org.lwjgl.DisplayMode; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.DisplayMode; import org.lwjgl.Sys; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL13; import org.lwjgl.opengl.Util; -import org.lwjgl.opengl.Window; +import org.lwjgl.opengl.Display; public final class Game { static { @@ -56,7 +56,7 @@ public final class Game { int mode = -1; DisplayMode[] modes = Display.getAvailableDisplayModes(); for (int i = 0; i < modes.length; i++) { - if (modes[i].width == 640 && modes[i].height == 480 && modes[i].bpp >= 16) { + if (modes[i].getWidth() == 640 && modes[i].getHeight() == 480 && modes[i].getBitsPerPixel() >= 16) { mode = i; break; } @@ -73,7 +73,7 @@ public final class Game { } static { try { - Window.create("LWJGL Game Example"); + Display.create(); System.out.println("Created OpenGL."); } catch (Exception e) { System.err.println("Failed to create OpenGL due to " + e); @@ -94,15 +94,15 @@ public final class Game { try { init(); while (!finished) { - if (!Window.isVisible()) { + if (!Display.isVisible()) { Thread.sleep(200); - } else if (Window.isCloseRequested()) { + } else if (Display.isCloseRequested()) { finished = true; } else { mainLoop(); render(); } - Window.update(); + Display.update(); } } catch (Throwable t) { t.printStackTrace(); @@ -133,7 +133,7 @@ public final class Game { private static void render() { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); GL11.glPushMatrix(); - GL11.glTranslatef(Display.getWidth() / 2, Display.getHeight() / 2, 0.0f); + GL11.glTranslatef(Display.getDisplayMode().getWidth() / 2, Display.getDisplayMode().getHeight() / 2, 0.0f); GL11.glRotatef(angle, 0, 0, 1.0f); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2i(-50, -50); @@ -156,7 +156,6 @@ public final class Game { * Cleanup */ private static void cleanup() { - Window.destroy(); - Display.resetDisplayMode(); + Display.destroy(); } } diff --git a/src/java/org/lwjgl/test/opengl/Grass.java b/src/java/org/lwjgl/test/opengl/Grass.java index 9c9438ef..e38328b1 100644 --- a/src/java/org/lwjgl/test/opengl/Grass.java +++ b/src/java/org/lwjgl/test/opengl/Grass.java @@ -50,8 +50,8 @@ import java.nio.IntBuffer; import java.util.Random; import org.lwjgl.BufferUtils; -import org.lwjgl.Display; -import org.lwjgl.DisplayMode; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.DisplayMode; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.*; @@ -73,9 +73,9 @@ public class Grass { int mode = -1; DisplayMode[] modes = Display.getAvailableDisplayModes(); for (int i = 0; i < modes.length; i++) { - if (modes[i].width == 640 - && modes[i].height == 480 - && modes[i].bpp >= 16) { + if (modes[i].getWidth ()== 640 + && modes[i].getHeight() == 480 + && modes[i].getBitsPerPixel() >= 16) { mode = i; break; } @@ -98,7 +98,7 @@ public class Grass { static { try { - Window.create("LWJGL Grass", 50, 50, 640, 480, 16, 0, 0,0, 0); + Display.create(); Keyboard.create(); Keyboard.enableBuffer(); Mouse.create(); @@ -190,9 +190,9 @@ public class Grass { aslod.count = 0.0f; while (!finished) { - if (Window.isCloseRequested()) { + if (Display.isCloseRequested()) { finished = true; - } else if (Window.isVisible()) { + } else if (Display.isVisible()) { keyPoll(); float degree = (1.0f + (aslod.value * 20.0f)) * 0.01745329f; @@ -205,9 +205,9 @@ public class Grass { grsDraw(); } - Window.update(); + Display.update(); } - Window.destroy(); + Display.destroy(); } private static float myrand() { diff --git a/src/java/org/lwjgl/test/opengl/PbufferTest.java b/src/java/org/lwjgl/test/opengl/PbufferTest.java index 30146ef3..39879f04 100644 --- a/src/java/org/lwjgl/test/opengl/PbufferTest.java +++ b/src/java/org/lwjgl/test/opengl/PbufferTest.java @@ -35,12 +35,13 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.IntBuffer; -import org.lwjgl.Display; -import org.lwjgl.DisplayMode; +import org.lwjgl.opengl.PixelFormat; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.DisplayMode; import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.Pbuffer; -import org.lwjgl.opengl.Window; +import org.lwjgl.opengl.Display; import org.lwjgl.opengl.glu.GLU; import org.lwjgl.util.vector.Vector2f; @@ -96,9 +97,9 @@ public class PbufferTest { try { //find displaymode mode = findDisplayMode(800, 600, 16); - + Display.setDisplayMode(mode); // start of in windowed mode - Window.create("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0, 0); + Display.create(); // gl = new GLWindow("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0); if ((Pbuffer.getPbufferCaps() & Pbuffer.PBUFFER_SUPPORTED) == 0) { System.out.println("No Pbuffer support!"); @@ -122,8 +123,8 @@ public class PbufferTest { * Runs the main loop of the "test" */ private void mainLoop() { - while (!Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) && !Window.isCloseRequested()) { - if (Window.isVisible()) { + while (!Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) && !Display.isCloseRequested()) { + if (Display.isVisible()) { // check keyboard input processKeyboard(); // do "game" logic, and render it @@ -132,7 +133,7 @@ public class PbufferTest { } else { // no need to render/paint if nothing has changed (ie. window // dragged over) - if (Window.isDirty()) { + if (Display.isDirty()) { render(); } // don't waste cpu time, sleep more @@ -142,7 +143,7 @@ public class PbufferTest { } } // Update window - Window.update(); + Display.update(); } } @@ -159,12 +160,12 @@ public class PbufferTest { quadPosition.y += quadVelocity.y; //check colision with vertical border border - if (quadPosition.x + 50 >= mode.width || quadPosition.x - 50 <= 0) { + if (quadPosition.x + 50 >= mode.getWidth() || quadPosition.x - 50 <= 0) { quadVelocity.x *= -1; } //check collision with horizontal border - if (quadPosition.y + 50 >= mode.height || quadPosition.y - 50 <= 0) { + if (quadPosition.y + 50 >= mode.getHeight() || quadPosition.y - 50 <= 0) { quadVelocity.y *= -1; } } @@ -197,7 +198,7 @@ public class PbufferTest { } GL11.glPopMatrix(); GL11.glCopyTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, 0, 0, 512, 512, 0); - Window.makeCurrent(); + Display.makeCurrent(); // OpenGL window rendering GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); @@ -225,11 +226,11 @@ public class PbufferTest { private void initPbuffer() { try { - pbuffer = new Pbuffer(512, 512, mode.bpp, 0, 0, 0, 0, null); + pbuffer = new Pbuffer(512, 512, new PixelFormat(), null); pbuffer.makeCurrent(); initGLState(256, 256, 0.5f); GL11.glBindTexture(GL11.GL_TEXTURE_2D, tex_handle); - Window.makeCurrent(); + Display.makeCurrent(); } catch (Exception e) { e.printStackTrace(); } @@ -245,17 +246,8 @@ public class PbufferTest { if (Keyboard.isKeyDown(Keyboard.KEY_F)) { try { - destroyTexture(); - Keyboard.destroy(); - pbuffer.destroy(); - Window.destroy(); - Display.setDisplayMode(mode); - Window.create("Test", mode.bpp, 0, 0, 0, 0); - glInit(); - initPbuffer(); - - Keyboard.create(); + Display.setFullscreen(true); } catch (Exception e) { e.printStackTrace(); } @@ -264,18 +256,7 @@ public class PbufferTest { //check for window key if (Keyboard.isKeyDown(Keyboard.KEY_W)) { try { - destroyTexture(); - Keyboard.destroy(); - pbuffer.destroy(); - Window.destroy(); - - Display.resetDisplayMode(); - Window.create("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0, 0); - glInit(); - initPbuffer(); - - - Keyboard.create(); + Display.setFullscreen(false); } catch (Exception e) { e.printStackTrace(); } @@ -335,9 +316,8 @@ public class PbufferTest { */ private void cleanup() { destroyTexture(); - Keyboard.destroy(); pbuffer.destroy(); - Window.destroy(); + Display.destroy(); } /** @@ -351,9 +331,9 @@ public class PbufferTest { private DisplayMode findDisplayMode(int width, int height, int bpp) { DisplayMode[] modes = Display.getAvailableDisplayModes(); for (int i = 0; i < modes.length; i++) { - if (modes[i].width == width - && modes[i].height == height - && modes[i].bpp >= bpp) { + if (modes[i].getWidth() == width + && modes[i].getHeight() == height + && modes[i].getBitsPerPixel() >= bpp) { return modes[i]; } } @@ -363,7 +343,7 @@ public class PbufferTest { private void initGLState(int width, int height, float color) { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); - GLU.gluOrtho2D(0, mode.width, 0, mode.height); + GLU.gluOrtho2D(0, mode.getWidth(), 0, mode.getHeight()); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glViewport(0, 0, width, height); @@ -377,7 +357,7 @@ public class PbufferTest { */ private void glInit() { //sync frame (only works on windows) - Window.setVSyncEnabled(true); + Display.setVSyncEnabled(true); GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_REPLACE); GL11.glEnable(GL11.GL_TEXTURE_2D); @@ -390,7 +370,7 @@ public class PbufferTest { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); - initGLState(mode.width, mode.height, 0f); + initGLState(mode.getWidth(), mode.getHeight(), 0f); } /** diff --git a/src/java/org/lwjgl/test/opengl/VBOIndexTest.java b/src/java/org/lwjgl/test/opengl/VBOIndexTest.java index b993de54..e6264201 100644 --- a/src/java/org/lwjgl/test/opengl/VBOIndexTest.java +++ b/src/java/org/lwjgl/test/opengl/VBOIndexTest.java @@ -41,8 +41,8 @@ package org.lwjgl.test.opengl; -import org.lwjgl.Display; -import org.lwjgl.DisplayMode; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.DisplayMode; import org.lwjgl.Sys; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; @@ -62,9 +62,9 @@ public final class VBOIndexTest { int mode = -1; DisplayMode[] modes = Display.getAvailableDisplayModes(); for ( int i = 0; i < modes.length; i++ ) { - if ( modes[i].width == 640 - && modes[i].height == 480 - && modes[i].bpp >= 16 ) { + if ( modes[i].getWidth() == 640 + && modes[i].getHeight() == 480 + && modes[i].getBitsPerPixel() >= 16 ) { mode = i; break; } @@ -82,7 +82,7 @@ public final class VBOIndexTest { static { try { - Window.create("LWJGL Game Example", 16, 0, 0, 0, 0); + Display.create(); System.out.println("Created OpenGL."); } catch (Exception e) { System.err.println("Failed to create OpenGL due to " + e); @@ -112,11 +112,11 @@ public final class VBOIndexTest { try { init(); while ( !finished ) { - Window.update(); + Display.update(); - if ( !Window.isVisible() ) + if ( !Display.isVisible() ) Thread.sleep(200); - else if ( Window.isCloseRequested() ) + else if ( Display.isCloseRequested() ) System.exit(0); mainLoop(); @@ -159,7 +159,7 @@ public final class VBOIndexTest { private static void render() { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); GL11.glPushMatrix(); - GL11.glTranslatef(Display.getWidth() / 2, Display.getHeight() / 2, 0.0f); + GL11.glTranslatef(Display.getDisplayMode().getWidth() / 2, Display.getDisplayMode().getHeight() / 2, 0.0f); GL11.glRotatef(angle, 0, 0, 1.0f); @@ -201,10 +201,10 @@ public final class VBOIndexTest { // Go into orthographic projection mode. GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); - GLU.gluOrtho2D(0, Display.getWidth(), 0, Display.getHeight()); + GLU.gluOrtho2D(0, Display.getDisplayMode().getWidth(), 0, Display.getDisplayMode().getHeight()); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); - GL11.glViewport(0, 0, Display.getWidth(), Display.getHeight()); + GL11.glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight()); if ( !GLContext.GL_ARB_vertex_buffer_object ) { System.out.println("ARB VBO not supported!"); System.exit(1); @@ -241,11 +241,6 @@ public final class VBOIndexTest { int_buffer.put(0, buffer_id); int_buffer.put(1, indices_buffer_id); ARBBufferObject.glDeleteBuffersARB(int_buffer); - Window.destroy(); - try { - Display.resetDisplayMode(); - } catch (Exception e) { - e.printStackTrace(); - } + Display.destroy(); } } diff --git a/src/java/org/lwjgl/test/opengl/VBOTest.java b/src/java/org/lwjgl/test/opengl/VBOTest.java index 452b0c42..2e4f026b 100644 --- a/src/java/org/lwjgl/test/opengl/VBOTest.java +++ b/src/java/org/lwjgl/test/opengl/VBOTest.java @@ -41,8 +41,8 @@ package org.lwjgl.test.opengl; -import org.lwjgl.Display; -import org.lwjgl.DisplayMode; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.DisplayMode; import org.lwjgl.Sys; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; @@ -62,9 +62,9 @@ public final class VBOTest { int mode = -1; DisplayMode[] modes = Display.getAvailableDisplayModes(); for ( int i = 0; i < modes.length; i++ ) { - if ( modes[i].width == 640 - && modes[i].height == 480 - && modes[i].bpp >= 16 ) { + if ( modes[i].getWidth() == 640 + && modes[i].getHeight() == 480 + && modes[i].getBitsPerPixel() >= 16 ) { mode = i; break; } @@ -82,7 +82,7 @@ public final class VBOTest { static { try { - Window.create("LWJGL Game Example", 16, 0, 0, 0, 0); + Display.create(); System.out.println("Created OpenGL."); } catch (Exception e) { System.err.println("Failed to create OpenGL due to " + e); @@ -108,11 +108,11 @@ public final class VBOTest { try { init(); while ( !finished ) { - Window.update(); + Display.update(); - if ( !Window.isVisible() ) + if ( !Display.isVisible() ) Thread.sleep(200); - else if ( Window.isCloseRequested() ) + else if ( Display.isCloseRequested() ) System.exit(0); mainLoop(); @@ -155,7 +155,7 @@ public final class VBOTest { private static void render() { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); GL11.glPushMatrix(); - GL11.glTranslatef(Display.getWidth() / 2, Display.getHeight() / 2, 0.0f); + GL11.glTranslatef(Display.getDisplayMode().getWidth() / 2, Display.getDisplayMode().getHeight() / 2, 0.0f); GL11.glRotatef(angle, 0, 0, 1.0f); ByteBuffer new_mapped_buffer = ARBBufferObject.glMapBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, ARBBufferObject.GL_WRITE_ONLY_ARB, @@ -180,10 +180,10 @@ public final class VBOTest { // Go into orthographic projection mode. GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); - GLU.gluOrtho2D(0, Display.getWidth(), 0, Display.getHeight()); + GLU.gluOrtho2D(0, Display.getDisplayMode().getWidth(), 0, Display.getDisplayMode().getHeight()); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); - GL11.glViewport(0, 0, Display.getWidth(), Display.getHeight()); + GL11.glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight()); if ( !GLContext.GL_ARB_vertex_buffer_object ) { System.out.println("ARB VBO not supported!"); System.exit(1); @@ -209,11 +209,6 @@ public final class VBOTest { IntBuffer int_buffer = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer(); int_buffer.put(0, buffer_id); ARBBufferObject.glDeleteBuffersARB(int_buffer); - Window.destroy(); - try { - Display.resetDisplayMode(); - } catch (Exception e) { - e.printStackTrace(); - } + Display.destroy(); } } diff --git a/src/java/org/lwjgl/test/opengl/shaders/ShadersTest.java b/src/java/org/lwjgl/test/opengl/shaders/ShadersTest.java index b2600ec1..ab0948f5 100644 --- a/src/java/org/lwjgl/test/opengl/shaders/ShadersTest.java +++ b/src/java/org/lwjgl/test/opengl/shaders/ShadersTest.java @@ -38,12 +38,16 @@ package org.lwjgl.test.opengl.shaders; -import org.lwjgl.*; +import org.lwjgl.LWJGLException; +import org.lwjgl.Sys; +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.DisplayMode; +import org.lwjgl.opengl.PixelFormat; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GLContext; -import org.lwjgl.opengl.Window; +import org.lwjgl.opengl.Display; import org.lwjgl.opengl.glu.GLU; import org.lwjgl.opengl.glu.Sphere; @@ -77,7 +81,7 @@ public final class ShadersTest { long lastFrameTime = 0; while ( run ) { - if (!Window.isVisible() ) + if (!Display.isVisible() ) Thread.yield(); else { // This is the current frame time. @@ -105,9 +109,9 @@ public final class ShadersTest { GL11.glPushMatrix(); } - Window.update(); + Display.update(); - if ( Window.isCloseRequested() ) + if ( Display.isCloseRequested() ) break; } @@ -133,7 +137,7 @@ public final class ShadersTest { try { System.out.println("Setting display mode to: " + displayMode); Display.setDisplayMode(displayMode); - Window.create("OpenGL Shaders Test", displayMode.bpp, 8, 24, 0); + Display.create(new PixelFormat(8, 24, 0)); } catch (LWJGLException e) { kill(e.getMessage()); } @@ -170,11 +174,11 @@ public final class ShadersTest { argsError(); } - GL11.glViewport(0, 0, displayMode.width, displayMode.height); + GL11.glViewport(0, 0, displayMode.getWidth(), displayMode.getHeight()); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); - GLU.gluPerspective(45, displayMode.width / (float)displayMode.height, 1.0f, 10.0f); + GLU.gluPerspective(45, displayMode.getWidth() / (float)displayMode.getHeight(), 1.0f, 10.0f); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); @@ -259,11 +263,11 @@ public final class ShadersTest { } static int getDisplayWidth() { - return displayMode.width; + return displayMode.getWidth(); } static int getDisplayHeight() { - return displayMode.height; + return displayMode.getHeight(); } static float getSin() { @@ -284,8 +288,8 @@ public final class ShadersTest { for ( int i = 0; i < modes.length; i++ ) { DisplayMode mode = modes[i]; - if ( mode.width == width && mode.height == height && mode.freq <= 85 ) { - if ( bestMode == null || (mode.bpp >= bestMode.bpp && mode.freq > bestMode.freq) ) + if ( mode.getWidth() == width && mode.getHeight() == height && mode.getFrequency() <= 85 ) { + if ( bestMode == null || (mode.getBitsPerPixel() >= bestMode.getBitsPerPixel() && mode.getFrequency() > bestMode.getFrequency()) ) bestMode = mode; } } @@ -298,10 +302,8 @@ public final class ShadersTest { if ( shader != null ) shader.cleanup(); - if ( Window.isCreated() ) - Window.destroy(); - - Display.resetDisplayMode(); + if ( Display.isCreated() ) + Display.destroy(); } private static void argsError() { @@ -335,4 +337,4 @@ public final class ShadersTest { System.exit(-1); } -} \ No newline at end of file +}