Code cleanup
This commit is contained in:
parent
3041c0494d
commit
83dd8b6bbc
|
@ -1,31 +1,31 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2002-2004 LWJGL Project
|
* Copyright (c) 2002-2004 LWJGL Project
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are
|
* modification, are permitted provided that the following conditions are
|
||||||
* met:
|
* met:
|
||||||
*
|
*
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* * Neither the name of 'LWJGL' nor the names of
|
* * Neither the name of 'LWJGL' nor the names of
|
||||||
* its contributors may be used to endorse or promote products derived
|
* its contributors may be used to endorse or promote products derived
|
||||||
* from this software without specific prior written permission.
|
* from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
@ -34,12 +34,12 @@ package org.lwjgl.opengl;
|
||||||
/**
|
/**
|
||||||
* This is the abstract class for a Display in LWJGL. LWJGL displays have some
|
* This is the abstract class for a Display in LWJGL. LWJGL displays have some
|
||||||
* peculiar characteristics:
|
* peculiar characteristics:
|
||||||
*
|
*
|
||||||
* - the display may be closeable by the user or operating system, and may be minimized
|
* - the display may be closeable by the user or operating system, and may be minimized
|
||||||
* by the user or operating system
|
* by the user or operating system
|
||||||
* - only one display may ever be open at once
|
* - only one display may ever be open at once
|
||||||
* - the operating system may or may not be able to do fullscreen or windowed displays.
|
* - the operating system may or may not be able to do fullscreen or windowed displays.
|
||||||
*
|
*
|
||||||
* @author foo
|
* @author foo
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -57,11 +57,11 @@ import org.lwjgl.input.Mouse;
|
||||||
public final class Display {
|
public final class Display {
|
||||||
|
|
||||||
/** The display implementor */
|
/** The display implementor */
|
||||||
private final static DisplayImplementation display_impl;
|
private static final DisplayImplementation display_impl;
|
||||||
|
|
||||||
/** The initial display mode */
|
/** The initial display mode */
|
||||||
private final static DisplayMode initial_mode;
|
private static final DisplayMode initial_mode;
|
||||||
|
|
||||||
/** The current display mode, if created */
|
/** The current display mode, if created */
|
||||||
private static DisplayMode current_mode;
|
private static DisplayMode current_mode;
|
||||||
|
|
||||||
|
@ -85,10 +85,10 @@ public final class Display {
|
||||||
|
|
||||||
/** VSync */
|
/** VSync */
|
||||||
private static boolean vsync;
|
private static boolean vsync;
|
||||||
|
|
||||||
/** A unique context object, so we can track different contexts between creates() and destroys() */
|
/** A unique context object, so we can track different contexts between creates() and destroys() */
|
||||||
private static Display context;
|
private static Display context;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
Sys.initialize();
|
Sys.initialize();
|
||||||
display_impl = createDisplayImplementation();
|
display_impl = createDisplayImplementation();
|
||||||
|
@ -100,7 +100,7 @@ public final class Display {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static DisplayImplementation createDisplayImplementation() {
|
private static DisplayImplementation createDisplayImplementation() {
|
||||||
String class_name;
|
String class_name;
|
||||||
String os_name = System.getProperty("os.name");
|
String os_name = System.getProperty("os.name");
|
||||||
if (os_name.startsWith("Linux")) {
|
if (os_name.startsWith("Linux")) {
|
||||||
|
@ -284,12 +284,14 @@ public final class Display {
|
||||||
}
|
}
|
||||||
timeThen = timeNow;
|
timeThen = timeNow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static long timeLate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alternative sync method which works better on triple-buffered GL displays.
|
* Alternative sync method which works better on triple-buffered GL displays.
|
||||||
|
*
|
||||||
* @param fps The desired frame rate, in frames per second
|
* @param fps The desired frame rate, in frames per second
|
||||||
*/
|
*/
|
||||||
private static long timeLate;
|
|
||||||
public static void sync2(int fps) {
|
public static void sync2(int fps) {
|
||||||
long gapTo = Sys.getTimerResolution() / fps + timeThen;
|
long gapTo = Sys.getTimerResolution() / fps + timeThen;
|
||||||
timeNow = Sys.getTime();
|
timeNow = Sys.getTime();
|
||||||
|
@ -321,7 +323,7 @@ public final class Display {
|
||||||
return (fullscreen) ? 0 : y;
|
return (fullscreen) ? 0 : y;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the title of the window
|
* @return the title of the window
|
||||||
*/
|
*/
|
||||||
|
@ -417,7 +419,7 @@ public final class Display {
|
||||||
* every frame regardless, you can ignore this flag altogether. If you are
|
* every frame regardless, you can ignore this flag altogether. If you are
|
||||||
* trying to be kind to other processes you can check this flag and only
|
* trying to be kind to other processes you can check this flag and only
|
||||||
* redraw when it returns true. The flag is cleared when update() or isDirty() is called.
|
* redraw when it returns true. The flag is cleared when update() or isDirty() is called.
|
||||||
*
|
*
|
||||||
* @return true if the window has been damaged by external changes
|
* @return true if the window has been damaged by external changes
|
||||||
* and needs to repaint itself
|
* and needs to repaint itself
|
||||||
*/
|
*/
|
||||||
|
@ -436,7 +438,7 @@ public final class Display {
|
||||||
public static void processMessages() {
|
public static void processMessages() {
|
||||||
if (!isCreated())
|
if (!isCreated())
|
||||||
throw new IllegalStateException("Cannot update uncreated window");
|
throw new IllegalStateException("Cannot update uncreated window");
|
||||||
|
|
||||||
display_impl.update();
|
display_impl.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -448,13 +450,13 @@ public final class Display {
|
||||||
public static void update() {
|
public static void update() {
|
||||||
if (!isCreated())
|
if (!isCreated())
|
||||||
throw new IllegalStateException("Cannot update uncreated window");
|
throw new IllegalStateException("Cannot update uncreated window");
|
||||||
|
|
||||||
// We paint only when the window is visible or dirty
|
// We paint only when the window is visible or dirty
|
||||||
if (isVisible() || isDirty()) {
|
if (isVisible() || isDirty()) {
|
||||||
Util.checkGLError();
|
Util.checkGLError();
|
||||||
display_impl.swapBuffers();
|
display_impl.swapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
processMessages();
|
processMessages();
|
||||||
|
|
||||||
// Poll the input devices while we're here
|
// Poll the input devices while we're here
|
||||||
|
@ -480,7 +482,7 @@ public final class Display {
|
||||||
display_impl.makeCurrent();
|
display_impl.makeCurrent();
|
||||||
GLContext.useContext(context);
|
GLContext.useContext(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the OpenGL context. If isFullscreen() is true or if windowed
|
* 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
|
* context are not supported on the platform, the display mode will be switched to the mode returned by
|
||||||
|
@ -602,7 +604,7 @@ public final class Display {
|
||||||
if (!isCreated()) {
|
if (!isCreated()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
destroyWindow();
|
destroyWindow();
|
||||||
display_impl.destroyContext();
|
display_impl.destroyContext();
|
||||||
GLContext.unloadOpenGLLibrary();
|
GLContext.unloadOpenGLLibrary();
|
||||||
|
@ -623,7 +625,7 @@ public final class Display {
|
||||||
display_impl.resetDisplayMode();
|
display_impl.resetDisplayMode();
|
||||||
current_mode = initial_mode;
|
current_mode = initial_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the unique Display context (or null, if the Display has not been created)
|
* @return the unique Display context (or null, if the Display has not been created)
|
||||||
*/
|
*/
|
||||||
|
@ -654,7 +656,7 @@ public final class Display {
|
||||||
* The window is clamped to remain entirely on the screen. If you attempt
|
* 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
|
* to position the window such that it would extend off the screen, the window
|
||||||
* is simply placed as close to the edge as possible.
|
* is simply placed as close to the edge as possible.
|
||||||
* @param x, y The new window location
|
* @param x , y The new window location
|
||||||
*/
|
*/
|
||||||
public static void setLocation(int x, int y) {
|
public static void setLocation(int x, int y) {
|
||||||
if (fullscreen) {
|
if (fullscreen) {
|
||||||
|
@ -670,9 +672,9 @@ public final class Display {
|
||||||
|
|
||||||
// cache position
|
// cache position
|
||||||
Display.x = x;
|
Display.x = x;
|
||||||
Display.y = y;
|
Display.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the driver adapter string. This is a unique string describing the actual card's hardware, eg. "Geforce2", "PS2",
|
* 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.
|
* "Radeon9700". If the adapter cannot be determined, this function returns null.
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2002-2004 LWJGL Project
|
* Copyright (c) 2002-2004 LWJGL Project
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are
|
* modification, are permitted provided that the following conditions are
|
||||||
* met:
|
* met:
|
||||||
*
|
*
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* * Neither the name of 'LWJGL' nor the names of
|
* * Neither the name of 'LWJGL' nor the names of
|
||||||
* its contributors may be used to endorse or promote products derived
|
* its contributors may be used to endorse or promote products derived
|
||||||
* from this software without specific prior written permission.
|
* from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
@ -44,16 +44,18 @@ import java.nio.ByteBuffer;
|
||||||
import org.lwjgl.LWJGLException;
|
import org.lwjgl.LWJGLException;
|
||||||
|
|
||||||
public interface DisplayImplementation {
|
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;
|
void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException;
|
||||||
|
|
||||||
|
void destroyWindow();
|
||||||
|
|
||||||
|
void switchDisplayMode(DisplayMode mode) throws LWJGLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset the display mode to whatever it was when LWJGL was initialized.
|
* Reset the display mode to whatever it was when LWJGL was initialized.
|
||||||
* Fails silently.
|
* Fails silently.
|
||||||
*/
|
*/
|
||||||
public void resetDisplayMode();
|
void resetDisplayMode();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the length of the gamma ramp arrays. Returns 0 if gamma settings are
|
* Return the length of the gamma ramp arrays. Returns 0 if gamma settings are
|
||||||
|
@ -61,182 +63,178 @@ public interface DisplayImplementation {
|
||||||
*
|
*
|
||||||
* @return the length of each gamma ramp array, or 0 if gamma settings are unsupported.
|
* @return the length of each gamma ramp array, or 0 if gamma settings are unsupported.
|
||||||
*/
|
*/
|
||||||
public int getGammaRampLength();
|
int getGammaRampLength();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Native method to set the gamma ramp.
|
* Native method to set the gamma ramp.
|
||||||
*/
|
*/
|
||||||
public void setGammaRamp(FloatBuffer gammaRamp) throws LWJGLException;
|
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",
|
* 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.
|
* "Radeon9700". If the adapter cannot be determined, this function returns null.
|
||||||
* @return a String
|
* @return a String
|
||||||
*/
|
*/
|
||||||
public String getAdapter();
|
String getAdapter();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the driver version. This is a vendor/adapter specific version string. If the version cannot be determined,
|
* Get the driver version. This is a vendor/adapter specific version string. If the version cannot be determined,
|
||||||
* this function returns null.
|
* this function returns null.
|
||||||
* @return a String
|
* @return a String
|
||||||
*/
|
*/
|
||||||
public String getVersion();
|
String getVersion();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize and return the current display mode.
|
* Initialize and return the current display mode.
|
||||||
*/
|
*/
|
||||||
public DisplayMode init();
|
DisplayMode init();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Native implementation of setTitle(). This will read the window's title member
|
* Native implementation of setTitle(). This will read the window's title member
|
||||||
* and stash it in the native title of the window.
|
* and stash it in the native title of the window.
|
||||||
*/
|
*/
|
||||||
public void setTitle(String title);
|
void setTitle(String title);
|
||||||
|
|
||||||
public boolean isCloseRequested();
|
boolean isCloseRequested();
|
||||||
|
|
||||||
public boolean isVisible();
|
boolean isVisible();
|
||||||
public boolean isActive();
|
boolean isActive();
|
||||||
|
|
||||||
public boolean isDirty();
|
boolean isDirty();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Swap double buffers.
|
* Swap double buffers.
|
||||||
*/
|
*/
|
||||||
public void swapBuffers();
|
void swapBuffers();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make the window the current rendering context for GL calls.
|
* Make the window the current rendering context for GL calls.
|
||||||
*/
|
*/
|
||||||
public void makeCurrent() throws LWJGLException;
|
void makeCurrent() throws LWJGLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the native OpenGL context.
|
* Create the native OpenGL context.
|
||||||
* @throws LWJGLException
|
* @throws LWJGLException
|
||||||
*/
|
*/
|
||||||
public void createContext(PixelFormat pixel_format) throws LWJGLException;
|
void createContext(PixelFormat pixel_format) throws LWJGLException;
|
||||||
|
|
||||||
public void destroyContext();
|
void destroyContext();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the windows internal state. This must be called at least once per video frame
|
* Updates the windows internal state. This must be called at least once per video frame
|
||||||
* to handle window close requests, moves, paints, etc.
|
* to handle window close requests, moves, paints, etc.
|
||||||
*/
|
*/
|
||||||
public void update();
|
void update();
|
||||||
|
|
||||||
public void setVSyncEnabled(boolean sync);
|
void setVSyncEnabled(boolean sync);
|
||||||
|
|
||||||
public void reshape(int x, int y, int width, int height);
|
void reshape(int x, int y, int width, int height);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Native method for getting displaymodes
|
* Native method for getting displaymodes
|
||||||
*/
|
*/
|
||||||
public DisplayMode[] getAvailableDisplayModes();
|
DisplayMode[] getAvailableDisplayModes();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mouse methods
|
* Mouse methods
|
||||||
*/
|
*/
|
||||||
/** Native query of wheel support */
|
/** Native query of wheel support */
|
||||||
public boolean hasWheel();
|
boolean hasWheel();
|
||||||
|
|
||||||
/** Native query of button count */
|
/** Native query of button count */
|
||||||
public int getButtonCount();
|
int getButtonCount();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Native method to create the mouse.
|
* Native method to create the mouse.
|
||||||
*
|
|
||||||
* @return true if the mouse was created
|
|
||||||
*/
|
*/
|
||||||
public void createMouse();
|
void createMouse();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Native method the destroy the mouse
|
* Native method the destroy the mouse
|
||||||
*/
|
*/
|
||||||
public void destroyMouse();
|
void destroyMouse();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Native method to poll the mouse
|
* Native method to poll the mouse
|
||||||
*/
|
*/
|
||||||
public void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons);
|
void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Native method to enable the buffer
|
* Native method to enable the buffer
|
||||||
* @return the event buffer,
|
|
||||||
* or null if no buffer can be allocated
|
|
||||||
*/
|
*/
|
||||||
public void enableMouseBuffer() throws LWJGLException;
|
void enableMouseBuffer() throws LWJGLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Native method to read the keyboard buffer
|
* Native method to read the keyboard buffer
|
||||||
|
*
|
||||||
* @return the total number of events read.
|
* @return the total number of events read.
|
||||||
*/
|
*/
|
||||||
public int readMouse(IntBuffer buffer, int buffer_position);
|
int readMouse(IntBuffer buffer, int buffer_position);
|
||||||
|
|
||||||
public void grabMouse(boolean grab);
|
|
||||||
|
void grabMouse(boolean grab);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Native function to determine native cursor support
|
* Native function to determine native cursor support
|
||||||
*/
|
*/
|
||||||
public int getNativeCursorCaps();
|
int getNativeCursorCaps();
|
||||||
|
|
||||||
/** Native method to set the native cursor */
|
/** Native method to set the native cursor */
|
||||||
public void setNativeCursor(Object handle) throws LWJGLException;
|
void setNativeCursor(Object handle) throws LWJGLException;
|
||||||
|
|
||||||
/** Native method returning the minimum cursor size */
|
/** Native method returning the minimum cursor size */
|
||||||
public int getMinCursorSize();
|
int getMinCursorSize();
|
||||||
|
|
||||||
/** Native method returning the maximum cursor size */
|
/** Native method returning the maximum cursor size */
|
||||||
public int getMaxCursorSize();
|
int getMaxCursorSize();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Keyboard methods
|
* Keyboard methods
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Native method to create the keyboard
|
* Native method to create the keyboard
|
||||||
*/
|
*/
|
||||||
public void createKeyboard() throws LWJGLException;
|
void createKeyboard() throws LWJGLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Native method to destroy the keyboard
|
* Native method to destroy the keyboard
|
||||||
*/
|
*/
|
||||||
public void destroyKeyboard();
|
void destroyKeyboard();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Native method to poll the keyboard.
|
* Native method to poll the keyboard.
|
||||||
*
|
*
|
||||||
* @param keyDownBufferAddress the address of a 256-byte buffer to place
|
* @param keyDownBuffer the address of a 256-byte buffer to place
|
||||||
* key states in.
|
* key states in.
|
||||||
*/
|
*/
|
||||||
public void pollKeyboard(ByteBuffer keyDownBuffer);
|
void pollKeyboard(ByteBuffer keyDownBuffer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Native method to read the keyboard buffer
|
* Native method to read the keyboard buffer
|
||||||
* @return the total number of events read.
|
* @return the total number of events read.
|
||||||
*/
|
*/
|
||||||
public int readKeyboard(IntBuffer buffer, int buffer_position);
|
int readKeyboard(IntBuffer buffer, int buffer_position);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Native method to enable the translation buffer
|
* Native method to enable the translation buffer
|
||||||
*/
|
*/
|
||||||
public void enableTranslation() throws LWJGLException;
|
void enableTranslation() throws LWJGLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Native method to enable the buffer
|
* Native method to enable the buffer
|
||||||
* @return the event buffer,
|
|
||||||
* or null if no buffer can be allocated
|
|
||||||
*/
|
*/
|
||||||
public void enableKeyboardBuffer() throws LWJGLException;
|
void enableKeyboardBuffer() throws LWJGLException;
|
||||||
|
|
||||||
public int isStateKeySet(int key);
|
|
||||||
|
|
||||||
/** Native cursor handles */
|
|
||||||
public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException;
|
|
||||||
|
|
||||||
public void destroyCursor(Object cursor_handle);
|
int isStateKeySet(int key);
|
||||||
|
|
||||||
|
/** Native cursor handles */
|
||||||
|
Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException;
|
||||||
|
|
||||||
|
void destroyCursor(Object cursor_handle);
|
||||||
|
|
||||||
/* Pbuffer caps */
|
/* Pbuffer caps */
|
||||||
public int getPbufferCaps();
|
int getPbufferCaps();
|
||||||
|
|
||||||
public boolean openURL(String url);
|
boolean openURL(String url);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2002-2004 LWJGL Project
|
* Copyright (c) 2002-2004 LWJGL Project
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are
|
* modification, are permitted provided that the following conditions are
|
||||||
* met:
|
* met:
|
||||||
*
|
*
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* * Neither the name of 'LWJGL' nor the names of
|
* * Neither the name of 'LWJGL' nor the names of
|
||||||
* its contributors may be used to endorse or promote products derived
|
* its contributors may be used to endorse or promote products derived
|
||||||
* from this software without specific prior written permission.
|
* from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
@ -37,7 +37,7 @@ package org.lwjgl.opengl;
|
||||||
* This class encapsulates the properties for a given display mode.
|
* This class encapsulates the properties for a given display mode.
|
||||||
* This class is not instantiable, and is aquired from the <code>Display.
|
* This class is not instantiable, and is aquired from the <code>Display.
|
||||||
* getAvailableDisplayModes()</code> method.
|
* getAvailableDisplayModes()</code> method.
|
||||||
*
|
*
|
||||||
* @author cix_foo <cix_foo@users.sourceforge.net>
|
* @author cix_foo <cix_foo@users.sourceforge.net>
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
|
@ -62,7 +62,7 @@ public final class DisplayMode {
|
||||||
public DisplayMode(int width, int height) {
|
public DisplayMode(int width, int height) {
|
||||||
this(width, height, 0, 0, false);
|
this(width, height, 0, 0, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplayMode(int width, int height, int bpp, int freq) {
|
DisplayMode(int width, int height, int bpp, int freq) {
|
||||||
this(width, height, bpp, freq, true);
|
this(width, height, bpp, freq, true);
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ public final class DisplayMode {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for <code>DisplayMode</code> equality
|
* Tests for <code>DisplayMode</code> equality
|
||||||
*
|
*
|
||||||
* @see java.lang.Object#equals(Object)
|
* @see java.lang.Object#equals(Object)
|
||||||
*/
|
*/
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
|
@ -115,7 +115,7 @@ public final class DisplayMode {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the hashcode for this object
|
* Retrieves the hashcode for this object
|
||||||
*
|
*
|
||||||
* @see java.lang.Object#hashCode()
|
* @see java.lang.Object#hashCode()
|
||||||
*/
|
*/
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
@ -124,11 +124,11 @@ public final class DisplayMode {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a String representation of this <code>DisplayMode</code>
|
* Retrieves a String representation of this <code>DisplayMode</code>
|
||||||
*
|
*
|
||||||
* @see java.lang.Object#toString()
|
* @see java.lang.Object#toString()
|
||||||
*/
|
*/
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer(32);
|
||||||
sb.append(width);
|
sb.append(width);
|
||||||
sb.append(" x ");
|
sb.append(" x ");
|
||||||
sb.append(height);
|
sb.append(height);
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2002-2004 LWJGL Project
|
* Copyright (c) 2002-2004 LWJGL Project
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are
|
* modification, are permitted provided that the following conditions are
|
||||||
* met:
|
* met:
|
||||||
*
|
*
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* * Neither the name of 'LWJGL' nor the names of
|
* * Neither the name of 'LWJGL' nor the names of
|
||||||
* its contributors may be used to endorse or promote products derived
|
* its contributors may be used to endorse or promote products derived
|
||||||
* from this software without specific prior written permission.
|
* from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
@ -41,15 +41,18 @@ import java.nio.ByteBuffer;
|
||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
|
|
||||||
abstract class EventQueue {
|
abstract class EventQueue {
|
||||||
private final static int QUEUE_SIZE = 200;
|
|
||||||
|
private static final int QUEUE_SIZE = 200;
|
||||||
|
|
||||||
private final int event_size;
|
private final int event_size;
|
||||||
|
|
||||||
private final IntBuffer queue;
|
private final IntBuffer queue;
|
||||||
|
|
||||||
public EventQueue(int event_size) {
|
protected EventQueue(int event_size) {
|
||||||
this.event_size = event_size;
|
this.event_size = event_size;
|
||||||
this.queue = ByteBuffer.allocateDirect(QUEUE_SIZE*event_size).asIntBuffer();
|
this.queue = ByteBuffer.allocateDirect(QUEUE_SIZE*event_size).asIntBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected synchronized void clearEvents() {
|
protected synchronized void clearEvents() {
|
||||||
queue.clear();
|
queue.clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2002-2004 LWJGL Project
|
* Copyright (c) 2002-2004 LWJGL Project
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are
|
* modification, are permitted provided that the following conditions are
|
||||||
* met:
|
* met:
|
||||||
*
|
*
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* * Neither the name of 'LWJGL' nor the names of
|
* * Neither the name of 'LWJGL' nor the names of
|
||||||
* its contributors may be used to endorse or promote products derived
|
* its contributors may be used to endorse or promote products derived
|
||||||
* from this software without specific prior written permission.
|
* from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
@ -44,14 +44,15 @@ import java.nio.ByteBuffer;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
final class KeyboardEventQueue extends EventQueue implements KeyListener {
|
final class KeyboardEventQueue extends EventQueue implements KeyListener {
|
||||||
private final static int[] KEY_MAP = new int[0xffff];
|
|
||||||
private final static int EVENT_SIZE = 3;
|
private static final int[] KEY_MAP = new int[0xffff];
|
||||||
|
private static final int EVENT_SIZE = 3;
|
||||||
|
|
||||||
private final byte[] key_states = new byte[Keyboard.KEYBOARD_SIZE];
|
private final byte[] key_states = new byte[Keyboard.KEYBOARD_SIZE];
|
||||||
|
|
||||||
/** Event scratch array */
|
/** Event scratch array */
|
||||||
private final int[] event = new int[EVENT_SIZE];
|
private final int[] event = new int[EVENT_SIZE];
|
||||||
|
|
||||||
static {
|
static {
|
||||||
KEY_MAP[KeyEvent.VK_0] = Keyboard.KEY_0;
|
KEY_MAP[KeyEvent.VK_0] = Keyboard.KEY_0;
|
||||||
KEY_MAP[KeyEvent.VK_1] = Keyboard.KEY_1;
|
KEY_MAP[KeyEvent.VK_1] = Keyboard.KEY_1;
|
||||||
|
@ -255,13 +256,13 @@ final class KeyboardEventQueue extends EventQueue implements KeyListener {
|
||||||
key_down_buffer.put(key_states);
|
key_down_buffer.put(key_states);
|
||||||
key_down_buffer.position(old_position);
|
key_down_buffer.position(old_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void handleKey(int key_code, byte state, char character) {
|
private synchronized void handleKey(int key_code, byte state, char character) {
|
||||||
int key_code_mapped = KEY_MAP[key_code];
|
int key_code_mapped = KEY_MAP[key_code];
|
||||||
if (character == KeyEvent.CHAR_UNDEFINED)
|
if ( character == KeyEvent.CHAR_UNDEFINED )
|
||||||
character = Keyboard.CHAR_NONE;
|
character = Keyboard.CHAR_NONE;
|
||||||
/* Ignore repeating presses */
|
/* Ignore repeating presses */
|
||||||
if (key_states[key_code_mapped] == state)
|
if ( key_states[key_code_mapped] == state )
|
||||||
return;
|
return;
|
||||||
key_states[key_code_mapped] = state;
|
key_states[key_code_mapped] = state;
|
||||||
int key_int_char = ((int)character) & 0xffff;
|
int key_int_char = ((int)character) & 0xffff;
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2002-2004 LWJGL Project
|
* Copyright (c) 2002-2004 LWJGL Project
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are
|
* modification, are permitted provided that the following conditions are
|
||||||
* met:
|
* met:
|
||||||
*
|
*
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* * Neither the name of 'LWJGL' nor the names of
|
* * Neither the name of 'LWJGL' nor the names of
|
||||||
* its contributors may be used to endorse or promote products derived
|
* its contributors may be used to endorse or promote products derived
|
||||||
* from this software without specific prior written permission.
|
* from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
@ -47,7 +47,7 @@ import org.lwjgl.BufferUtils;
|
||||||
import org.lwjgl.LWJGLException;
|
import org.lwjgl.LWJGLException;
|
||||||
|
|
||||||
final class LinuxDisplay implements DisplayImplementation {
|
final class LinuxDisplay implements DisplayImplementation {
|
||||||
private final static int CURSOR_HANDLE_SIZE = 8;
|
private static final int CURSOR_HANDLE_SIZE = 8;
|
||||||
|
|
||||||
public native void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException;
|
public native void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException;
|
||||||
public native void destroyWindow();
|
public native void destroyWindow();
|
||||||
|
@ -110,7 +110,7 @@ final class LinuxDisplay implements DisplayImplementation {
|
||||||
|
|
||||||
String[] browsers = {"mozilla", "opera", "konqueror", "nautilus", "galeon", "netscape"};
|
String[] browsers = {"mozilla", "opera", "konqueror", "nautilus", "galeon", "netscape"};
|
||||||
|
|
||||||
for (int i = 0; i < browsers.length; i ++) {
|
for (int i = 0; i < browsers.length; i ++) {
|
||||||
try {
|
try {
|
||||||
Runtime.getRuntime().exec(new String[] { browsers[i], url });
|
Runtime.getRuntime().exec(new String[] { browsers[i], url });
|
||||||
return true;
|
return true;
|
||||||
|
@ -119,7 +119,7 @@ final class LinuxDisplay implements DisplayImplementation {
|
||||||
e.printStackTrace(System.err);
|
e.printStackTrace(System.err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Seems to have failed
|
// Seems to have failed
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2002-2004 LWJGL Project
|
* Copyright (c) 2002-2004 LWJGL Project
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are
|
* modification, are permitted provided that the following conditions are
|
||||||
* met:
|
* met:
|
||||||
*
|
*
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* * Neither the name of 'LWJGL' nor the names of
|
* * Neither the name of 'LWJGL' nor the names of
|
||||||
* its contributors may be used to endorse or promote products derived
|
* its contributors may be used to endorse or promote products derived
|
||||||
* from this software without specific prior written permission.
|
* from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
@ -51,7 +51,6 @@ import java.lang.reflect.Proxy;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.FloatBuffer;
|
import java.nio.FloatBuffer;
|
||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -59,7 +58,7 @@ import org.lwjgl.LWJGLException;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
final class MacOSXDisplay implements DisplayImplementation {
|
final class MacOSXDisplay implements DisplayImplementation {
|
||||||
private final static int GAMMA_LENGTH = 256;
|
private static final int GAMMA_LENGTH = 256;
|
||||||
|
|
||||||
private MacOSXFrame frame;
|
private MacOSXFrame frame;
|
||||||
private MouseEventQueue mouse_queue;
|
private MouseEventQueue mouse_queue;
|
||||||
|
@ -68,11 +67,11 @@ final class MacOSXDisplay implements DisplayImplementation {
|
||||||
|
|
||||||
/* States */
|
/* States */
|
||||||
private boolean close_requested;
|
private boolean close_requested;
|
||||||
|
|
||||||
public MacOSXDisplay() {
|
MacOSXDisplay() {
|
||||||
new MacOSXApplicationListener();
|
new MacOSXApplicationListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException {
|
public void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException {
|
||||||
hideUI(fullscreen);
|
hideUI(fullscreen);
|
||||||
close_requested = false;
|
close_requested = false;
|
||||||
|
@ -100,7 +99,7 @@ final class MacOSXDisplay implements DisplayImplementation {
|
||||||
}
|
}
|
||||||
hideUI(false);
|
hideUI(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getGammaRampLength() {
|
public int getGammaRampLength() {
|
||||||
return GAMMA_LENGTH;
|
return GAMMA_LENGTH;
|
||||||
}
|
}
|
||||||
|
@ -110,11 +109,11 @@ final class MacOSXDisplay implements DisplayImplementation {
|
||||||
public String getAdapter() {
|
public String getAdapter() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getVersion() {
|
public String getVersion() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean equals(java.awt.DisplayMode awt_mode, DisplayMode mode) {
|
private boolean equals(java.awt.DisplayMode awt_mode, DisplayMode mode) {
|
||||||
return awt_mode.getWidth() == mode.getWidth() && awt_mode.getHeight() == mode.getHeight()
|
return awt_mode.getWidth() == mode.getWidth() && awt_mode.getHeight() == mode.getHeight()
|
||||||
&& awt_mode.getBitDepth() == mode.getBitsPerPixel() && awt_mode.getRefreshRate() == mode.getFrequency();
|
&& awt_mode.getBitDepth() == mode.getBitsPerPixel() && awt_mode.getRefreshRate() == mode.getFrequency();
|
||||||
|
@ -129,7 +128,7 @@ final class MacOSXDisplay implements DisplayImplementation {
|
||||||
}
|
}
|
||||||
throw new LWJGLException(mode + " is not supported");
|
throw new LWJGLException(mode + " is not supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetDisplayMode() {
|
public void resetDisplayMode() {
|
||||||
if (MacOSXFrame.getDevice().getFullScreenWindow() != null)
|
if (MacOSXFrame.getDevice().getFullScreenWindow() != null)
|
||||||
MacOSXFrame.getDevice().setFullScreenWindow(null);
|
MacOSXFrame.getDevice().setFullScreenWindow(null);
|
||||||
|
@ -138,7 +137,7 @@ final class MacOSXDisplay implements DisplayImplementation {
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void restoreGamma();
|
private native void restoreGamma();
|
||||||
|
|
||||||
private DisplayMode createLWJGLDisplayMode(java.awt.DisplayMode awt_mode) {
|
private DisplayMode createLWJGLDisplayMode(java.awt.DisplayMode awt_mode) {
|
||||||
int bit_depth;
|
int bit_depth;
|
||||||
int refresh_rate;
|
int refresh_rate;
|
||||||
|
@ -154,11 +153,11 @@ final class MacOSXDisplay implements DisplayImplementation {
|
||||||
refresh_rate = 0;
|
refresh_rate = 0;
|
||||||
return new DisplayMode(awt_mode.getWidth(), awt_mode.getHeight(), bit_depth, refresh_rate);
|
return new DisplayMode(awt_mode.getWidth(), awt_mode.getHeight(), bit_depth, refresh_rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DisplayMode init() {
|
public DisplayMode init() {
|
||||||
return createLWJGLDisplayMode(MacOSXFrame.getDevice().getDisplayMode());
|
return createLWJGLDisplayMode(MacOSXFrame.getDevice().getDisplayMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
public DisplayMode[] getAvailableDisplayModes() {
|
public DisplayMode[] getAvailableDisplayModes() {
|
||||||
java.awt.DisplayMode[] awt_modes = MacOSXFrame.getDevice().getDisplayModes();
|
java.awt.DisplayMode[] awt_modes = MacOSXFrame.getDevice().getDisplayModes();
|
||||||
List modes = new ArrayList();
|
List modes = new ArrayList();
|
||||||
|
@ -169,11 +168,11 @@ final class MacOSXDisplay implements DisplayImplementation {
|
||||||
modes.toArray(mode_list);
|
modes.toArray(mode_list);
|
||||||
return mode_list;
|
return mode_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTitle(String title) {
|
public void setTitle(String title) {
|
||||||
frame.syncSetTitle(title);
|
frame.syncSetTitle(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCloseRequested() {
|
public boolean isCloseRequested() {
|
||||||
boolean result;
|
boolean result;
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
|
@ -186,11 +185,11 @@ final class MacOSXDisplay implements DisplayImplementation {
|
||||||
public boolean isVisible() {
|
public boolean isVisible() {
|
||||||
return frame.syncIsVisible();
|
return frame.syncIsVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isActive() {
|
public boolean isActive() {
|
||||||
return frame.syncIsActive();
|
return frame.syncIsActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDirty() {
|
public boolean isDirty() {
|
||||||
return frame.getCanvas().syncIsDirty();
|
return frame.getCanvas().syncIsDirty();
|
||||||
}
|
}
|
||||||
|
@ -213,7 +212,7 @@ final class MacOSXDisplay implements DisplayImplementation {
|
||||||
warpCursor();
|
warpCursor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void warpCursor() {
|
private void warpCursor() {
|
||||||
if (mouse_queue != null && mouse_queue.isGrabbed()) {
|
if (mouse_queue != null && mouse_queue.isGrabbed()) {
|
||||||
Rectangle bounds = frame.syncGetBounds();
|
Rectangle bounds = frame.syncGetBounds();
|
||||||
|
@ -248,7 +247,7 @@ final class MacOSXDisplay implements DisplayImplementation {
|
||||||
public int getButtonCount() {
|
public int getButtonCount() {
|
||||||
return MouseEventQueue.NUM_BUTTONS;
|
return MouseEventQueue.NUM_BUTTONS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createMouse() {
|
public void createMouse() {
|
||||||
MacOSXGLCanvas canvas = frame.getCanvas();
|
MacOSXGLCanvas canvas = frame.getCanvas();
|
||||||
this.mouse_queue = new MouseEventQueue(canvas.getWidth(), canvas.getHeight());
|
this.mouse_queue = new MouseEventQueue(canvas.getWidth(), canvas.getHeight());
|
||||||
|
@ -264,14 +263,14 @@ final class MacOSXDisplay implements DisplayImplementation {
|
||||||
canvas.removeMouseMotionListener(mouse_queue);
|
canvas.removeMouseMotionListener(mouse_queue);
|
||||||
this.mouse_queue = null;
|
this.mouse_queue = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons_buffer) {
|
public void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons_buffer) {
|
||||||
mouse_queue.poll(coord_buffer, buttons_buffer);
|
mouse_queue.poll(coord_buffer, buttons_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enableMouseBuffer() throws LWJGLException {
|
public void enableMouseBuffer() throws LWJGLException {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int readMouse(IntBuffer buffer, int buffer_position) {
|
public int readMouse(IntBuffer buffer, int buffer_position) {
|
||||||
assert buffer_position == buffer.position();
|
assert buffer_position == buffer.position();
|
||||||
return mouse_queue.copyEvents(buffer);
|
return mouse_queue.copyEvents(buffer);
|
||||||
|
@ -300,13 +299,13 @@ final class MacOSXDisplay implements DisplayImplementation {
|
||||||
Componennt, it is reset to the default pointer cursor when the window is de-
|
Componennt, it is reset to the default pointer cursor when the window is de-
|
||||||
activated and the re-activated. The Cursor can not be reset to the custom cursor,
|
activated and the re-activated. The Cursor can not be reset to the custom cursor,
|
||||||
with another setCursor.
|
with another setCursor.
|
||||||
2. When the cursor is moving in the top pixel row (y = 0 in AWT coordinates) in fullscreen
|
2. When the cursor is moving in the top pixel row (y = 0 in AWT coordinates) in fullscreen
|
||||||
mode, no mouse moved events are reported, even though mouse pressed/released and dragged
|
mode, no mouse moved events are reported, even though mouse pressed/released and dragged
|
||||||
events are reported
|
events are reported
|
||||||
*/
|
*/
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNativeCursor(Object handle) throws LWJGLException {
|
public void setNativeCursor(Object handle) throws LWJGLException {
|
||||||
Cursor awt_cursor = (Cursor)handle;
|
Cursor awt_cursor = (Cursor)handle;
|
||||||
frame.syncSetCursor(awt_cursor);
|
frame.syncSetCursor(awt_cursor);
|
||||||
|
@ -328,7 +327,7 @@ final class MacOSXDisplay implements DisplayImplementation {
|
||||||
this.keyboard_queue = new KeyboardEventQueue();
|
this.keyboard_queue = new KeyboardEventQueue();
|
||||||
canvas.addKeyListener(keyboard_queue);
|
canvas.addKeyListener(keyboard_queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void destroyKeyboard() {
|
public void destroyKeyboard() {
|
||||||
/*
|
/*
|
||||||
* This line is commented out to work around AWT bug 4867453:
|
* This line is commented out to work around AWT bug 4867453:
|
||||||
|
@ -338,11 +337,11 @@ final class MacOSXDisplay implements DisplayImplementation {
|
||||||
|
|
||||||
this.keyboard_queue = null;
|
this.keyboard_queue = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pollKeyboard(ByteBuffer keyDownBuffer) {
|
public void pollKeyboard(ByteBuffer keyDownBuffer) {
|
||||||
keyboard_queue.poll(keyDownBuffer);
|
keyboard_queue.poll(keyDownBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int readKeyboard(IntBuffer buffer, int buffer_position) {
|
public int readKeyboard(IntBuffer buffer, int buffer_position) {
|
||||||
assert buffer_position == buffer.position();
|
assert buffer_position == buffer.position();
|
||||||
return keyboard_queue.copyEvents(buffer);
|
return keyboard_queue.copyEvents(buffer);
|
||||||
|
@ -350,7 +349,7 @@ final class MacOSXDisplay implements DisplayImplementation {
|
||||||
|
|
||||||
public void enableTranslation() throws LWJGLException {
|
public void enableTranslation() throws LWJGLException {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enableKeyboardBuffer() throws LWJGLException {
|
public void enableKeyboardBuffer() throws LWJGLException {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,7 +386,7 @@ final class MacOSXDisplay implements DisplayImplementation {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class captures com.apple.eawt.ApplicationEvents through reflection
|
* This class captures com.apple.eawt.ApplicationEvents through reflection
|
||||||
* to enable compilation on other platforms than Mac OS X
|
* to enable compilation on other platforms than Mac OS X
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2002-2004 LWJGL Project
|
* Copyright (c) 2002-2004 LWJGL Project
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are
|
* modification, are permitted provided that the following conditions are
|
||||||
* met:
|
* met:
|
||||||
*
|
*
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* * Neither the name of 'LWJGL' nor the names of
|
* * Neither the name of 'LWJGL' nor the names of
|
||||||
* its contributors may be used to endorse or promote products derived
|
* its contributors may be used to endorse or promote products derived
|
||||||
* from this software without specific prior written permission.
|
* from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
@ -52,6 +52,7 @@ import java.lang.reflect.InvocationTargetException;
|
||||||
import org.lwjgl.LWJGLException;
|
import org.lwjgl.LWJGLException;
|
||||||
|
|
||||||
final class MacOSXFrame extends Frame implements WindowListener, ComponentListener {
|
final class MacOSXFrame extends Frame implements WindowListener, ComponentListener {
|
||||||
|
|
||||||
private final MacOSXGLCanvas canvas;
|
private final MacOSXGLCanvas canvas;
|
||||||
private boolean close_requested;
|
private boolean close_requested;
|
||||||
|
|
||||||
|
@ -61,24 +62,24 @@ final class MacOSXFrame extends Frame implements WindowListener, ComponentListen
|
||||||
private boolean active;
|
private boolean active;
|
||||||
private boolean visible;
|
private boolean visible;
|
||||||
private boolean minimized;
|
private boolean minimized;
|
||||||
|
|
||||||
public MacOSXFrame(DisplayMode mode, java.awt.DisplayMode requested_mode, boolean fullscreen, int x, int y) throws LWJGLException {
|
MacOSXFrame(DisplayMode mode, java.awt.DisplayMode requested_mode, boolean fullscreen, int x, int y) throws LWJGLException {
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
addWindowListener(this);
|
addWindowListener(this);
|
||||||
addComponentListener(this);
|
addComponentListener(this);
|
||||||
canvas = new MacOSXGLCanvas();
|
canvas = new MacOSXGLCanvas();
|
||||||
add(canvas, BorderLayout.CENTER);
|
add(canvas, BorderLayout.CENTER);
|
||||||
setUndecorated(fullscreen);
|
setUndecorated(fullscreen);
|
||||||
if (fullscreen) {
|
if ( fullscreen ) {
|
||||||
getDevice().setFullScreenWindow(this);
|
getDevice().setFullScreenWindow(this);
|
||||||
getDevice().setDisplayMode(requested_mode);
|
getDevice().setDisplayMode(requested_mode);
|
||||||
java.awt.DisplayMode real_mode = getDevice().getDisplayMode();
|
java.awt.DisplayMode real_mode = getDevice().getDisplayMode();
|
||||||
/** For some strange reason, the display mode is sometimes silently capped even though the mode is reported as supported */
|
/** For some strange reason, the display mode is sometimes silently capped even though the mode is reported as supported */
|
||||||
if (requested_mode.getWidth() != real_mode.getWidth() || requested_mode.getHeight() != real_mode.getHeight()) {
|
if ( requested_mode.getWidth() != real_mode.getWidth() || requested_mode.getHeight() != real_mode.getHeight() ) {
|
||||||
getDevice().setFullScreenWindow(null);
|
getDevice().setFullScreenWindow(null);
|
||||||
syncDispose();
|
syncDispose();
|
||||||
throw new LWJGLException("AWT capped mode: requested mode = " + requested_mode.getWidth() + "x" + requested_mode.getHeight() +
|
throw new LWJGLException("AWT capped mode: requested mode = " + requested_mode.getWidth() + "x" + requested_mode.getHeight() +
|
||||||
" but got " + real_mode.getWidth() + " " + real_mode.getHeight());
|
" but got " + real_mode.getWidth() + " " + real_mode.getHeight());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pack();
|
pack();
|
||||||
|
@ -94,11 +95,11 @@ final class MacOSXFrame extends Frame implements WindowListener, ComponentListen
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rectangle syncGetBounds() {
|
public Rectangle syncGetBounds() {
|
||||||
synchronized (this) {
|
synchronized ( this ) {
|
||||||
return bounds;
|
return bounds;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void componentShown(ComponentEvent e) {
|
public void componentShown(ComponentEvent e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +107,7 @@ final class MacOSXFrame extends Frame implements WindowListener, ComponentListen
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateBounds() {
|
private void updateBounds() {
|
||||||
synchronized (this) {
|
synchronized ( this ) {
|
||||||
bounds = getBounds();
|
bounds = getBounds();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,20 +120,20 @@ final class MacOSXFrame extends Frame implements WindowListener, ComponentListen
|
||||||
updateBounds();
|
updateBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final static GraphicsDevice getDevice() {
|
public static GraphicsDevice getDevice() {
|
||||||
GraphicsEnvironment g_env = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
GraphicsEnvironment g_env = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||||
GraphicsDevice device = g_env.getDefaultScreenDevice();
|
GraphicsDevice device = g_env.getDefaultScreenDevice();
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void windowIconified(WindowEvent e) {
|
public void windowIconified(WindowEvent e) {
|
||||||
synchronized (this) {
|
synchronized ( this ) {
|
||||||
minimized = true;
|
minimized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void windowDeiconified(WindowEvent e) {
|
public void windowDeiconified(WindowEvent e) {
|
||||||
synchronized (this) {
|
synchronized ( this ) {
|
||||||
minimized = false;
|
minimized = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,19 +145,19 @@ final class MacOSXFrame extends Frame implements WindowListener, ComponentListen
|
||||||
}
|
}
|
||||||
|
|
||||||
public void windowClosing(WindowEvent e) {
|
public void windowClosing(WindowEvent e) {
|
||||||
synchronized (this) {
|
synchronized ( this ) {
|
||||||
close_requested = true;
|
close_requested = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void windowDeactivated(WindowEvent e) {
|
public void windowDeactivated(WindowEvent e) {
|
||||||
synchronized (this) {
|
synchronized ( this ) {
|
||||||
active = false;
|
active = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void windowActivated(WindowEvent e) {
|
public void windowActivated(WindowEvent e) {
|
||||||
synchronized (this) {
|
synchronized ( this ) {
|
||||||
should_update = true;
|
should_update = true;
|
||||||
active = true;
|
active = true;
|
||||||
}
|
}
|
||||||
|
@ -165,16 +166,17 @@ final class MacOSXFrame extends Frame implements WindowListener, ComponentListen
|
||||||
public void syncDispose() {
|
public void syncDispose() {
|
||||||
invokeAWT(new Runnable() {
|
invokeAWT(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (isDisplayable())
|
if ( isDisplayable() )
|
||||||
dispose();
|
dispose();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TitleSetter implements Runnable {
|
private class TitleSetter implements Runnable {
|
||||||
|
|
||||||
private final String title;
|
private final String title;
|
||||||
|
|
||||||
public TitleSetter(String title) {
|
TitleSetter(String title) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,14 +184,14 @@ final class MacOSXFrame extends Frame implements WindowListener, ComponentListen
|
||||||
setTitle(title);
|
setTitle(title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void syncSetTitle(String title) {
|
public void syncSetTitle(String title) {
|
||||||
invokeAWT(new TitleSetter(title));
|
invokeAWT(new TitleSetter(title));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean syncIsCloseRequested() {
|
public boolean syncIsCloseRequested() {
|
||||||
boolean result;
|
boolean result;
|
||||||
synchronized (this) {
|
synchronized ( this ) {
|
||||||
result = close_requested;
|
result = close_requested;
|
||||||
close_requested = false;
|
close_requested = false;
|
||||||
}
|
}
|
||||||
|
@ -197,24 +199,24 @@ final class MacOSXFrame extends Frame implements WindowListener, ComponentListen
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean syncIsVisible() {
|
public boolean syncIsVisible() {
|
||||||
synchronized (this) {
|
synchronized ( this ) {
|
||||||
return !minimized;
|
return !minimized;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean syncIsActive() {
|
public boolean syncIsActive() {
|
||||||
synchronized (this) {
|
synchronized ( this ) {
|
||||||
return active;
|
return active;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MacOSXGLCanvas getCanvas() {
|
public MacOSXGLCanvas getCanvas() {
|
||||||
return canvas;
|
return canvas;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean syncShouldUpdateContext() {
|
public boolean syncShouldUpdateContext() {
|
||||||
boolean result;
|
boolean result;
|
||||||
synchronized (this) {
|
synchronized ( this ) {
|
||||||
result = canvas.syncShouldUpdateContext() || should_update;
|
result = canvas.syncShouldUpdateContext() || should_update;
|
||||||
should_update = false;
|
should_update = false;
|
||||||
}
|
}
|
||||||
|
@ -222,12 +224,13 @@ final class MacOSXFrame extends Frame implements WindowListener, ComponentListen
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Reshaper implements Runnable {
|
private class Reshaper implements Runnable {
|
||||||
|
|
||||||
private final int x;
|
private final int x;
|
||||||
private final int y;
|
private final int y;
|
||||||
private final int width;
|
private final int width;
|
||||||
private final int height;
|
private final int height;
|
||||||
|
|
||||||
public Reshaper(int x, int y, int width, int height) {
|
Reshaper(int x, int y, int width, int height) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.width = width;
|
this.width = width;
|
||||||
|
@ -255,9 +258,10 @@ final class MacOSXFrame extends Frame implements WindowListener, ComponentListen
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CursorSetter implements Runnable {
|
private class CursorSetter implements Runnable {
|
||||||
|
|
||||||
private final java.awt.Cursor awt_cursor;
|
private final java.awt.Cursor awt_cursor;
|
||||||
|
|
||||||
public CursorSetter(java.awt.Cursor awt_cursor) {
|
CursorSetter(java.awt.Cursor awt_cursor) {
|
||||||
this.awt_cursor = awt_cursor;
|
this.awt_cursor = awt_cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2002-2004 LWJGL Project
|
* Copyright (c) 2002-2004 LWJGL Project
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are
|
* modification, are permitted provided that the following conditions are
|
||||||
* met:
|
* met:
|
||||||
*
|
*
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* * Neither the name of 'LWJGL' nor the names of
|
* * Neither the name of 'LWJGL' nor the names of
|
||||||
* its contributors may be used to endorse or promote products derived
|
* its contributors may be used to endorse or promote products derived
|
||||||
* from this software without specific prior written permission.
|
* from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
@ -44,6 +44,7 @@ import java.awt.event.ComponentEvent;
|
||||||
import java.awt.event.ComponentListener;
|
import java.awt.event.ComponentListener;
|
||||||
|
|
||||||
final class MacOSXGLCanvas extends Canvas implements ComponentListener {
|
final class MacOSXGLCanvas extends Canvas implements ComponentListener {
|
||||||
|
|
||||||
private int width;
|
private int width;
|
||||||
private int height;
|
private int height;
|
||||||
private boolean context_update;
|
private boolean context_update;
|
||||||
|
@ -55,9 +56,9 @@ final class MacOSXGLCanvas extends Canvas implements ComponentListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void paint(Graphics g) {
|
public void paint(Graphics g) {
|
||||||
synchronized (this) {
|
synchronized ( this ) {
|
||||||
dirty = true;
|
dirty = true;
|
||||||
if (!canvas_created) {
|
if ( !canvas_created ) {
|
||||||
setFocusTraversalKeysEnabled(false);
|
setFocusTraversalKeysEnabled(false);
|
||||||
/* Input methods are not enabled in fullscreen anyway, so disable always */
|
/* Input methods are not enabled in fullscreen anyway, so disable always */
|
||||||
enableInputMethods(false);
|
enableInputMethods(false);
|
||||||
|
@ -72,16 +73,16 @@ final class MacOSXGLCanvas extends Canvas implements ComponentListener {
|
||||||
|
|
||||||
public boolean syncIsDirty() {
|
public boolean syncIsDirty() {
|
||||||
boolean result;
|
boolean result;
|
||||||
synchronized (this) {
|
synchronized ( this ) {
|
||||||
result = dirty;
|
result = dirty;
|
||||||
dirty = false;
|
dirty = false;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void waitForCanvasCreated() {
|
public void waitForCanvasCreated() {
|
||||||
synchronized (this) {
|
synchronized ( this ) {
|
||||||
while (!canvas_created) {
|
while ( !canvas_created ) {
|
||||||
try {
|
try {
|
||||||
wait();
|
wait();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
@ -90,18 +91,18 @@ final class MacOSXGLCanvas extends Canvas implements ComponentListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean syncShouldUpdateContext() {
|
public boolean syncShouldUpdateContext() {
|
||||||
boolean should_update;
|
boolean should_update;
|
||||||
synchronized (this) {
|
synchronized ( this ) {
|
||||||
should_update = context_update;
|
should_update = context_update;
|
||||||
context_update = false;
|
context_update = false;
|
||||||
}
|
}
|
||||||
return should_update;
|
return should_update;
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void setUpdate() {
|
private synchronized void setUpdate() {
|
||||||
synchronized (this) {
|
synchronized ( this ) {
|
||||||
width = getWidth();
|
width = getWidth();
|
||||||
height = getHeight();
|
height = getHeight();
|
||||||
context_update = true;
|
context_update = true;
|
||||||
|
@ -109,17 +110,17 @@ final class MacOSXGLCanvas extends Canvas implements ComponentListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int syncGetWidth() {
|
public int syncGetWidth() {
|
||||||
synchronized (this) {
|
synchronized ( this ) {
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int syncGetHeight() {
|
public int syncGetHeight() {
|
||||||
synchronized (this) {
|
synchronized ( this ) {
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void componentShown(ComponentEvent e) {
|
public void componentShown(ComponentEvent e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +149,7 @@ final class MacOSXGLCanvas extends Canvas implements ComponentListener {
|
||||||
super.setSize(d);
|
super.setSize(d);
|
||||||
setUpdate();
|
setUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSize(int width, int height) {
|
public void setSize(int width, int height) {
|
||||||
super.setSize(width, height);
|
super.setSize(width, height);
|
||||||
setUpdate();
|
setUpdate();
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2002-2004 LWJGL Project
|
* Copyright (c) 2002-2004 LWJGL Project
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are
|
* modification, are permitted provided that the following conditions are
|
||||||
* met:
|
* met:
|
||||||
*
|
*
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* * Neither the name of 'LWJGL' nor the names of
|
* * Neither the name of 'LWJGL' nor the names of
|
||||||
* its contributors may be used to endorse or promote products derived
|
* its contributors may be used to endorse or promote products derived
|
||||||
* from this software without specific prior written permission.
|
* from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
@ -49,9 +49,10 @@ import java.nio.ByteBuffer;
|
||||||
import org.lwjgl.BufferUtils;
|
import org.lwjgl.BufferUtils;
|
||||||
|
|
||||||
final class MouseEventQueue extends EventQueue implements MouseListener, MouseMotionListener, MouseWheelListener {
|
final class MouseEventQueue extends EventQueue implements MouseListener, MouseMotionListener, MouseWheelListener {
|
||||||
private final static int WHEEL_SCALE = 120;
|
|
||||||
public final static int NUM_BUTTONS = 3;
|
private static final int WHEEL_SCALE = 120;
|
||||||
private final static int EVENT_SIZE = 5;
|
public static final int NUM_BUTTONS = 3;
|
||||||
|
private static final int EVENT_SIZE = 5;
|
||||||
|
|
||||||
private final int width;
|
private final int width;
|
||||||
private final int height;
|
private final int height;
|
||||||
|
@ -75,7 +76,7 @@ final class MouseEventQueue extends EventQueue implements MouseListener, MouseMo
|
||||||
/** Buttons array */
|
/** Buttons array */
|
||||||
private final byte[] buttons = new byte[NUM_BUTTONS];
|
private final byte[] buttons = new byte[NUM_BUTTONS];
|
||||||
|
|
||||||
public MouseEventQueue(int width, int height) {
|
MouseEventQueue(int width, int height) {
|
||||||
super(EVENT_SIZE);
|
super(EVENT_SIZE);
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
|
@ -103,7 +104,7 @@ final class MouseEventQueue extends EventQueue implements MouseListener, MouseMo
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean putMouseEvent(int button, int state, int dz) {
|
private boolean putMouseEvent(int button, int state, int dz) {
|
||||||
if (grabbed)
|
if ( grabbed )
|
||||||
return putMouseEventWithCoords(button, state, 0, 0, dz);
|
return putMouseEventWithCoords(button, state, 0, 0, dz);
|
||||||
else
|
else
|
||||||
return putMouseEventWithCoords(button, state, last_x, last_y, dz);
|
return putMouseEventWithCoords(button, state, last_x, last_y, dz);
|
||||||
|
@ -119,7 +120,7 @@ final class MouseEventQueue extends EventQueue implements MouseListener, MouseMo
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void poll(IntBuffer coord_buffer, ByteBuffer buttons_buffer) {
|
public synchronized void poll(IntBuffer coord_buffer, ByteBuffer buttons_buffer) {
|
||||||
if (grabbed) {
|
if ( grabbed ) {
|
||||||
coord_buffer.put(0, accum_dx);
|
coord_buffer.put(0, accum_dx);
|
||||||
coord_buffer.put(1, accum_dy);
|
coord_buffer.put(1, accum_dy);
|
||||||
} else {
|
} else {
|
||||||
|
@ -135,7 +136,7 @@ final class MouseEventQueue extends EventQueue implements MouseListener, MouseMo
|
||||||
|
|
||||||
private synchronized void setCursorPos(int x, int y) {
|
private synchronized void setCursorPos(int x, int y) {
|
||||||
y = transformY(y);
|
y = transformY(y);
|
||||||
if (grabbed)
|
if ( grabbed )
|
||||||
return;
|
return;
|
||||||
int dx = x - last_x;
|
int dx = x - last_x;
|
||||||
int dy = y - last_y;
|
int dy = y - last_y;
|
||||||
|
@ -148,16 +149,16 @@ final class MouseEventQueue extends EventQueue implements MouseListener, MouseMo
|
||||||
|
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseEntered(MouseEvent e) {
|
public void mouseEntered(MouseEvent e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseExited(MouseEvent e) {
|
public void mouseExited(MouseEvent e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleButton(MouseEvent e) {
|
private void handleButton(MouseEvent e) {
|
||||||
byte button;
|
byte button;
|
||||||
switch (e.getButton()) {
|
switch ( e.getButton() ) {
|
||||||
case MouseEvent.BUTTON1:
|
case MouseEvent.BUTTON1:
|
||||||
button = (byte)0;
|
button = (byte)0;
|
||||||
break;
|
break;
|
||||||
|
@ -171,7 +172,7 @@ final class MouseEventQueue extends EventQueue implements MouseListener, MouseMo
|
||||||
throw new IllegalArgumentException("Not a valid button: " + e.getButton());
|
throw new IllegalArgumentException("Not a valid button: " + e.getButton());
|
||||||
}
|
}
|
||||||
byte state;
|
byte state;
|
||||||
switch (e.getID()) {
|
switch ( e.getID() ) {
|
||||||
case MouseEvent.MOUSE_PRESSED:
|
case MouseEvent.MOUSE_PRESSED:
|
||||||
state = 1;
|
state = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -192,13 +193,13 @@ final class MouseEventQueue extends EventQueue implements MouseListener, MouseMo
|
||||||
buttons[button] = state;
|
buttons[button] = state;
|
||||||
putMouseEvent(button, state, 0);
|
putMouseEvent(button, state, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseReleased(MouseEvent e) {
|
public void mouseReleased(MouseEvent e) {
|
||||||
handleButton(e);
|
handleButton(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleMotion(MouseEvent e) {
|
private void handleMotion(MouseEvent e) {
|
||||||
if (grabbed) {
|
if ( grabbed ) {
|
||||||
updateDeltas();
|
updateDeltas();
|
||||||
} else {
|
} else {
|
||||||
setCursorPos(e.getX(), e.getY());
|
setCursorPos(e.getX(), e.getY());
|
||||||
|
@ -208,24 +209,24 @@ final class MouseEventQueue extends EventQueue implements MouseListener, MouseMo
|
||||||
public void mouseDragged(MouseEvent e) {
|
public void mouseDragged(MouseEvent e) {
|
||||||
handleMotion(e);
|
handleMotion(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseMoved(MouseEvent e) {
|
public void mouseMoved(MouseEvent e) {
|
||||||
handleMotion(e);
|
handleMotion(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void handleWheel(int amount) {
|
private synchronized void handleWheel(int amount) {
|
||||||
accum_dz += amount;
|
accum_dz += amount;
|
||||||
putMouseEvent(-1, 0, amount);
|
putMouseEvent(-1, 0, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateDeltas() {
|
private void updateDeltas() {
|
||||||
if (!grabbed)
|
if ( !grabbed )
|
||||||
return;
|
return;
|
||||||
synchronized (this) {
|
synchronized ( this ) {
|
||||||
((MacOSXDisplay)Display.getImplementation()).getMouseDeltas(delta_buffer);
|
((MacOSXDisplay)Display.getImplementation()).getMouseDeltas(delta_buffer);
|
||||||
int dx = delta_buffer.get(0);
|
int dx = delta_buffer.get(0);
|
||||||
int dy = -delta_buffer.get(1);
|
int dy = -delta_buffer.get(1);
|
||||||
if (dx != 0 || dy != 0) {
|
if ( dx != 0 || dy != 0 ) {
|
||||||
putMouseEventWithCoords(-1, 0, dx, dy, 0);
|
putMouseEventWithCoords(-1, 0, dx, dy, 0);
|
||||||
accum_dx += dx;
|
accum_dx += dx;
|
||||||
accum_dy += dy;
|
accum_dy += dy;
|
||||||
|
@ -233,8 +234,8 @@ final class MouseEventQueue extends EventQueue implements MouseListener, MouseMo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseWheelMoved(MouseWheelEvent e) {
|
public void mouseWheelMoved(MouseWheelEvent e) {
|
||||||
int wheel_amount = -e.getWheelRotation()*WHEEL_SCALE;
|
int wheel_amount = -e.getWheelRotation() * WHEEL_SCALE;
|
||||||
handleWheel(wheel_amount);
|
handleWheel(wheel_amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2002-2004 LWJGL Project
|
* Copyright (c) 2002-2004 LWJGL Project
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are
|
* modification, are permitted provided that the following conditions are
|
||||||
* met:
|
* met:
|
||||||
*
|
*
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* * Neither the name of 'LWJGL' nor the names of
|
* * Neither the name of 'LWJGL' nor the names of
|
||||||
* its contributors may be used to endorse or promote products derived
|
* its contributors may be used to endorse or promote products derived
|
||||||
* from this software without specific prior written permission.
|
* from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
@ -46,7 +46,7 @@ import org.lwjgl.BufferUtils;
|
||||||
import org.lwjgl.LWJGLException;
|
import org.lwjgl.LWJGLException;
|
||||||
|
|
||||||
final class Win32Display implements DisplayImplementation {
|
final class Win32Display implements DisplayImplementation {
|
||||||
private final static int CURSOR_HANDLE_SIZE = 8;
|
private static final int CURSOR_HANDLE_SIZE = 8;
|
||||||
|
|
||||||
public native void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException;
|
public native void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException;
|
||||||
public native void destroyWindow();
|
public native void destroyWindow();
|
||||||
|
@ -70,6 +70,7 @@ final class Win32Display implements DisplayImplementation {
|
||||||
public native void setVSyncEnabled(boolean sync);
|
public native void setVSyncEnabled(boolean sync);
|
||||||
public native void reshape(int x, int y, int width, int height);
|
public native void reshape(int x, int y, int width, int height);
|
||||||
public native DisplayMode[] getAvailableDisplayModes();
|
public native DisplayMode[] getAvailableDisplayModes();
|
||||||
|
|
||||||
/* Mouse */
|
/* Mouse */
|
||||||
public native boolean hasWheel();
|
public native boolean hasWheel();
|
||||||
public native int getButtonCount();
|
public native int getButtonCount();
|
||||||
|
@ -83,6 +84,7 @@ final class Win32Display implements DisplayImplementation {
|
||||||
public native void setNativeCursor(Object handle) throws LWJGLException;
|
public native void setNativeCursor(Object handle) throws LWJGLException;
|
||||||
public native int getMinCursorSize();
|
public native int getMinCursorSize();
|
||||||
public native int getMaxCursorSize();
|
public native int getMaxCursorSize();
|
||||||
|
|
||||||
/* Keyboard */
|
/* Keyboard */
|
||||||
public native void createKeyboard() throws LWJGLException;
|
public native void createKeyboard() throws LWJGLException;
|
||||||
public native void destroyKeyboard();
|
public native void destroyKeyboard();
|
||||||
|
|
Loading…
Reference in New Issue