Converted Cursor and Pbuffer handles to ByteBuffers
This commit is contained in:
parent
efb28a1a85
commit
bdf5a43d5e
|
@ -32,10 +32,10 @@
|
||||||
package org.lwjgl.input;
|
package org.lwjgl.input;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
|
||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
|
|
||||||
import org.lwjgl.LWJGLException;
|
import org.lwjgl.LWJGLException;
|
||||||
|
import org.lwjgl.BufferUtils;
|
||||||
import org.lwjgl.Sys;
|
import org.lwjgl.Sys;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,8 +49,9 @@ import org.lwjgl.Sys;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Cursor {
|
public class Cursor {
|
||||||
|
private final static int HANDLE_SIZE = 8;
|
||||||
/** First element to display */
|
/** First element to display */
|
||||||
private CursorElement[] cursors = null;
|
private final CursorElement[] cursors;
|
||||||
|
|
||||||
/** Index into list of cursors */
|
/** Index into list of cursors */
|
||||||
private int index = 0;
|
private int index = 0;
|
||||||
|
@ -88,15 +89,15 @@ public class Cursor {
|
||||||
yHotspot = height - 1 - yHotspot;
|
yHotspot = height - 1 - yHotspot;
|
||||||
|
|
||||||
// create cursor (or cursors if multiple images supplied)
|
// create cursor (or cursors if multiple images supplied)
|
||||||
createCursors(width, height, xHotspot, yHotspot, numImages, images, delays);
|
cursors = createCursors(width, height, xHotspot, yHotspot, numImages, images, delays);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the actual cursor, using a platform specific class
|
* Creates the actual cursor, using a platform specific class
|
||||||
*/
|
*/
|
||||||
private void createCursors(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
|
private static CursorElement[] createCursors(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
|
||||||
// create copy and flip images to match ogl
|
// create copy and flip images to match ogl
|
||||||
IntBuffer images_copy = ByteBuffer.allocateDirect(images.remaining()*4).order(ByteOrder.nativeOrder()).asIntBuffer();
|
IntBuffer images_copy = BufferUtils.createIntBuffer(images.remaining());
|
||||||
flipImages(width, height, numImages, images, images_copy);
|
flipImages(width, height, numImages, images, images_copy);
|
||||||
|
|
||||||
// Win32 doesn't (afaik) allow for animation based cursors, except when they're
|
// Win32 doesn't (afaik) allow for animation based cursors, except when they're
|
||||||
|
@ -107,25 +108,30 @@ public class Cursor {
|
||||||
// might want to split it into a X/Win/Mac cursor if it gets too cluttered
|
// might want to split it into a X/Win/Mac cursor if it gets too cluttered
|
||||||
|
|
||||||
String osName = System.getProperty("os.name", "");
|
String osName = System.getProperty("os.name", "");
|
||||||
|
CursorElement[] cursors;
|
||||||
if (osName.startsWith("Win")) {
|
if (osName.startsWith("Win")) {
|
||||||
// create our cursor elements
|
// create our cursor elements
|
||||||
cursors = new CursorElement[numImages];
|
cursors = new CursorElement[numImages];
|
||||||
for(int i=0; i<numImages; i++) {
|
for(int i=0; i<numImages; i++) {
|
||||||
cursors[i] = new CursorElement();
|
ByteBuffer handle = BufferUtils.createByteBuffer(HANDLE_SIZE);
|
||||||
cursors[i].cursorHandle = nCreateCursor(width, height, xHotspot, yHotspot, 1, images_copy, images_copy.position(), null, 0);
|
nCreateCursor(handle, width, height, xHotspot, yHotspot, 1, images_copy, images_copy.position(), null, 0);
|
||||||
cursors[i].delay = (delays != null) ? delays.get(i) : 0;
|
long delay = (delays != null) ? delays.get(i) : 0;
|
||||||
cursors[i].timeout = System.currentTimeMillis();
|
long timeout = System.currentTimeMillis();
|
||||||
|
cursors[i] = new CursorElement(handle, delay, timeout);
|
||||||
|
|
||||||
// offset to next image
|
// offset to next image
|
||||||
images_copy.position(width*height*(i+1));
|
images_copy.position(width*height*(i+1));
|
||||||
}
|
}
|
||||||
} else if (osName.startsWith("Lin")) {
|
} else if (osName.startsWith("Lin")) {
|
||||||
// create our cursor elements
|
// create our cursor elements
|
||||||
cursors = new CursorElement[1];
|
ByteBuffer handle = BufferUtils.createByteBuffer(HANDLE_SIZE);
|
||||||
cursors[0] = new CursorElement();
|
nCreateCursor(handle, width, height, xHotspot, yHotspot, numImages, images_copy, images_copy.position(), delays, delays != null ? delays.position() : -1);
|
||||||
cursors[0].cursorHandle = nCreateCursor(width, height, xHotspot, yHotspot, numImages, images_copy, images_copy.position(), delays, delays != null ? delays.position() : -1);
|
CursorElement cursor_element = new CursorElement(handle, -1, -1);
|
||||||
|
cursors = new CursorElement[]{cursor_element};
|
||||||
} else {
|
} else {
|
||||||
|
throw new RuntimeException("Unknown OS");
|
||||||
}
|
}
|
||||||
|
return cursors;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -168,7 +174,7 @@ public class Cursor {
|
||||||
/**
|
/**
|
||||||
* Gets the native handle associated with the cursor object.
|
* Gets the native handle associated with the cursor object.
|
||||||
*/
|
*/
|
||||||
public long getHandle() {
|
ByteBuffer getHandle() {
|
||||||
return cursors[index].cursorHandle;
|
return cursors[index].cursorHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,24 +221,30 @@ public class Cursor {
|
||||||
/**
|
/**
|
||||||
* Native method to create a native cursor
|
* Native method to create a native cursor
|
||||||
*/
|
*/
|
||||||
private static native long nCreateCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset);
|
private static 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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Native method to destroy a native cursor
|
* Native method to destroy a native cursor
|
||||||
*/
|
*/
|
||||||
private static native void nDestroyCursor(long cursorHandle);
|
private static native void nDestroyCursor(ByteBuffer cursorHandle);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A single cursor element, used when animating
|
* A single cursor element, used when animating
|
||||||
*/
|
*/
|
||||||
protected class CursorElement {
|
private static class CursorElement {
|
||||||
/** Handle to cursor */
|
/** Handle to cursor */
|
||||||
long cursorHandle;
|
final ByteBuffer cursorHandle;
|
||||||
|
|
||||||
/** How long a delay this element should have */
|
/** How long a delay this element should have */
|
||||||
long delay;
|
final long delay;
|
||||||
|
|
||||||
/** Absolute time this element times out */
|
/** Absolute time this element times out */
|
||||||
long timeout;
|
long timeout;
|
||||||
|
|
||||||
|
CursorElement(ByteBuffer cursorHandle, long delay, long timeout) {
|
||||||
|
this.cursorHandle = cursorHandle;
|
||||||
|
this.delay = delay;
|
||||||
|
this.timeout = timeout;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,14 +200,14 @@ public class Mouse {
|
||||||
nSetNativeCursor(currentCursor.getHandle());
|
nSetNativeCursor(currentCursor.getHandle());
|
||||||
currentCursor.setTimeout();
|
currentCursor.setTimeout();
|
||||||
} else {
|
} else {
|
||||||
nSetNativeCursor(0);
|
nSetNativeCursor(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return oldCursor;
|
return oldCursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Native method to set the native cursor */
|
/** Native method to set the native cursor */
|
||||||
private static native void nSetNativeCursor(long handle) throws LWJGLException;
|
private static native void nSetNativeCursor(ByteBuffer handle) throws LWJGLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the minimum size of a native cursor. Can only be called if
|
* Gets the minimum size of a native cursor. Can only be called if
|
||||||
|
|
|
@ -32,9 +32,11 @@
|
||||||
package org.lwjgl.opengl;
|
package org.lwjgl.opengl;
|
||||||
|
|
||||||
import org.lwjgl.Sys;
|
import org.lwjgl.Sys;
|
||||||
|
import org.lwjgl.BufferUtils;
|
||||||
import org.lwjgl.LWJGLException;
|
import org.lwjgl.LWJGLException;
|
||||||
|
|
||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* $Id$
|
* $Id$
|
||||||
|
@ -134,10 +136,15 @@ public final class Pbuffer {
|
||||||
*/
|
*/
|
||||||
public static final int DEPTH_BUFFER = RenderTexture.WGL_DEPTH_COMPONENT_NV;
|
public static final int DEPTH_BUFFER = RenderTexture.WGL_DEPTH_COMPONENT_NV;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximum number of bytes in the native handle
|
||||||
|
*/
|
||||||
|
private final static int HANDLE_SIZE = 24;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle to the native GL rendering context
|
* Handle to the native GL rendering context
|
||||||
*/
|
*/
|
||||||
private final int handle;
|
private final ByteBuffer handle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Width
|
* Width
|
||||||
|
@ -183,7 +190,7 @@ public final class Pbuffer {
|
||||||
public static Pbuffer createPbufferUsingDisplayContext(int width, int height, RenderTexture renderTexture) throws LWJGLException {
|
public static Pbuffer createPbufferUsingDisplayContext(int width, int height, RenderTexture renderTexture) throws LWJGLException {
|
||||||
if (!Display.isCreated())
|
if (!Display.isCreated())
|
||||||
throw new IllegalStateException("The Display must be created before a shared Pbuffer can be created that use the Display context");
|
throw new IllegalStateException("The Display must be created before a shared Pbuffer can be created that use the Display context");
|
||||||
int handle = createPbuffer(true, width, height, null, renderTexture);
|
ByteBuffer handle = createPbuffer(true, width, height, null, renderTexture);
|
||||||
return new Pbuffer(width, height, Display.getContext(), handle);
|
return new Pbuffer(width, height, Display.getContext(), handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,26 +213,28 @@ public final class Pbuffer {
|
||||||
* @param renderTexture
|
* @param renderTexture
|
||||||
*/
|
*/
|
||||||
public static Pbuffer createPbufferUsingUniqueContext(int width, int height, PixelFormat pixel_format, RenderTexture renderTexture) throws LWJGLException {
|
public static Pbuffer createPbufferUsingUniqueContext(int width, int height, PixelFormat pixel_format, RenderTexture renderTexture) throws LWJGLException {
|
||||||
int handle = createPbuffer(false, width, height, pixel_format, renderTexture);
|
ByteBuffer handle = createPbuffer(false, width, height, pixel_format, renderTexture);
|
||||||
return new Pbuffer(width, height, null, handle);
|
return new Pbuffer(width, height, null, handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Pbuffer(int width, int height, Object display_context, int handle) {
|
private Pbuffer(int width, int height, Object display_context, ByteBuffer handle) {
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
this.display_context = display_context;
|
this.display_context = display_context;
|
||||||
this.handle = handle;
|
this.handle = handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int createPbuffer(boolean use_display_context, int width, int height, PixelFormat pixel_format, RenderTexture renderTexture) throws LWJGLException {
|
private static ByteBuffer createPbuffer(boolean use_display_context, int width, int height, PixelFormat pixel_format, RenderTexture renderTexture) throws LWJGLException {
|
||||||
GLContext.loadOpenGLLibrary();
|
GLContext.loadOpenGLLibrary();
|
||||||
try {
|
try {
|
||||||
|
ByteBuffer handle = BufferUtils.createByteBuffer(HANDLE_SIZE);
|
||||||
if ( renderTexture == null )
|
if ( renderTexture == null )
|
||||||
return nCreate(use_display_context, width, height, pixel_format, null, null);
|
nCreate(handle, use_display_context, width, height, pixel_format, null, null);
|
||||||
else
|
else
|
||||||
return nCreate(use_display_context, width, height, pixel_format,
|
nCreate(handle, use_display_context, width, height, pixel_format,
|
||||||
renderTexture.pixelFormatCaps,
|
renderTexture.pixelFormatCaps,
|
||||||
renderTexture.pBufferAttribs);
|
renderTexture.pBufferAttribs);
|
||||||
|
return handle;
|
||||||
} catch (LWJGLException e) {
|
} catch (LWJGLException e) {
|
||||||
GLContext.unloadOpenGLLibrary();
|
GLContext.unloadOpenGLLibrary();
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -246,7 +255,7 @@ public final class Pbuffer {
|
||||||
/**
|
/**
|
||||||
* Native method to test for buffer integrity
|
* Native method to test for buffer integrity
|
||||||
*/
|
*/
|
||||||
private static native boolean nIsBufferLost(int handle);
|
private static native boolean nIsBufferLost(ByteBuffer handle);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to make the Pbuffer context current. All subsequent OpenGL calls will go to this buffer.
|
* Method to make the Pbuffer context current. All subsequent OpenGL calls will go to this buffer.
|
||||||
|
@ -263,7 +272,7 @@ public final class Pbuffer {
|
||||||
/**
|
/**
|
||||||
* Native method to make a pbuffer current.
|
* Native method to make a pbuffer current.
|
||||||
*/
|
*/
|
||||||
private static native void nMakeCurrent(int handle) throws LWJGLException;
|
private static native void nMakeCurrent(ByteBuffer handle) throws LWJGLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Pbuffer capabilities.
|
* Gets the Pbuffer capabilities.
|
||||||
|
@ -275,7 +284,7 @@ public final class Pbuffer {
|
||||||
/**
|
/**
|
||||||
* Native method to create a Pbuffer
|
* Native method to create a Pbuffer
|
||||||
*/
|
*/
|
||||||
private static native int nCreate(boolean shared, int width, int height, PixelFormat pixel_format,
|
private static native void nCreate(ByteBuffer handle, boolean shared, int width, int height, PixelFormat pixel_format,
|
||||||
IntBuffer pixelFormatCaps,
|
IntBuffer pixelFormatCaps,
|
||||||
IntBuffer pBufferAttribs) throws LWJGLException;
|
IntBuffer pBufferAttribs) throws LWJGLException;
|
||||||
|
|
||||||
|
@ -300,7 +309,7 @@ public final class Pbuffer {
|
||||||
/**
|
/**
|
||||||
* Natively destroy any GL-related stuff
|
* Natively destroy any GL-related stuff
|
||||||
*/
|
*/
|
||||||
private static native void nDestroy(int handle);
|
private static native void nDestroy(ByteBuffer handle);
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------
|
||||||
// ------------------------------- Render-to-Texture Methods -------------------------------
|
// ------------------------------- Render-to-Texture Methods -------------------------------
|
||||||
|
@ -322,7 +331,7 @@ public final class Pbuffer {
|
||||||
nSetAttrib(handle, attrib, value);
|
nSetAttrib(handle, attrib, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static native void nSetAttrib(int handle, int attrib, int value);
|
private static native void nSetAttrib(ByteBuffer handle, int attrib, int value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Binds the currently bound texture to the buffer specified. The buffer can be one of the following:
|
* Binds the currently bound texture to the buffer specified. The buffer can be one of the following:
|
||||||
|
@ -335,7 +344,7 @@ public final class Pbuffer {
|
||||||
nBindTexImage(handle, buffer);
|
nBindTexImage(handle, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static native void nBindTexImage(int handle, int buffer);
|
private static native void nBindTexImage(ByteBuffer handle, int buffer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Releases the currently bound texture from the buffer specified.
|
* Releases the currently bound texture from the buffer specified.
|
||||||
|
@ -346,7 +355,7 @@ public final class Pbuffer {
|
||||||
nReleaseTexImage(handle, buffer);
|
nReleaseTexImage(handle, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static native void nReleaseTexImage(int handle, int buffer);
|
private static native void nReleaseTexImage(ByteBuffer handle, int buffer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns the height.
|
* @return Returns the height.
|
||||||
|
|
|
@ -7,21 +7,23 @@
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
#undef org_lwjgl_input_Cursor_HANDLE_SIZE
|
||||||
|
#define org_lwjgl_input_Cursor_HANDLE_SIZE 8L
|
||||||
/*
|
/*
|
||||||
* Class: org_lwjgl_input_Cursor
|
* Class: org_lwjgl_input_Cursor
|
||||||
* Method: nCreateCursor
|
* Method: nCreateCursor
|
||||||
* Signature: (IIIIILjava/nio/IntBuffer;ILjava/nio/IntBuffer;I)J
|
* Signature: (Ljava/nio/ByteBuffer;IIIIILjava/nio/IntBuffer;ILjava/nio/IntBuffer;I)V
|
||||||
*/
|
*/
|
||||||
JNIEXPORT jlong JNICALL Java_org_lwjgl_input_Cursor_nCreateCursor
|
JNIEXPORT void JNICALL Java_org_lwjgl_input_Cursor_nCreateCursor
|
||||||
(JNIEnv *, jclass, jint, jint, jint, jint, jint, jobject, jint, jobject, jint);
|
(JNIEnv *, jclass, jobject, jint, jint, jint, jint, jint, jobject, jint, jobject, jint);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: org_lwjgl_input_Cursor
|
* Class: org_lwjgl_input_Cursor
|
||||||
* Method: nDestroyCursor
|
* Method: nDestroyCursor
|
||||||
* Signature: (J)V
|
* Signature: (Ljava/nio/ByteBuffer;)V
|
||||||
*/
|
*/
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_input_Cursor_nDestroyCursor
|
JNIEXPORT void JNICALL Java_org_lwjgl_input_Cursor_nDestroyCursor
|
||||||
(JNIEnv *, jclass, jlong);
|
(JNIEnv *, jclass, jobject);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,10 +13,19 @@ extern "C" {
|
||||||
#define org_lwjgl_input_Mouse_CURSOR_8_BIT_ALPHA 2L
|
#define org_lwjgl_input_Mouse_CURSOR_8_BIT_ALPHA 2L
|
||||||
#undef org_lwjgl_input_Mouse_CURSOR_ANIMATION
|
#undef org_lwjgl_input_Mouse_CURSOR_ANIMATION
|
||||||
#define org_lwjgl_input_Mouse_CURSOR_ANIMATION 4L
|
#define org_lwjgl_input_Mouse_CURSOR_ANIMATION 4L
|
||||||
|
#undef org_lwjgl_input_Mouse_MAX_SENSITIVITY
|
||||||
|
#define org_lwjgl_input_Mouse_MAX_SENSITIVITY 8L
|
||||||
|
#undef org_lwjgl_input_Mouse_MIN_SENSITIVITY
|
||||||
|
#define org_lwjgl_input_Mouse_MIN_SENSITIVITY 1L
|
||||||
|
/* Inaccessible static: sensitivity */
|
||||||
|
/* Inaccessible static: width */
|
||||||
|
/* Inaccessible static: height */
|
||||||
/* Inaccessible static: created */
|
/* Inaccessible static: created */
|
||||||
/* Inaccessible static: buttons */
|
/* Inaccessible static: buttons */
|
||||||
/* Inaccessible static: x */
|
/* Inaccessible static: x */
|
||||||
/* Inaccessible static: y */
|
/* Inaccessible static: y */
|
||||||
|
/* Inaccessible static: scrollX */
|
||||||
|
/* Inaccessible static: scrollY */
|
||||||
/* Inaccessible static: coord_buffer */
|
/* Inaccessible static: coord_buffer */
|
||||||
/* Inaccessible static: dx */
|
/* Inaccessible static: dx */
|
||||||
/* Inaccessible static: dy */
|
/* Inaccessible static: dy */
|
||||||
|
@ -33,6 +42,7 @@ extern "C" {
|
||||||
#undef org_lwjgl_input_Mouse_BUFFER_SIZE
|
#undef org_lwjgl_input_Mouse_BUFFER_SIZE
|
||||||
#define org_lwjgl_input_Mouse_BUFFER_SIZE 50L
|
#define org_lwjgl_input_Mouse_BUFFER_SIZE 50L
|
||||||
/* Inaccessible static: isGrabbed */
|
/* Inaccessible static: isGrabbed */
|
||||||
|
/* Inaccessible static: trackingEnabled */
|
||||||
/*
|
/*
|
||||||
* Class: org_lwjgl_input_Mouse
|
* Class: org_lwjgl_input_Mouse
|
||||||
* Method: nGetNativeCursorCaps
|
* Method: nGetNativeCursorCaps
|
||||||
|
@ -44,10 +54,10 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetNativeCursorCaps
|
||||||
/*
|
/*
|
||||||
* Class: org_lwjgl_input_Mouse
|
* Class: org_lwjgl_input_Mouse
|
||||||
* Method: nSetNativeCursor
|
* Method: nSetNativeCursor
|
||||||
* Signature: (J)V
|
* Signature: (Ljava/nio/ByteBuffer;)V
|
||||||
*/
|
*/
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nSetNativeCursor
|
JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nSetNativeCursor
|
||||||
(JNIEnv *, jclass, jlong);
|
(JNIEnv *, jclass, jobject);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: org_lwjgl_input_Mouse
|
* Class: org_lwjgl_input_Mouse
|
||||||
|
|
|
@ -41,21 +41,23 @@ extern "C" {
|
||||||
#define org_lwjgl_opengl_Pbuffer_BACK_RIGHT_BUFFER 8326L
|
#define org_lwjgl_opengl_Pbuffer_BACK_RIGHT_BUFFER 8326L
|
||||||
#undef org_lwjgl_opengl_Pbuffer_DEPTH_BUFFER
|
#undef org_lwjgl_opengl_Pbuffer_DEPTH_BUFFER
|
||||||
#define org_lwjgl_opengl_Pbuffer_DEPTH_BUFFER 8359L
|
#define org_lwjgl_opengl_Pbuffer_DEPTH_BUFFER 8359L
|
||||||
|
#undef org_lwjgl_opengl_Pbuffer_HANDLE_SIZE
|
||||||
|
#define org_lwjgl_opengl_Pbuffer_HANDLE_SIZE 24L
|
||||||
/*
|
/*
|
||||||
* Class: org_lwjgl_opengl_Pbuffer
|
* Class: org_lwjgl_opengl_Pbuffer
|
||||||
* Method: nIsBufferLost
|
* Method: nIsBufferLost
|
||||||
* Signature: (I)Z
|
* Signature: (Ljava/nio/ByteBuffer;)Z
|
||||||
*/
|
*/
|
||||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Pbuffer_nIsBufferLost
|
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Pbuffer_nIsBufferLost
|
||||||
(JNIEnv *, jclass, jint);
|
(JNIEnv *, jclass, jobject);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: org_lwjgl_opengl_Pbuffer
|
* Class: org_lwjgl_opengl_Pbuffer
|
||||||
* Method: nMakeCurrent
|
* Method: nMakeCurrent
|
||||||
* Signature: (I)V
|
* Signature: (Ljava/nio/ByteBuffer;)V
|
||||||
*/
|
*/
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nMakeCurrent
|
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nMakeCurrent
|
||||||
(JNIEnv *, jclass, jint);
|
(JNIEnv *, jclass, jobject);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: org_lwjgl_opengl_Pbuffer
|
* Class: org_lwjgl_opengl_Pbuffer
|
||||||
|
@ -68,42 +70,42 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Pbuffer_getPbufferCaps
|
||||||
/*
|
/*
|
||||||
* Class: org_lwjgl_opengl_Pbuffer
|
* Class: org_lwjgl_opengl_Pbuffer
|
||||||
* Method: nCreate
|
* Method: nCreate
|
||||||
* Signature: (ZIILorg/lwjgl/opengl/PixelFormat;Ljava/nio/IntBuffer;Ljava/nio/IntBuffer;)I
|
* Signature: (Ljava/nio/ByteBuffer;ZIILorg/lwjgl/opengl/PixelFormat;Ljava/nio/IntBuffer;Ljava/nio/IntBuffer;)V
|
||||||
*/
|
*/
|
||||||
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate
|
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate
|
||||||
(JNIEnv *, jclass, jboolean, jint, jint, jobject, jobject, jobject);
|
(JNIEnv *, jclass, jobject, jboolean, jint, jint, jobject, jobject, jobject);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: org_lwjgl_opengl_Pbuffer
|
* Class: org_lwjgl_opengl_Pbuffer
|
||||||
* Method: nDestroy
|
* Method: nDestroy
|
||||||
* Signature: (I)V
|
* Signature: (Ljava/nio/ByteBuffer;)V
|
||||||
*/
|
*/
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nDestroy
|
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nDestroy
|
||||||
(JNIEnv *, jclass, jint);
|
(JNIEnv *, jclass, jobject);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: org_lwjgl_opengl_Pbuffer
|
* Class: org_lwjgl_opengl_Pbuffer
|
||||||
* Method: nSetAttrib
|
* Method: nSetAttrib
|
||||||
* Signature: (III)V
|
* Signature: (Ljava/nio/ByteBuffer;II)V
|
||||||
*/
|
*/
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nSetAttrib
|
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nSetAttrib
|
||||||
(JNIEnv *, jclass, jint, jint, jint);
|
(JNIEnv *, jclass, jobject, jint, jint);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: org_lwjgl_opengl_Pbuffer
|
* Class: org_lwjgl_opengl_Pbuffer
|
||||||
* Method: nBindTexImage
|
* Method: nBindTexImage
|
||||||
* Signature: (II)V
|
* Signature: (Ljava/nio/ByteBuffer;I)V
|
||||||
*/
|
*/
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nBindTexImage
|
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nBindTexImage
|
||||||
(JNIEnv *, jclass, jint, jint);
|
(JNIEnv *, jclass, jobject, jint);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: org_lwjgl_opengl_Pbuffer
|
* Class: org_lwjgl_opengl_Pbuffer
|
||||||
* Method: nReleaseTexImage
|
* Method: nReleaseTexImage
|
||||||
* Signature: (II)V
|
* Signature: (Ljava/nio/ByteBuffer;I)V
|
||||||
*/
|
*/
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nReleaseTexImage
|
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nReleaseTexImage
|
||||||
(JNIEnv *, jclass, jint, jint);
|
(JNIEnv *, jclass, jobject, jint);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,17 +44,16 @@
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
#include "common_tools.h"
|
#include "common_tools.h"
|
||||||
|
|
||||||
/*
|
JNIEXPORT void JNICALL Java_org_lwjgl_input_Cursor_nCreateCursor
|
||||||
* Class: org_lwjgl_input_Cursor
|
(JNIEnv *env, jclass clazz, jobject handle_buffer, jint width, jint height, jint x_hotspot, jint y_hotspot, jint num_images, jobject image_buffer, jint images_offset, jobject delay_buffer, jint delays_offset)
|
||||||
* Method: nCreateCursor
|
|
||||||
* Signature: (IIIIIII)I
|
|
||||||
*/
|
|
||||||
JNIEXPORT jlong JNICALL Java_org_lwjgl_input_Cursor_nCreateCursor
|
|
||||||
(JNIEnv *env, jclass clazz, jint width, jint height, jint x_hotspot, jint y_hotspot, jint num_images, jobject image_buffer, jint images_offset, jobject delay_buffer, jint delays_offset)
|
|
||||||
{
|
{
|
||||||
|
if (env->GetDirectBufferCapacity(handle_buffer) < sizeof(Cursor)) {
|
||||||
|
throwException(env, "Handle buffer not large enough");
|
||||||
|
return;
|
||||||
|
}
|
||||||
Display *disp = incDisplay(env);
|
Display *disp = incDisplay(env);
|
||||||
if (disp == NULL)
|
if (disp == NULL)
|
||||||
return 0;
|
return;
|
||||||
const int *delays = NULL;
|
const int *delays = NULL;
|
||||||
if (delay_buffer != NULL)
|
if (delay_buffer != NULL)
|
||||||
delays = (const int *)env->GetDirectBufferAddress(delay_buffer) + delays_offset;
|
delays = (const int *)env->GetDirectBufferAddress(delay_buffer) + delays_offset;
|
||||||
|
@ -74,20 +73,16 @@ JNIEXPORT jlong JNICALL Java_org_lwjgl_input_Cursor_nCreateCursor
|
||||||
cursor_image->delay = delays[i];
|
cursor_image->delay = delays[i];
|
||||||
cursor_images->images[i] = cursor_image;
|
cursor_images->images[i] = cursor_image;
|
||||||
}
|
}
|
||||||
Cursor cursor = XcursorImagesLoadCursor(disp, cursor_images);
|
Cursor *cursor = (Cursor *)env->GetDirectBufferAddress(handle_buffer);
|
||||||
|
*cursor = XcursorImagesLoadCursor(disp, cursor_images);
|
||||||
XcursorImagesDestroy(cursor_images);
|
XcursorImagesDestroy(cursor_images);
|
||||||
return (jlong)cursor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_lwjgl_input_Cursor
|
|
||||||
* Method: nDestroyCursor
|
|
||||||
* Signature: (I)V
|
|
||||||
*/
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_input_Cursor_nDestroyCursor
|
JNIEXPORT void JNICALL Java_org_lwjgl_input_Cursor_nDestroyCursor
|
||||||
(JNIEnv *env, jclass clazz, jlong cursor_handle)
|
(JNIEnv *env, jclass clazz, jobject cursor_handle_buffer)
|
||||||
{
|
{
|
||||||
Cursor cursor = (Cursor)cursor_handle;
|
Cursor *cursor = (Cursor *)env->GetDirectBufferAddress(cursor_handle_buffer);
|
||||||
XFreeCursor(getDisplay(), cursor);
|
// Cursor cursor = (Cursor)cursor_handle;
|
||||||
|
XFreeCursor(getDisplay(), *cursor);
|
||||||
decDisplay();
|
decDisplay();
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,10 +202,11 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetNativeCursorCaps
|
||||||
return caps;
|
return caps;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nSetNativeCursor (JNIEnv *env, jclass clazz, jlong cursor_handle) {
|
JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nSetNativeCursor(JNIEnv *env, jclass clazz, jobject cursor_handle) {
|
||||||
if (cursor_handle != 0) {
|
if (cursor_handle != NULL) {
|
||||||
Cursor cursor = (Cursor)cursor_handle;
|
Cursor *cursor = (Cursor *)env->GetDirectBufferAddress(cursor_handle);
|
||||||
current_cursor = cursor;
|
// Cursor cursor = (Cursor)cursor_handle;
|
||||||
|
current_cursor = *cursor;
|
||||||
} else
|
} else
|
||||||
current_cursor = None;
|
current_cursor = None;
|
||||||
updateCursor();
|
updateCursor();
|
||||||
|
|
|
@ -52,7 +52,7 @@ typedef struct _PbufferInfo {
|
||||||
} PbufferInfo;
|
} PbufferInfo;
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Pbuffer_nIsBufferLost
|
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Pbuffer_nIsBufferLost
|
||||||
(JNIEnv *env, jclass clazz, jint handle)
|
(JNIEnv *env, jclass clazz, jobject handle_buffer)
|
||||||
{
|
{
|
||||||
// The buffer is never lost, because of the GLX_PRESERVED_CONTENTS flag
|
// The buffer is never lost, because of the GLX_PRESERVED_CONTENTS flag
|
||||||
return JNI_FALSE;
|
return JNI_FALSE;
|
||||||
|
@ -71,7 +71,7 @@ static void destroyPbuffer(PbufferInfo *buffer_info) {
|
||||||
glXDestroyPbuffer(getDisplay(), buffer);
|
glXDestroyPbuffer(getDisplay(), buffer);
|
||||||
if (!buffer_info->use_display_context)
|
if (!buffer_info->use_display_context)
|
||||||
glXDestroyContext(getDisplay(), context);
|
glXDestroyContext(getDisplay(), context);
|
||||||
free(buffer_info);
|
// free(buffer_info);
|
||||||
decDisplay();
|
decDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,17 +147,17 @@ static bool createPbufferUsingDisplayContext(JNIEnv *env, PbufferInfo *buffer_in
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate(JNIEnv *env, jclass clazz, jboolean use_display_context, jint width, jint height, jobject pixel_format, jobject pixelFormatCaps, jobject pBufferAttribs)
|
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate(JNIEnv *env, jclass clazz, jobject handle_buffer, jboolean use_display_context, jint width, jint height, jobject pixel_format, jobject pixelFormatCaps, jobject pBufferAttribs)
|
||||||
{
|
{
|
||||||
Display *disp = incDisplay(env);
|
Display *disp = incDisplay(env);
|
||||||
if (disp == NULL) {
|
if (disp == NULL) {
|
||||||
return -1;
|
return;
|
||||||
}
|
}
|
||||||
int current_screen = XDefaultScreen(disp);
|
int current_screen = XDefaultScreen(disp);
|
||||||
if (!extgl_InitGLX(env, disp, current_screen)) {
|
if (!extgl_InitGLX(env, disp, current_screen)) {
|
||||||
decDisplay();
|
decDisplay();
|
||||||
throwException(env, "Could not init GLX");
|
throwException(env, "Could not init GLX");
|
||||||
return -1;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int buffer_attribs[] = {GLX_PBUFFER_WIDTH, width,
|
const int buffer_attribs[] = {GLX_PBUFFER_WIDTH, width,
|
||||||
|
@ -166,7 +166,12 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate(JNIEnv *env, jclass
|
||||||
GLX_LARGEST_PBUFFER, False,
|
GLX_LARGEST_PBUFFER, False,
|
||||||
None, None};
|
None, None};
|
||||||
|
|
||||||
PbufferInfo *buffer_info = (PbufferInfo *)malloc(sizeof(PbufferInfo));
|
if (env->GetDirectBufferCapacity(handle_buffer) < sizeof(PbufferInfo)) {
|
||||||
|
throwException(env, "Handle buffer not large enough");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PbufferInfo *buffer_info = (PbufferInfo *)env->GetDirectBufferAddress(handle_buffer);
|
||||||
|
// PbufferInfo *buffer_info = (PbufferInfo *)malloc(sizeof(PbufferInfo));
|
||||||
buffer_info->use_display_context = use_display_context;
|
buffer_info->use_display_context = use_display_context;
|
||||||
bool result;
|
bool result;
|
||||||
if (use_display_context) {
|
if (use_display_context) {
|
||||||
|
@ -175,18 +180,18 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate(JNIEnv *env, jclass
|
||||||
result = createPbufferUsingUniqueContext(env, buffer_info, pixel_format, width, height, buffer_attribs);
|
result = createPbufferUsingUniqueContext(env, buffer_info, pixel_format, width, height, buffer_attribs);
|
||||||
}
|
}
|
||||||
if (!result)
|
if (!result)
|
||||||
return -1;
|
return;
|
||||||
if (!checkXError(env)) {
|
if (!checkXError(env)) {
|
||||||
destroyPbuffer(buffer_info);
|
destroyPbuffer(buffer_info);
|
||||||
return -1;
|
return;
|
||||||
}
|
}
|
||||||
return (jint)buffer_info;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nMakeCurrent
|
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nMakeCurrent
|
||||||
(JNIEnv *env, jclass clazz, jint handle)
|
(JNIEnv *env, jclass clazz, jobject handle_buffer)
|
||||||
{
|
{
|
||||||
PbufferInfo *buffer_info = (PbufferInfo *)handle;
|
PbufferInfo *buffer_info = (PbufferInfo *)env->GetDirectBufferAddress(handle_buffer);
|
||||||
|
//PbufferInfo *buffer_info = (PbufferInfo *)handle;
|
||||||
GLXPbuffer buffer = buffer_info->buffer;
|
GLXPbuffer buffer = buffer_info->buffer;
|
||||||
GLXContext context = buffer_info->context;
|
GLXContext context = buffer_info->context;
|
||||||
if (glXMakeContextCurrent(getDisplay(), buffer, buffer, context) == False) {
|
if (glXMakeContextCurrent(getDisplay(), buffer, buffer, context) == False) {
|
||||||
|
@ -200,26 +205,27 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nMakeCurrent
|
||||||
* Signature: (I)V
|
* Signature: (I)V
|
||||||
*/
|
*/
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nDestroy
|
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nDestroy
|
||||||
(JNIEnv *env, jclass clazz, jint handle)
|
(JNIEnv *env, jclass clazz, jobject handle_buffer)
|
||||||
{
|
{
|
||||||
PbufferInfo *buffer_info = (PbufferInfo *)handle;
|
PbufferInfo *buffer_info = (PbufferInfo *)env->GetDirectBufferAddress(handle_buffer);
|
||||||
|
//PbufferInfo *buffer_info = (PbufferInfo *)handle;
|
||||||
destroyPbuffer(buffer_info);
|
destroyPbuffer(buffer_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nSetAttrib
|
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nSetAttrib
|
||||||
(JNIEnv *env, jclass clazz, jint handle, jint attrib, jint value)
|
(JNIEnv *env, jclass clazz, jobject handle_buffer, jint attrib, jint value)
|
||||||
{
|
{
|
||||||
throwException(env, "The render-to-texture extension is not supported.");
|
throwException(env, "The render-to-texture extension is not supported.");
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nBindTexImage
|
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nBindTexImage
|
||||||
(JNIEnv *env, jclass clazz, jint handle, jint buffer)
|
(JNIEnv *env, jclass clazz, jobject handle_buffer, jint buffer)
|
||||||
{
|
{
|
||||||
throwException(env, "The render-to-texture extension is not supported.");
|
throwException(env, "The render-to-texture extension is not supported.");
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nReleaseTexImage
|
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nReleaseTexImage
|
||||||
(JNIEnv *env, jclass clazz, jint handle, jint buffer)
|
(JNIEnv *env, jclass clazz, jobject handle_buffer, jint buffer)
|
||||||
{
|
{
|
||||||
throwException(env, "The render-to-texture extension is not supported.");
|
throwException(env, "The render-to-texture extension is not supported.");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue