2004-11-25 23:31:38 +01:00
|
|
|
/*
|
2004-11-02 13:48:58 +01:00
|
|
|
* Copyright (c) 2002-2004 LWJGL Project
|
|
|
|
|
* All rights reserved.
|
2004-11-25 23:31:38 +01:00
|
|
|
*
|
2004-11-02 13:48:58 +01:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
2004-11-25 23:31:38 +01:00
|
|
|
* modification, are permitted provided that the following conditions are
|
2004-11-02 13:48:58 +01:00
|
|
|
* met:
|
2004-11-25 23:31:38 +01:00
|
|
|
*
|
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
2004-11-02 13:48:58 +01:00
|
|
|
* 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.
|
|
|
|
|
*
|
2004-11-25 23:31:38 +01:00
|
|
|
* * Neither the name of 'LWJGL' nor the names of
|
|
|
|
|
* its contributors may be used to endorse or promote products derived
|
2004-11-02 13:48:58 +01:00
|
|
|
* from this software without specific prior written permission.
|
2004-11-25 23:31:38 +01:00
|
|
|
*
|
2004-11-02 13:48:58 +01:00
|
|
|
* 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
|
2004-11-25 23:31:38 +01:00
|
|
|
* 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
|
2004-11-02 13:48:58 +01:00
|
|
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
2004-11-25 23:31:38 +01:00
|
|
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
2004-11-02 13:48:58 +01:00
|
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
*/
|
|
|
|
|
package org.lwjgl.opengl;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This is the Display implementation interface. Display delegates
|
|
|
|
|
* to implementors of this interface. There is one DisplayImplementation
|
|
|
|
|
* for each supported platform.
|
|
|
|
|
* @author elias_naur
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import java.nio.ByteBuffer;
|
2004-11-20 17:46:44 +01:00
|
|
|
import java.nio.FloatBuffer;
|
2004-11-11 14:27:59 +01:00
|
|
|
import java.nio.IntBuffer;
|
2004-11-02 13:48:58 +01:00
|
|
|
|
2004-11-20 17:46:44 +01:00
|
|
|
import org.lwjgl.LWJGLException;
|
2005-05-04 22:59:44 +02:00
|
|
|
import org.lwjgl.LWJGLUtil;
|
2005-01-20 23:51:28 +01:00
|
|
|
import org.lwjgl.input.Keyboard;
|
2004-11-02 13:48:58 +01:00
|
|
|
|
|
|
|
|
final class LinuxDisplay implements DisplayImplementation {
|
2005-01-18 18:25:34 +01:00
|
|
|
private static final int NUM_BUTTONS = 3;
|
2004-11-11 14:27:59 +01:00
|
|
|
|
2005-03-29 13:31:22 +02:00
|
|
|
private static int display_connection_usage_count = 0;
|
|
|
|
|
|
2005-02-20 12:24:22 +01:00
|
|
|
private static PeerInfo peer_info;
|
|
|
|
|
|
2005-01-11 16:22:12 +01:00
|
|
|
/* Since Xlib is not guaranteed to be thread safe, we need a way to synchronize LWJGL
|
2005-02-20 12:24:22 +01:00
|
|
|
* Xlib calls with AWT Xlib calls. Fortunately, JAWT implements LockAWT and UnlockAWT() to
|
2005-01-11 16:22:12 +01:00
|
|
|
* do just that.
|
|
|
|
|
*/
|
2005-02-20 12:24:22 +01:00
|
|
|
static native void lockAWT();
|
|
|
|
|
static native void unlockAWT();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* increment and decrement display usage.
|
|
|
|
|
*/
|
2005-03-29 13:31:22 +02:00
|
|
|
static void incDisplay() throws LWJGLException {
|
|
|
|
|
if (display_connection_usage_count == 0) {
|
2005-04-25 09:47:28 +02:00
|
|
|
GLContext.loadOpenGLLibrary();
|
2005-03-29 13:31:22 +02:00
|
|
|
openDisplay();
|
|
|
|
|
}
|
|
|
|
|
display_connection_usage_count++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void decDisplay() {
|
|
|
|
|
display_connection_usage_count--;
|
|
|
|
|
if (display_connection_usage_count < 0)
|
|
|
|
|
throw new InternalError("display_connection_usage_count < 0: " + display_connection_usage_count);
|
|
|
|
|
if (display_connection_usage_count == 0) {
|
|
|
|
|
closeDisplay();
|
2005-04-25 09:47:28 +02:00
|
|
|
GLContext.unloadOpenGLLibrary();
|
2005-03-29 13:31:22 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static native void openDisplay() throws LWJGLException;
|
|
|
|
|
private static native void closeDisplay();
|
2005-02-20 12:24:22 +01:00
|
|
|
|
2005-01-11 16:22:12 +01:00
|
|
|
public void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException {
|
|
|
|
|
lockAWT();
|
2005-02-20 12:24:22 +01:00
|
|
|
try {
|
|
|
|
|
ByteBuffer handle = peer_info.lockAndGetHandle();
|
|
|
|
|
try {
|
|
|
|
|
nCreateWindow(handle, mode, fullscreen, x, y);
|
|
|
|
|
} finally {
|
|
|
|
|
peer_info.unlock();
|
|
|
|
|
}
|
|
|
|
|
} finally {
|
|
|
|
|
unlockAWT();
|
|
|
|
|
}
|
2005-01-11 16:22:12 +01:00
|
|
|
}
|
2005-02-20 12:24:22 +01:00
|
|
|
private static native void nCreateWindow(ByteBuffer peer_info_handle, DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException;
|
2005-01-11 16:22:12 +01:00
|
|
|
|
|
|
|
|
public void destroyWindow() {
|
|
|
|
|
lockAWT();
|
|
|
|
|
nDestroyWindow();
|
|
|
|
|
unlockAWT();
|
|
|
|
|
}
|
2005-02-20 12:24:22 +01:00
|
|
|
private static native void nDestroyWindow();
|
2005-01-11 16:22:12 +01:00
|
|
|
|
|
|
|
|
public void switchDisplayMode(DisplayMode mode) throws LWJGLException {
|
|
|
|
|
lockAWT();
|
2005-02-20 12:24:22 +01:00
|
|
|
try {
|
|
|
|
|
nSwitchDisplayMode(mode);
|
|
|
|
|
} finally {
|
|
|
|
|
unlockAWT();
|
|
|
|
|
}
|
2005-01-11 16:22:12 +01:00
|
|
|
}
|
2005-02-20 12:24:22 +01:00
|
|
|
private static native void nSwitchDisplayMode(DisplayMode mode) throws LWJGLException;
|
|
|
|
|
|
2005-01-11 16:22:12 +01:00
|
|
|
public void resetDisplayMode() {
|
|
|
|
|
lockAWT();
|
2005-02-20 12:24:22 +01:00
|
|
|
try {
|
|
|
|
|
nResetDisplayMode();
|
|
|
|
|
} finally {
|
|
|
|
|
unlockAWT();
|
|
|
|
|
}
|
2005-01-11 16:22:12 +01:00
|
|
|
}
|
2005-02-20 12:24:22 +01:00
|
|
|
private static native void nResetDisplayMode();
|
2005-01-11 16:22:12 +01:00
|
|
|
|
|
|
|
|
public int getGammaRampLength() {
|
|
|
|
|
lockAWT();
|
|
|
|
|
int length = nGetGammaRampLength();
|
|
|
|
|
unlockAWT();
|
|
|
|
|
return length;
|
|
|
|
|
}
|
2005-02-20 12:24:22 +01:00
|
|
|
private static native int nGetGammaRampLength();
|
|
|
|
|
|
2005-01-11 16:22:12 +01:00
|
|
|
public void setGammaRamp(FloatBuffer gammaRamp) throws LWJGLException {
|
|
|
|
|
lockAWT();
|
2005-02-20 12:24:22 +01:00
|
|
|
try {
|
|
|
|
|
nSetGammaRamp(gammaRamp);
|
|
|
|
|
} finally {
|
|
|
|
|
unlockAWT();
|
|
|
|
|
}
|
2005-01-11 16:22:12 +01:00
|
|
|
}
|
2005-02-20 12:24:22 +01:00
|
|
|
private static native void nSetGammaRamp(FloatBuffer gammaRamp) throws LWJGLException;
|
2005-01-06 15:03:48 +01:00
|
|
|
|
|
|
|
|
public String getAdapter() {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2005-02-20 12:24:22 +01:00
|
|
|
|
2005-01-06 15:03:48 +01:00
|
|
|
public String getVersion() {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2005-02-20 12:24:22 +01:00
|
|
|
|
|
|
|
|
public DisplayMode init() throws LWJGLException {
|
2005-01-11 16:22:12 +01:00
|
|
|
lockAWT();
|
2005-02-20 12:24:22 +01:00
|
|
|
try {
|
|
|
|
|
DisplayMode mode = nInit();
|
|
|
|
|
return mode;
|
|
|
|
|
} finally {
|
|
|
|
|
unlockAWT();
|
|
|
|
|
}
|
2005-01-11 16:22:12 +01:00
|
|
|
}
|
2005-02-20 12:24:22 +01:00
|
|
|
private static native DisplayMode nInit() throws LWJGLException;
|
2005-01-11 16:22:12 +01:00
|
|
|
|
|
|
|
|
public void setTitle(String title) {
|
|
|
|
|
lockAWT();
|
|
|
|
|
nSetTitle(title);
|
|
|
|
|
unlockAWT();
|
|
|
|
|
}
|
2005-02-20 12:24:22 +01:00
|
|
|
private static native void nSetTitle(String title);
|
|
|
|
|
|
2005-01-11 16:22:12 +01:00
|
|
|
public boolean isCloseRequested() {
|
|
|
|
|
lockAWT();
|
|
|
|
|
boolean result = nIsCloseRequested();
|
|
|
|
|
unlockAWT();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2005-02-20 12:24:22 +01:00
|
|
|
private static native boolean nIsCloseRequested();
|
|
|
|
|
|
2005-01-11 16:22:12 +01:00
|
|
|
public boolean isVisible() {
|
|
|
|
|
lockAWT();
|
|
|
|
|
boolean result = nIsVisible();
|
|
|
|
|
unlockAWT();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2005-02-20 12:24:22 +01:00
|
|
|
private static native boolean nIsVisible();
|
|
|
|
|
|
2005-01-11 16:22:12 +01:00
|
|
|
public boolean isActive() {
|
|
|
|
|
lockAWT();
|
|
|
|
|
boolean result = nIsActive();
|
|
|
|
|
unlockAWT();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2005-02-20 12:24:22 +01:00
|
|
|
private static native boolean nIsActive();
|
|
|
|
|
|
2005-01-11 16:22:12 +01:00
|
|
|
public boolean isDirty() {
|
|
|
|
|
lockAWT();
|
|
|
|
|
boolean result = nIsDirty();
|
|
|
|
|
unlockAWT();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2005-02-20 12:24:22 +01:00
|
|
|
private static native boolean nIsDirty();
|
|
|
|
|
|
|
|
|
|
public PeerInfo createPeerInfo(PixelFormat pixel_format) throws LWJGLException {
|
2005-02-23 12:11:08 +01:00
|
|
|
peer_info = new LinuxDisplayPeerInfo(pixel_format);
|
|
|
|
|
return peer_info;
|
2005-01-11 16:22:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void update() {
|
|
|
|
|
lockAWT();
|
|
|
|
|
nUpdate();
|
|
|
|
|
unlockAWT();
|
|
|
|
|
}
|
2005-02-20 12:24:22 +01:00
|
|
|
private static native void nUpdate();
|
2005-01-11 16:22:12 +01:00
|
|
|
|
|
|
|
|
public void reshape(int x, int y, int width, int height) {
|
|
|
|
|
lockAWT();
|
|
|
|
|
nReshape(x, y, width, height);
|
|
|
|
|
unlockAWT();
|
|
|
|
|
}
|
2005-02-20 12:24:22 +01:00
|
|
|
private static native void nReshape(int x, int y, int width, int height);
|
2005-01-11 16:22:12 +01:00
|
|
|
|
2005-02-20 12:24:22 +01:00
|
|
|
public DisplayMode[] getAvailableDisplayModes() throws LWJGLException {
|
2005-01-11 16:22:12 +01:00
|
|
|
lockAWT();
|
2005-02-20 12:24:22 +01:00
|
|
|
try {
|
|
|
|
|
DisplayMode[] modes = nGetAvailableDisplayModes();
|
|
|
|
|
return modes;
|
|
|
|
|
} finally {
|
|
|
|
|
unlockAWT();
|
|
|
|
|
}
|
2005-01-11 16:22:12 +01:00
|
|
|
}
|
2005-02-20 12:24:22 +01:00
|
|
|
private static native DisplayMode[] nGetAvailableDisplayModes() throws LWJGLException;
|
2005-01-11 16:22:12 +01:00
|
|
|
|
2004-11-02 13:48:58 +01:00
|
|
|
/* Mouse */
|
2005-01-06 15:03:48 +01:00
|
|
|
public boolean hasWheel() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2005-01-11 16:22:12 +01:00
|
|
|
public int getButtonCount() {
|
2005-01-18 18:25:34 +01:00
|
|
|
return NUM_BUTTONS;
|
2005-01-11 16:22:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void createMouse() {
|
|
|
|
|
lockAWT();
|
|
|
|
|
nCreateMouse();
|
|
|
|
|
unlockAWT();
|
|
|
|
|
}
|
2005-02-20 12:24:22 +01:00
|
|
|
private static native void nCreateMouse();
|
2005-01-11 16:22:12 +01:00
|
|
|
public void destroyMouse() {
|
|
|
|
|
lockAWT();
|
|
|
|
|
nDestroyMouse();
|
|
|
|
|
unlockAWT();
|
|
|
|
|
}
|
2005-02-20 12:24:22 +01:00
|
|
|
private static native void nDestroyMouse();
|
2005-01-11 16:22:12 +01:00
|
|
|
|
|
|
|
|
public void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) {
|
|
|
|
|
lockAWT();
|
|
|
|
|
nPollMouse(coord_buffer, buttons);
|
|
|
|
|
unlockAWT();
|
|
|
|
|
}
|
2005-02-20 12:24:22 +01:00
|
|
|
private static native void nPollMouse(IntBuffer coord_buffer, ByteBuffer buttons);
|
2005-01-11 16:22:12 +01:00
|
|
|
|
|
|
|
|
public int readMouse(IntBuffer buffer, int buffer_position) {
|
|
|
|
|
lockAWT();
|
|
|
|
|
int count = nReadMouse(buffer, buffer_position);
|
|
|
|
|
unlockAWT();
|
|
|
|
|
return count;
|
|
|
|
|
}
|
2005-02-20 12:24:22 +01:00
|
|
|
private static native int nReadMouse(IntBuffer buffer, int buffer_position);
|
2005-01-11 16:22:12 +01:00
|
|
|
|
2005-04-12 13:45:06 +02:00
|
|
|
public void setCursorPosition(int x, int y) {
|
|
|
|
|
lockAWT();
|
|
|
|
|
nSetCursorPosition(x, y);
|
|
|
|
|
unlockAWT();
|
|
|
|
|
}
|
|
|
|
|
private native void nSetCursorPosition(int x, int y);
|
|
|
|
|
|
2005-01-11 16:22:12 +01:00
|
|
|
public void grabMouse(boolean grab) {
|
|
|
|
|
lockAWT();
|
|
|
|
|
nGrabMouse(grab);
|
|
|
|
|
unlockAWT();
|
|
|
|
|
}
|
2005-02-20 12:24:22 +01:00
|
|
|
private static native void nGrabMouse(boolean grab);
|
2005-01-11 16:22:12 +01:00
|
|
|
|
2005-01-18 13:34:36 +01:00
|
|
|
public int getNativeCursorCapabilities() {
|
2005-01-11 16:22:12 +01:00
|
|
|
lockAWT();
|
2005-02-20 12:24:22 +01:00
|
|
|
try {
|
|
|
|
|
incDisplay();
|
|
|
|
|
int caps = nGetNativeCursorCapabilities();
|
|
|
|
|
decDisplay();
|
|
|
|
|
return caps;
|
|
|
|
|
} catch (LWJGLException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
} finally {
|
|
|
|
|
unlockAWT();
|
|
|
|
|
}
|
2005-01-11 16:22:12 +01:00
|
|
|
}
|
2005-02-20 12:24:22 +01:00
|
|
|
private static native int nGetNativeCursorCapabilities() throws LWJGLException;
|
2005-01-11 16:22:12 +01:00
|
|
|
|
|
|
|
|
public void setNativeCursor(Object handle) throws LWJGLException {
|
|
|
|
|
lockAWT();
|
|
|
|
|
nSetNativeCursor(handle);
|
|
|
|
|
unlockAWT();
|
|
|
|
|
}
|
2005-02-20 12:24:22 +01:00
|
|
|
private static native void nSetNativeCursor(Object handle) throws LWJGLException;
|
2005-01-11 16:22:12 +01:00
|
|
|
|
|
|
|
|
public int getMinCursorSize() {
|
|
|
|
|
lockAWT();
|
2005-04-25 09:26:07 +02:00
|
|
|
try {
|
|
|
|
|
incDisplay();
|
|
|
|
|
int min_size = nGetMinCursorSize();
|
|
|
|
|
decDisplay();
|
|
|
|
|
return min_size;
|
|
|
|
|
} catch (LWJGLException e) {
|
|
|
|
|
LWJGLUtil.log("Exception occurred in getMinCursorSize: " + e);
|
|
|
|
|
return 0;
|
|
|
|
|
} finally {
|
|
|
|
|
unlockAWT();
|
|
|
|
|
}
|
2005-01-11 16:22:12 +01:00
|
|
|
}
|
2005-02-20 12:24:22 +01:00
|
|
|
private static native int nGetMinCursorSize();
|
2005-01-11 16:22:12 +01:00
|
|
|
|
|
|
|
|
public int getMaxCursorSize() {
|
|
|
|
|
lockAWT();
|
2005-04-25 09:26:07 +02:00
|
|
|
try {
|
|
|
|
|
incDisplay();
|
|
|
|
|
int max_size = nGetMaxCursorSize();
|
|
|
|
|
decDisplay();
|
|
|
|
|
return max_size;
|
|
|
|
|
} catch (LWJGLException e) {
|
|
|
|
|
LWJGLUtil.log("Exception occurred in getMaxCursorSize: " + e);
|
|
|
|
|
return 0;
|
|
|
|
|
} finally {
|
|
|
|
|
unlockAWT();
|
|
|
|
|
}
|
2005-01-11 16:22:12 +01:00
|
|
|
}
|
2005-02-20 12:24:22 +01:00
|
|
|
private static native int nGetMaxCursorSize();
|
2005-01-11 16:22:12 +01:00
|
|
|
|
2004-11-02 13:48:58 +01:00
|
|
|
/* Keyboard */
|
2005-01-11 16:22:12 +01:00
|
|
|
public void createKeyboard() throws LWJGLException {
|
|
|
|
|
lockAWT();
|
2005-02-20 12:24:22 +01:00
|
|
|
try {
|
|
|
|
|
nCreateKeyboard();
|
|
|
|
|
} finally {
|
|
|
|
|
unlockAWT();
|
|
|
|
|
}
|
2005-01-11 16:22:12 +01:00
|
|
|
}
|
2005-02-20 12:24:22 +01:00
|
|
|
private static native void nCreateKeyboard() throws LWJGLException;
|
2005-01-11 16:22:12 +01:00
|
|
|
|
|
|
|
|
public void destroyKeyboard() {
|
|
|
|
|
lockAWT();
|
|
|
|
|
nDestroyKeyboard();
|
|
|
|
|
unlockAWT();
|
|
|
|
|
}
|
2005-02-20 12:24:22 +01:00
|
|
|
private static native void nDestroyKeyboard();
|
2005-01-11 16:22:12 +01:00
|
|
|
|
|
|
|
|
public void pollKeyboard(ByteBuffer keyDownBuffer) {
|
|
|
|
|
lockAWT();
|
|
|
|
|
nPollKeyboard(keyDownBuffer);
|
|
|
|
|
unlockAWT();
|
|
|
|
|
}
|
2005-02-20 12:24:22 +01:00
|
|
|
private static native void nPollKeyboard(ByteBuffer keyDownBuffer);
|
2005-01-11 16:22:12 +01:00
|
|
|
|
|
|
|
|
public int readKeyboard(IntBuffer buffer, int buffer_position) {
|
|
|
|
|
lockAWT();
|
|
|
|
|
int count = nReadKeyboard(buffer, buffer_position);
|
|
|
|
|
unlockAWT();
|
|
|
|
|
return count;
|
|
|
|
|
}
|
2005-02-20 12:24:22 +01:00
|
|
|
private static native int nReadKeyboard(IntBuffer buffer, int buffer_position);
|
2005-01-11 16:22:12 +01:00
|
|
|
|
|
|
|
|
public int isStateKeySet(int key) {
|
|
|
|
|
return Keyboard.STATE_UNKNOWN;
|
|
|
|
|
}
|
2004-11-11 14:27:59 +01:00
|
|
|
|
2005-02-21 16:56:53 +01:00
|
|
|
private static native ByteBuffer nCreateCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset) throws LWJGLException;
|
2004-11-11 14:27:59 +01:00
|
|
|
|
|
|
|
|
public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
|
2005-01-11 16:22:12 +01:00
|
|
|
lockAWT();
|
2005-02-20 12:24:22 +01:00
|
|
|
try {
|
|
|
|
|
incDisplay();
|
|
|
|
|
try {
|
2005-02-21 16:56:53 +01:00
|
|
|
return nCreateCursor(width, height, xHotspot, yHotspot, numImages, images, images.position(), delays, delays != null ? delays.position() : -1);
|
2005-02-20 12:24:22 +01:00
|
|
|
} catch (LWJGLException e) {
|
|
|
|
|
decDisplay();
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
} finally {
|
|
|
|
|
unlockAWT();
|
|
|
|
|
}
|
2004-11-11 14:27:59 +01:00
|
|
|
}
|
|
|
|
|
|
2005-01-11 16:22:12 +01:00
|
|
|
public void destroyCursor(Object cursorHandle) {
|
|
|
|
|
lockAWT();
|
|
|
|
|
nDestroyCursor(cursorHandle);
|
2005-02-20 12:24:22 +01:00
|
|
|
decDisplay();
|
2005-01-11 16:22:12 +01:00
|
|
|
unlockAWT();
|
|
|
|
|
}
|
2005-02-20 12:24:22 +01:00
|
|
|
private static native void nDestroyCursor(Object cursorHandle);
|
2005-01-11 16:22:12 +01:00
|
|
|
|
2005-01-18 13:34:36 +01:00
|
|
|
public int getPbufferCapabilities() {
|
2005-01-11 16:22:12 +01:00
|
|
|
lockAWT();
|
2005-02-24 11:44:34 +01:00
|
|
|
try {
|
|
|
|
|
incDisplay();
|
|
|
|
|
int caps = nGetPbufferCapabilities();
|
|
|
|
|
decDisplay();
|
|
|
|
|
return caps;
|
|
|
|
|
} catch (LWJGLException e) {
|
2005-03-29 20:09:33 +02:00
|
|
|
LWJGLUtil.log("Exception occurred in getPbufferCapabilities: " + e);
|
2005-02-24 11:44:34 +01:00
|
|
|
return 0;
|
|
|
|
|
} finally {
|
|
|
|
|
unlockAWT();
|
|
|
|
|
}
|
2005-01-11 16:22:12 +01:00
|
|
|
}
|
2005-02-20 12:24:22 +01:00
|
|
|
private static native int nGetPbufferCapabilities();
|
2005-01-11 16:22:12 +01:00
|
|
|
|
2005-02-20 12:24:22 +01:00
|
|
|
public boolean isBufferLost(PeerInfo handle) {
|
2005-01-11 14:53:12 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-20 12:24:22 +01:00
|
|
|
public PeerInfo createPbuffer(int width, int height, PixelFormat pixel_format,
|
|
|
|
|
IntBuffer pixelFormatCaps,
|
|
|
|
|
IntBuffer pBufferAttribs) throws LWJGLException {
|
2005-02-23 12:11:08 +01:00
|
|
|
return new LinuxPbufferPeerInfo(width, height, pixel_format);
|
2005-01-11 16:22:12 +01:00
|
|
|
}
|
2005-01-11 14:53:12 +01:00
|
|
|
|
2005-02-20 12:24:22 +01:00
|
|
|
public void setPbufferAttrib(PeerInfo handle, int attrib, int value) {
|
2005-01-11 14:53:12 +01:00
|
|
|
throw new UnsupportedOperationException();
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-20 12:24:22 +01:00
|
|
|
public void bindTexImageToPbuffer(PeerInfo handle, int buffer) {
|
2005-01-11 14:53:12 +01:00
|
|
|
throw new UnsupportedOperationException();
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-20 12:24:22 +01:00
|
|
|
public void releaseTexImageFromPbuffer(PeerInfo handle, int buffer) {
|
2005-01-11 14:53:12 +01:00
|
|
|
throw new UnsupportedOperationException();
|
|
|
|
|
}
|
2005-07-05 23:54:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets one or more icons for the Display.
|
|
|
|
|
* <ul>
|
|
|
|
|
* <li>On Windows you should supply at least one 16x16 icon and one 32x32.</li>
|
|
|
|
|
* <li>Linux (and similar platforms) expect one 32x32 icon.</li>
|
|
|
|
|
* <li>Mac OS X should be supplied one 128x128 icon</li>
|
|
|
|
|
* </ul>
|
|
|
|
|
* The implementation will use the supplied ByteBuffers with image data in RGBA and perform any conversions nescesarry for the specific platform.
|
|
|
|
|
*
|
|
|
|
|
* @param icons Array of icons in RGBA mode
|
|
|
|
|
* @return number of icons used.
|
|
|
|
|
*/
|
|
|
|
|
public int setIcon(ByteBuffer[] icons) {
|
|
|
|
|
for (int i=0;i<icons.length;i++) {
|
2005-07-10 22:15:55 +02:00
|
|
|
int size = icons[i].limit() / 4;
|
2005-07-05 23:54:12 +02:00
|
|
|
|
|
|
|
|
if (((int) Math.sqrt(size)) == 32) {
|
|
|
|
|
nSetWindowIcon(icons[i]);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static native int nSetWindowIcon(ByteBuffer icon);
|
2004-11-02 13:48:58 +01:00
|
|
|
}
|