From 4e023eec168517c7a9308decb8b4980e7439eb48 Mon Sep 17 00:00:00 2001 From: kappaOne Date: Tue, 29 Jan 2013 22:59:40 +0000 Subject: [PATCH] Implement animated cursor support on OS X --- src/java/org/lwjgl/input/Cursor.java | 21 ++++++++++++------- .../org_lwjgl_opengl_MacOSXNativeMouse.m | 4 ++-- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/java/org/lwjgl/input/Cursor.java b/src/java/org/lwjgl/input/Cursor.java index 315b2f61..c38c10f3 100644 --- a/src/java/org/lwjgl/input/Cursor.java +++ b/src/java/org/lwjgl/input/Cursor.java @@ -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; iGetDirectBufferAddress(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