Fix colors on OS X native cursors

This commit is contained in:
kappaOne 2013-01-31 22:44:43 +00:00
parent 4e023eec16
commit 0d25914029
1 changed files with 24 additions and 0 deletions

View File

@ -173,6 +173,10 @@ public class Cursor {
CursorElement[] cursors;
switch (LWJGLUtil.getPlatform()) {
case LWJGLUtil.PLATFORM_MACOSX:
// OS X requires the image format to be in ABGR format
convertARGBtoABGR(images_copy);
// create our cursor elements
cursors = new CursorElement[numImages];
for(int i=0; i<numImages; i++) {
@ -220,6 +224,26 @@ public class Cursor {
}
return cursors;
}
/**
* Convert an IntBuffer image of ARGB format into ABGR
*
* @param imageBuffer image to convert
*/
private static void convertARGBtoABGR(IntBuffer imageBuffer) {
for (int i = 0; i < imageBuffer.limit(); i++) {
int argbColor = imageBuffer.get(i);
byte alpha = (byte)(argbColor >>> 24);
byte blue = (byte)(argbColor >>> 16);
byte green = (byte)(argbColor >>> 8);
byte red = (byte)argbColor;
int abgrColor = ((alpha & 0xff) << 24 ) + ((red & 0xff) << 16 ) + ((green & 0xff) << 8 ) + ((blue & 0xff) );
imageBuffer.put(i, abgrColor);
}
}
/**
* Flips the images so they're oriented according to opengl