diff options
-rwxr-xr-x | src/classes/com/sun/opengl/util/BufferUtil.java | 39 | ||||
-rwxr-xr-x | src/native/jogl/WindowsWindow.c | 6 |
2 files changed, 42 insertions, 3 deletions
diff --git a/src/classes/com/sun/opengl/util/BufferUtil.java b/src/classes/com/sun/opengl/util/BufferUtil.java index 756f568b4..392a03974 100755 --- a/src/classes/com/sun/opengl/util/BufferUtil.java +++ b/src/classes/com/sun/opengl/util/BufferUtil.java @@ -42,6 +42,8 @@ package com.sun.opengl.util; import java.nio.*; import java.util.*; +import java.lang.reflect.*; + /** Utility routines for dealing with direct buffers. */ public class BufferUtil { @@ -82,8 +84,7 @@ public class BufferUtil { the host platform's native byte order. */ public static ByteBuffer newByteBuffer(int numElements) { ByteBuffer bb = ByteBuffer.allocateDirect(numElements); - // FIXME: refactor dependencies on Java SE buffer classes - // bb.order(ByteOrder.nativeOrder()); + nativeOrder(bb); return bb; } @@ -228,4 +229,38 @@ public class BufferUtil { // dest.rewind(); // return dest; // } + + //---------------------------------------------------------------------- + // Internals only below this point + // + + // NOTE that this work must be done reflectively at the present time + // because this code must compile and run correctly on both CDC/FP and J2SE + private static boolean isCDCFP; + private static Class byteOrderClass; + private static Object nativeOrderObject; + private static Method orderMethod; + + private static void nativeOrder(ByteBuffer buf) { + if (!isCDCFP) { + try { + if (byteOrderClass == null) { + byteOrderClass = Class.forName("java.nio.ByteOrder"); + orderMethod = ByteBuffer.class.getMethod("order", new Class[] { byteOrderClass }); + Method nativeOrderMethod = byteOrderClass.getMethod("nativeOrder", null); + nativeOrderObject = nativeOrderMethod.invoke(null, null); + } + } catch (Throwable t) { + // Must be running on CDC / FP + isCDCFP = true; + } + + if (!isCDCFP) { + try { + orderMethod.invoke(buf, new Object[] { nativeOrderObject }); + } catch (Throwable t) { + } + } + } + } } diff --git a/src/native/jogl/WindowsWindow.c b/src/native/jogl/WindowsWindow.c index 8742e5fbe..157615950 100755 --- a/src/native/jogl/WindowsWindow.c +++ b/src/native/jogl/WindowsWindow.c @@ -224,12 +224,14 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_CreateWin * Signature: (J)V */ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_DispatchMessages - (JNIEnv *env, jclass clazz, jlong window) + (JNIEnv *_env, jclass clazz, jlong window) { int i = 0; MSG msg; BOOL gotOne; + env = _env; + // Periodically take a break do { gotOne = PeekMessage(&msg, (HWND) window, 0, 0, PM_REMOVE); @@ -239,6 +241,8 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_DispatchMe DispatchMessage(&msg); } } while (gotOne && i < 100); + + env = NULL; } /* |