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