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-22 22:22:30 +01:00
|
|
|
import java.io.IOException;
|
2004-11-02 13:48:58 +01:00
|
|
|
|
2004-11-11 14:27:59 +01:00
|
|
|
import org.lwjgl.BufferUtils;
|
2004-11-20 17:46:44 +01:00
|
|
|
import org.lwjgl.LWJGLException;
|
2004-11-02 13:48:58 +01:00
|
|
|
|
|
|
|
|
final class LinuxDisplay implements DisplayImplementation {
|
2004-11-25 23:31:38 +01:00
|
|
|
private static final int CURSOR_HANDLE_SIZE = 8;
|
2004-11-11 14:27:59 +01:00
|
|
|
|
2004-11-02 13:48:58 +01:00
|
|
|
public native void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException;
|
|
|
|
|
public native void destroyWindow();
|
|
|
|
|
public native void switchDisplayMode(DisplayMode mode) throws LWJGLException;
|
|
|
|
|
public native void resetDisplayMode();
|
|
|
|
|
public native int getGammaRampLength();
|
|
|
|
|
public native void setGammaRamp(FloatBuffer gammaRamp) throws LWJGLException;
|
2005-01-06 15:03:48 +01:00
|
|
|
|
|
|
|
|
public String getAdapter() {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getVersion() {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2004-11-02 13:48:58 +01:00
|
|
|
public native DisplayMode init();
|
|
|
|
|
public native void setTitle(String title);
|
|
|
|
|
public native boolean isCloseRequested();
|
|
|
|
|
public native boolean isVisible();
|
|
|
|
|
public native boolean isActive();
|
|
|
|
|
public native boolean isDirty();
|
|
|
|
|
public native void swapBuffers();
|
|
|
|
|
public native void makeCurrent() throws LWJGLException;
|
|
|
|
|
public native void createContext(PixelFormat pixel_format) throws LWJGLException;
|
|
|
|
|
public native void destroyContext();
|
|
|
|
|
public native void update();
|
|
|
|
|
public native void setVSyncEnabled(boolean sync);
|
|
|
|
|
public native void reshape(int x, int y, int width, int height);
|
|
|
|
|
public native DisplayMode[] getAvailableDisplayModes();
|
|
|
|
|
/* Mouse */
|
2005-01-06 15:03:48 +01:00
|
|
|
public boolean hasWheel() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2004-11-02 13:48:58 +01:00
|
|
|
public native int getButtonCount();
|
|
|
|
|
public native void createMouse();
|
|
|
|
|
public native void destroyMouse();
|
|
|
|
|
public native void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons);
|
|
|
|
|
public native void enableMouseBuffer() throws LWJGLException;
|
|
|
|
|
public native int readMouse(IntBuffer buffer, int buffer_position);
|
|
|
|
|
public native void grabMouse(boolean grab);
|
|
|
|
|
public native int getNativeCursorCaps();
|
2004-11-11 14:27:59 +01:00
|
|
|
public native void setNativeCursor(Object handle) throws LWJGLException;
|
2004-11-02 13:48:58 +01:00
|
|
|
public native int getMinCursorSize();
|
|
|
|
|
public native int getMaxCursorSize();
|
|
|
|
|
/* Keyboard */
|
|
|
|
|
public native void createKeyboard() throws LWJGLException;
|
|
|
|
|
public native void destroyKeyboard();
|
|
|
|
|
public native void pollKeyboard(ByteBuffer keyDownBuffer);
|
|
|
|
|
public native int readKeyboard(IntBuffer buffer, int buffer_position);
|
|
|
|
|
public native void enableTranslation() throws LWJGLException;
|
|
|
|
|
public native void enableKeyboardBuffer() throws LWJGLException;
|
|
|
|
|
public native int isStateKeySet(int key);
|
2004-11-11 14:27:59 +01:00
|
|
|
|
|
|
|
|
public native void nCreateCursor(ByteBuffer handle, int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset) throws LWJGLException;
|
|
|
|
|
|
|
|
|
|
public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
|
|
|
|
|
ByteBuffer handle = BufferUtils.createByteBuffer(CURSOR_HANDLE_SIZE);
|
|
|
|
|
nCreateCursor(handle, width, height, xHotspot, yHotspot, numImages, images, images.position(), delays, delays != null ? delays.position() : -1);
|
|
|
|
|
return handle;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public native void destroyCursor(Object cursorHandle);
|
2004-11-18 13:10:28 +01:00
|
|
|
public native int getPbufferCaps();
|
2004-11-22 22:22:30 +01:00
|
|
|
|
|
|
|
|
public boolean openURL(String url) {
|
|
|
|
|
// Linux may as well resort to pure Java hackery, as there's no Linux native way of doing it
|
|
|
|
|
// right anyway.
|
|
|
|
|
|
|
|
|
|
String[] browsers = {"mozilla", "opera", "konqueror", "nautilus", "galeon", "netscape"};
|
|
|
|
|
|
2004-11-25 23:31:38 +01:00
|
|
|
for (int i = 0; i < browsers.length; i ++) {
|
2004-11-22 22:22:30 +01:00
|
|
|
try {
|
|
|
|
|
Runtime.getRuntime().exec(new String[] { browsers[i], url });
|
|
|
|
|
return true;
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
// Ignore
|
|
|
|
|
e.printStackTrace(System.err);
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-11-25 23:31:38 +01:00
|
|
|
|
2004-11-22 22:22:30 +01:00
|
|
|
// Seems to have failed
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2004-11-02 13:48:58 +01:00
|
|
|
}
|