Implement animated cursor support on OS X
This commit is contained in:
parent
27cfdf646e
commit
4e023eec16
|
@ -163,20 +163,27 @@ public class Cursor {
|
|||
IntBuffer images_copy = BufferUtils.createIntBuffer(images.remaining());
|
||||
flipImages(width, height, numImages, images, images_copy);
|
||||
|
||||
// Win32 doesn't (afaik) allow for animation based cursors, except when they're
|
||||
// in the .ani format, which we don't support.
|
||||
// Mac and Windows doesn't (afaik) allow for animation based cursors, except in the .ani
|
||||
// format on Windows, which we don't support.
|
||||
// The cursor animation was therefor developed using java side time tracking.
|
||||
// unfortunately X flickers when changing cursor. We therefore check for either
|
||||
// Win32 or X and do accordingly. This hasn't been implemented on Mac, but we
|
||||
// might want to split it into a X/Win/Mac cursor if it gets too cluttered
|
||||
// Windows, Mac or X and do accordingly.
|
||||
// we might want to split it into a X/Win/Mac cursor if it gets too cluttered
|
||||
|
||||
CursorElement[] cursors;
|
||||
switch (LWJGLUtil.getPlatform()) {
|
||||
case LWJGLUtil.PLATFORM_MACOSX:
|
||||
// create our cursor elements
|
||||
Object handle_mac = Mouse.getImplementation().createCursor(width, height, xHotspot, yHotspot, numImages, images_copy, delays);
|
||||
CursorElement cursor_element_mac = new CursorElement(handle_mac, -1, -1);
|
||||
cursors = new CursorElement[]{cursor_element_mac};
|
||||
cursors = new CursorElement[numImages];
|
||||
for(int i=0; i<numImages; i++) {
|
||||
Object handle = Mouse.getImplementation().createCursor(width, height, xHotspot, yHotspot, 1, images_copy, null);
|
||||
long delay = (delays != null) ? delays.get(i) : 0;
|
||||
long timeout = System.currentTimeMillis();
|
||||
cursors[i] = new CursorElement(handle, delay, timeout);
|
||||
|
||||
// offset to next image
|
||||
images_copy.position(width*height*(i+1));
|
||||
}
|
||||
break;
|
||||
case LWJGLUtil.PLATFORM_WINDOWS:
|
||||
// create our cursor elements
|
||||
|
|
|
@ -101,10 +101,10 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXNativeMouse_nUnregisterMouseL
|
|||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_MacOSXNativeMouse_nCreateCursor(JNIEnv *env, jobject _this, 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) {
|
||||
jint *bytes = (jint *)(*env)->GetDirectBufferAddress(env, image_buffer);
|
||||
jlong *bytes = (jint *)(*env)->GetDirectBufferAddress(env, image_buffer) + images_offset;
|
||||
|
||||
NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc]
|
||||
initWithBitmapDataPlanes:(jint *)&bytes
|
||||
initWithBitmapDataPlanes:(jlong *)&bytes
|
||||
pixelsWide:width pixelsHigh:height
|
||||
bitsPerSample:8
|
||||
samplesPerPixel:4
|
||||
|
|
Loading…
Reference in New Issue