|
From: Elias N. <eli...@us...> - 2004-11-02 12:49:14
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25783/src/java/org/lwjgl/opengl Modified Files: Display.java Added Files: DisplayImplementation.java LinuxDisplay.java Win32Display.java Log Message: Split out native implementation of Display/Mouse/Keyboard into implementers of DisplayImplementation --- NEW FILE: Win32Display.java --- /* * Copyright (c) 2002-2004 LWJGL 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 'LWJGL' 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.opengl; /** * This is the Display implementation interface. Display delegates * to implementors of this interface. There is one DisplayImplementation * for each supported platform. * @author elias_naur */ import java.nio.FloatBuffer; import java.nio.IntBuffer; import java.nio.ByteBuffer; import org.lwjgl.LWJGLException; final class Win32Display implements DisplayImplementation { public native void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException; public native void destroyWindow(); public native void switchDisplayMode(DisplayMode mode) throws LWJGLException; public native void resetDisplayMode(); public native int getGammaRampLength(); public native void setGammaRamp(FloatBuffer gammaRamp) throws LWJGLException; public native String getAdapter(); public native String getVersion(); public native DisplayMode init(); public native void setTitle(String title); public native boolean isCloseRequested(); public native boolean isVisible(); public native boolean isActive(); public native boolean isDirty(); public native void swapBuffers(); public native void makeCurrent() throws LWJGLException; public native void createContext(PixelFormat pixel_format) throws LWJGLException; public native void destroyContext(); public native void update(); public native void setVSyncEnabled(boolean sync); public native void reshape(int x, int y, int width, int height); public native DisplayMode[] getAvailableDisplayModes(); /* Mouse */ public native boolean hasWheel(); public native int getButtonCount(); public native void createMouse(); public native void destroyMouse(); public native void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons); public native void enableMouseBuffer() throws LWJGLException; public native int readMouse(IntBuffer buffer, int buffer_position); public native void grabMouse(boolean grab); public native int getNativeCursorCaps(); public native void setNativeCursor(ByteBuffer handle) throws LWJGLException; public native int getMinCursorSize(); public native int getMaxCursorSize(); /* Keyboard */ public native void createKeyboard() throws LWJGLException; public native void destroyKeyboard(); public native void pollKeyboard(ByteBuffer keyDownBuffer); public native int readKeyboard(IntBuffer buffer, int buffer_position); public native void enableTranslation() throws LWJGLException; public native void enableKeyboardBuffer() throws LWJGLException; public native int isStateKeySet(int key); } --- NEW FILE: DisplayImplementation.java --- /* * Copyright (c) 2002-2004 LWJGL 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 'LWJGL' 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.opengl; /** * This is the Display implementation interface. Display delegates * to implementors of this interface. There is one DisplayImplementation * for each supported platform. * @author elias_naur */ import java.nio.FloatBuffer; import java.nio.IntBuffer; import java.nio.ByteBuffer; import org.lwjgl.LWJGLException; public interface DisplayImplementation { public void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException; public void destroyWindow(); public void switchDisplayMode(DisplayMode mode) throws LWJGLException; /** * Reset the display mode to whatever it was when LWJGL was initialized. * Fails silently. */ public void resetDisplayMode(); /** * Return the length of the gamma ramp arrays. Returns 0 if gamma settings are * unsupported. * * @return the length of each gamma ramp array, or 0 if gamma settings are unsupported. */ public int getGammaRampLength(); /** * Native method to set the gamma ramp. */ public void setGammaRamp(FloatBuffer gammaRamp) throws LWJGLException; /** * Get the driver adapter string. This is a unique string describing the actual card's hardware, eg. "Geforce2", "PS2", * "Radeon9700". If the adapter cannot be determined, this function returns null. * @return a String */ public String getAdapter(); /** * Get the driver version. This is a vendor/adapter specific version string. If the version cannot be determined, * this function returns null. * @return a String */ public String getVersion(); /** * Initialize and return the current display mode. */ public DisplayMode init(); /** * Native implementation of setTitle(). This will read the window's title member * and stash it in the native title of the window. */ public void setTitle(String title); public boolean isCloseRequested(); public boolean isVisible(); public boolean isActive(); public boolean isDirty(); /** * Swap double buffers. */ public void swapBuffers(); /** * Make the window the current rendering context for GL calls. */ public void makeCurrent() throws LWJGLException; /** * Create the native OpenGL context. * @throws LWJGLException */ public void createContext(PixelFormat pixel_format) throws LWJGLException; public void destroyContext(); /** * Updates the windows internal state. This must be called at least once per video frame * to handle window close requests, moves, paints, etc. */ public void update(); public void setVSyncEnabled(boolean sync); public void reshape(int x, int y, int width, int height); /** * Native method for getting displaymodes */ public DisplayMode[] getAvailableDisplayModes(); /* * Mouse methods */ /** Native query of wheel support */ public boolean hasWheel(); /** Native query of button count */ public int getButtonCount(); /** * Native method to create the mouse. * * @return true if the mouse was created */ public void createMouse(); /** * Native method the destroy the mouse */ public void destroyMouse(); /** * Native method to poll the mouse */ public void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons); /** * Native method to enable the buffer * @return the event buffer, * or null if no buffer can be allocated */ public void enableMouseBuffer() throws LWJGLException; /** * Native method to read the keyboard buffer * @return the total number of events read. */ public int readMouse(IntBuffer buffer, int buffer_position); public void grabMouse(boolean grab); /** * Native function to determine native cursor support */ public int getNativeCursorCaps(); /** Native method to set the native cursor */ public void setNativeCursor(ByteBuffer handle) throws LWJGLException; /** Native method returning the minimum cursor size */ public int getMinCursorSize(); /** Native method returning the maximum cursor size */ public int getMaxCursorSize(); /* * Keyboard methods */ /** * Native method to create the keyboard */ public void createKeyboard() throws LWJGLException; /** * Native method to destroy the keyboard */ public void destroyKeyboard(); /** * Native method to poll the keyboard. * * @param keyDownBufferAddress the address of a 256-byte buffer to place * key states in. */ public void pollKeyboard(ByteBuffer keyDownBuffer); /** * Native method to read the keyboard buffer * @return the total number of events read. */ public int readKeyboard(IntBuffer buffer, int buffer_position); /** * Native method to enable the translation buffer */ public void enableTranslation() throws LWJGLException; /** * Native method to enable the buffer * @return the event buffer, * or null if no buffer can be allocated */ public void enableKeyboardBuffer() throws LWJGLException; public int isStateKeySet(int key); } --- NEW FILE: LinuxDisplay.java --- /* * Copyright (c) 2002-2004 LWJGL 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 'LWJGL' 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.opengl; /** * This is the Display implementation interface. Display delegates * to implementors of this interface. There is one DisplayImplementation * for each supported platform. * @author elias_naur */ import java.nio.FloatBuffer; import java.nio.IntBuffer; import java.nio.ByteBuffer; import org.lwjgl.LWJGLException; final class LinuxDisplay implements DisplayImplementation { public native void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException; public native void destroyWindow(); public native void switchDisplayMode(DisplayMode mode) throws LWJGLException; public native void resetDisplayMode(); public native int getGammaRampLength(); public native void setGammaRamp(FloatBuffer gammaRamp) throws LWJGLException; public native String getAdapter(); public native String getVersion(); public native DisplayMode init(); public native void setTitle(String title); public native boolean isCloseRequested(); public native boolean isVisible(); public native boolean isActive(); public native boolean isDirty(); public native void swapBuffers(); public native void makeCurrent() throws LWJGLException; public native void createContext(PixelFormat pixel_format) throws LWJGLException; public native void destroyContext(); public native void update(); public native void setVSyncEnabled(boolean sync); public native void reshape(int x, int y, int width, int height); public native DisplayMode[] getAvailableDisplayModes(); /* Mouse */ public native boolean hasWheel(); public native int getButtonCount(); public native void createMouse(); public native void destroyMouse(); public native void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons); public native void enableMouseBuffer() throws LWJGLException; public native int readMouse(IntBuffer buffer, int buffer_position); public native void grabMouse(boolean grab); public native int getNativeCursorCaps(); public native void setNativeCursor(ByteBuffer handle) throws LWJGLException; public native int getMinCursorSize(); public native int getMaxCursorSize(); /* Keyboard */ public native void createKeyboard() throws LWJGLException; public native void destroyKeyboard(); public native void pollKeyboard(ByteBuffer keyDownBuffer); public native int readKeyboard(IntBuffer buffer, int buffer_position); public native void enableTranslation() throws LWJGLException; public native void enableKeyboardBuffer() throws LWJGLException; public native int isStateKeySet(int key); } Index: Display.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/Display.java,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- Display.java 1 Nov 2004 23:13:30 -0000 1.25 +++ Display.java 2 Nov 2004 12:48:57 -0000 1.26 @@ -56,21 +56,14 @@ public final class Display { - /** The current display mode, if created */ - private static DisplayMode current_mode; + /** The display implementor */ + private final static DisplayImplementation display_impl; /** The initial display mode */ private final static DisplayMode initial_mode; - static { - Sys.initialize(); - current_mode = initial_mode = init(); - Runtime.getRuntime().addShutdownHook(new Thread() { - public void run() { - reset(); - } - }); - } + /** The current display mode, if created */ + private static DisplayMode current_mode; /** Timer for sync() */ private static long timeNow, timeThen; @@ -96,6 +89,38 @@ /** A unique context object, so we can track different contexts between creates() and destroys() */ private static Display context; + static { + Sys.initialize(); + display_impl = createDisplayImplementation(); + current_mode = initial_mode = display_impl.init(); + Runtime.getRuntime().addShutdownHook(new Thread() { + public void run() { + reset(); + } + }); + } + + private final static DisplayImplementation createDisplayImplementation() { + String class_name; + String os_name = System.getProperty("os.name"); + if (os_name.startsWith("Linux")) { + class_name = "org.lwjgl.opengl.LinuxDisplay"; + } else if (os_name.startsWith("Windows")) { + class_name = "org.lwjgl.opengl.Win32Display"; + } else + throw new IllegalStateException("The platform " + os_name + " is not supported"); + try { + Class display_class = Class.forName(class_name); + return (DisplayImplementation)display_class.newInstance(); + } catch (ClassNotFoundException e) { + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } catch (InstantiationException e) { + throw new RuntimeException(e); + } + } + /** * Only constructed by ourselves */ @@ -113,7 +138,7 @@ * @return an array of all display modes the system reckons it can handle. */ public static DisplayMode[] getAvailableDisplayModes() { - DisplayMode[] unfilteredModes = nGetAvailableDisplayModes(); + DisplayMode[] unfilteredModes = display_impl.getAvailableDisplayModes(); if (unfilteredModes == null) { return new DisplayMode[0]; @@ -132,11 +157,6 @@ } /** - * Native method for getting displaymodes - */ - private static native DisplayMode[] nGetAvailableDisplayModes(); - - /** * Return the current display mode, as set by setDisplayMode(). * @return The current display mode */ @@ -165,8 +185,8 @@ switchDisplayMode(); createWindow(); } catch (LWJGLException e) { - destroyContext(); - resetDisplayMode(); + display_impl.destroyContext(); + display_impl.resetDisplayMode(); throw e; } } @@ -179,14 +199,12 @@ private static void createWindow() throws LWJGLException { x = Math.max(0, Math.min(initial_mode.getWidth() - current_mode.getWidth(), x)); y = Math.max(0, Math.min(initial_mode.getHeight() - current_mode.getHeight(), y)); - nCreateWindow(current_mode, fullscreen, (fullscreen) ? 0 : x, (fullscreen) ? 0 : y); - nSetTitle(title); + display_impl.createWindow(current_mode, fullscreen, (fullscreen) ? 0 : x, (fullscreen) ? 0 : y); + setTitle(title); initControls(); - nSetVSyncEnabled(vsync); + setVSyncEnabled(vsync); } - private static native void nCreateWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException; - private static void destroyWindow() { // Automatically destroy keyboard, mouse, and controller if (Mouse.isCreated()) { @@ -198,25 +216,15 @@ if (Controller.isCreated()) { Controller.destroy(); } - nDestroyWindow(); + display_impl.destroyWindow(); } - private static native void nDestroyWindow(); - private static void switchDisplayMode() throws LWJGLException { if (!current_mode.isFullscreen()) throw new LWJGLException("The current DisplayMode instance cannot be used for fullscreen mode"); - nSwitchDisplayMode(current_mode); + display_impl.switchDisplayMode(current_mode); } - private static native void nSwitchDisplayMode(DisplayMode mode) throws LWJGLException; - - /** - * Reset the display mode to whatever it was when LWJGL was initialized. - * Fails silently. - */ - private static native void resetDisplayMode(); - /** * Set the display configuration to the specified gamma, brightness and contrast. * The configuration changes will be reset when destroy() is called. @@ -233,7 +241,7 @@ throw new IllegalArgumentException("Invalid brightness value"); if (contrast < 0.0f) throw new IllegalArgumentException("Invalid contrast value"); - int rampSize = getGammaRampLength(); + int rampSize = display_impl.getGammaRampLength(); if (rampSize == 0) { throw new LWJGLException("Display configuration not supported"); } @@ -253,38 +261,11 @@ rampEntry = 0.0f; gammaRamp.put(i, rampEntry); } - setGammaRamp(gammaRamp); + display_impl.setGammaRamp(gammaRamp); Sys.log("Gamma set, gamma = " + gamma + ", brightness = " + brightness + ", contrast = " + contrast); } /** - * Return the length of the gamma ramp arrays. Returns 0 if gamma settings are - * unsupported. - * - * @return the length of each gamma ramp array, or 0 if gamma settings are unsupported. - */ - private static native int getGammaRampLength(); - - /** - * Native method to set the gamma ramp. - */ - private static native void setGammaRamp(FloatBuffer gammaRamp) throws LWJGLException; - - /** - * Get the driver adapter string. This is a unique string describing the actual card's hardware, eg. "Geforce2", "PS2", - * "Radeon9700". If the adapter cannot be determined, this function returns null. - * @return a String - */ - public static native String getAdapter(); - - /** - * Get the driver version. This is a vendor/adapter specific version string. If the version cannot be determined, - * this function returns null. - * @return a String - */ - public static native String getVersion(); - - /** * Synchronize the display to a capped frame rate. Note that we are being "smart" about the * desired results in our implementation; we automatically subtract 1 from the desired framerate * to prevent just missing the frame time if vsync is set. @@ -324,11 +305,6 @@ } /** - * Initialize and return the current display mode. - */ - private static native DisplayMode init(); - - /** * @return the X coordinate of the window (always 0 for fullscreen) */ /*public static int getX() { @@ -371,12 +347,12 @@ if (fullscreen) { switchDisplayMode(); } else { - resetDisplayMode(); + display_impl.resetDisplayMode(); } createWindow(); } catch (LWJGLException e) { - destroyContext(); - resetDisplayMode(); + display_impl.destroyContext(); + display_impl.resetDisplayMode(); throw e; } } @@ -399,51 +375,39 @@ } title = newTitle; if (isCreated()) - nSetTitle(title); + display_impl.setTitle(title); } /** - * Native implementation of setTitle(). This will read the window's title member - * and stash it in the native title of the window. - */ - private static native void nSetTitle(String title); - - /** * @return true if the user or operating system has asked the window to close */ public static boolean isCloseRequested() { if (!isCreated()) throw new IllegalStateException("Cannot determine close requested state of uncreated window"); - nUpdate(); - return nIsCloseRequested(); + display_impl.update(); + return display_impl.isCloseRequested(); } - private static native boolean nIsCloseRequested(); - /** * @return true if the window is visible, false if not */ public static boolean isVisible() { if (!isCreated()) throw new IllegalStateException("Cannot determine minimized state of uncreated window"); - nUpdate(); - return nIsVisible(); + display_impl.update(); + return display_impl.isVisible(); } - private static native boolean nIsVisible(); - /** * @return true if window is active, that is, the foreground display of the operating system. */ public static boolean isActive() { if (!isCreated()) throw new IllegalStateException("Cannot determine focused state of uncreated window"); - nUpdate(); - return nIsActive(); + display_impl.update(); + return display_impl.isActive(); } - private static native boolean nIsActive(); - /** * Determine if the window's contents have been damaged by external events. * If you are writing a straightforward game rendering loop and simply paint @@ -457,12 +421,10 @@ public static boolean isDirty() { if (!isCreated()) throw new IllegalStateException("Cannot determine dirty state of uncreated window"); - nUpdate(); - return nIsDirty(); + display_impl.update(); + return display_impl.isDirty(); } - private static native boolean nIsDirty(); - /** * Update the window. This processes operating system events, and if the window is visible * clears the dirty flag and swaps the buffers. @@ -475,10 +437,10 @@ // We paint only when the window is visible or dirty if (isVisible() || isDirty()) { Util.checkGLError(); - swapBuffers(); + display_impl.swapBuffers(); } - nUpdate(); + display_impl.update(); // Poll the input devices while we're here if (Mouse.isCreated()) { @@ -494,27 +456,17 @@ } /** - * Swap double buffers. - */ - private static native void swapBuffers(); - - /** * Make the Display the current rendering context for GL calls. Also initialize native stubs. * @throws LWJGLException If the context could not be made current */ public static void makeCurrent() throws LWJGLException { if (!isCreated()) throw new IllegalStateException("No window created to make current"); - nMakeCurrent(); + display_impl.makeCurrent(); GLContext.useContext(context); } /** - * Make the window the current rendering context for GL calls. - */ - private static native void nMakeCurrent() throws LWJGLException; - - /** * Create the OpenGL context. If isFullscreen() is true or if windowed * context are not supported on the platform, the display mode will be switched to the mode returned by * getDisplayMode(), and a fullscreen context will be created. If isFullscreen() is false, a windowed context @@ -549,14 +501,14 @@ try { GLContext.loadOpenGLLibrary(); try { - createContext(pixel_format); + display_impl.createContext(pixel_format); try { context = new Display(); createWindow(); makeCurrent(); initContext(); } catch (LWJGLException e) { - destroyContext(); + display_impl.destroyContext(); context = null; throw e; } @@ -565,19 +517,11 @@ throw e; } } catch (LWJGLException e) { - resetDisplayMode(); + display_impl.resetDisplayMode(); throw e; } } - /** - * Create the native OpenGL context. - * @throws LWJGLException - */ - private static native void createContext(PixelFormat pixel_format) throws LWJGLException; - - private static native void destroyContext(); - private static void initContext() { // Put the window into orthographic projection mode with 1:1 pixel ratio. // We haven't used GLU here to do this to avoid an unnecessary dependency. @@ -589,6 +533,10 @@ GL11.glViewport(0, 0, current_mode.getWidth(), current_mode.getHeight()); } + public static DisplayImplementation getImplementation() { + return display_impl; + } + private static void initControls() { // Automatically create mouse, keyboard and controller if (!Boolean.getBoolean("org.lwjgl.opengl.Display.noinput")) { @@ -641,7 +589,7 @@ } destroyWindow(); - destroyContext(); + display_impl.destroyContext(); GLContext.unloadOpenGLLibrary(); context = null; try { @@ -657,7 +605,7 @@ * in the static constructor */ private static void reset() { - resetDisplayMode(); + display_impl.resetDisplayMode(); current_mode = initial_mode; } @@ -676,12 +624,6 @@ } /** - * Updates the windows internal state. This must be called at least once per video frame - * to handle window close requests, moves, paints, etc. - */ - private static native void nUpdate(); - - /** * Enable or disable vertical monitor synchronization. This call is a best-attempt at changing * the vertical refresh synchronization of the monitor, and is not guaranteed to be successful. * @param sync true to synchronize; false to ignore synchronization @@ -689,11 +631,9 @@ public static void setVSyncEnabled(boolean sync) { vsync = sync; if (isCreated()) - nSetVSyncEnabled(vsync); + display_impl.setVSyncEnabled(vsync); } - 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 @@ -705,17 +645,34 @@ if (fullscreen) { return; } - - // offset if already created - if(isCreated()) { - x = Math.max(0, Math.min(initial_mode.getWidth() - current_mode.getWidth(), x)); - y = Math.max(0, Math.min(initial_mode.getHeight() - current_mode.getHeight(), y)); - nReshape(x, y, current_mode.getWidth(), current_mode.getHeight()); - } - // cache position - Display.x = x; - Display.y = y; + // offset if already created + if(isCreated()) { + x = Math.max(0, Math.min(initial_mode.getWidth() - current_mode.getWidth(), x)); + y = Math.max(0, Math.min(initial_mode.getHeight() - current_mode.getHeight(), y)); + display_impl.reshape(x, y, current_mode.getWidth(), current_mode.getHeight()); + } + + // cache position + Display.x = x; + Display.y = y; + } + + /** + * Get the driver adapter string. This is a unique string describing the actual card's hardware, eg. "Geforce2", "PS2", + * "Radeon9700". If the adapter cannot be determined, this function returns null. + * @return a String + */ + public static String getAdapter() { + return display_impl.getAdapter(); + } + + /** + * Get the driver version. This is a vendor/adapter specific version string. If the version cannot be determined, + * this function returns null. + * @return a String + */ + public static String getVersion() { + return display_impl.getVersion(); } - private static native void nReshape(int x, int y, int width, int height); } |