diff options
author | Kenneth Russel <[email protected]> | 2008-05-29 12:24:38 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2008-05-29 12:24:38 +0000 |
commit | 45fa88a5904d3740313bd86b7837f21b3c27ca7f (patch) | |
tree | c92c23de6eb86b9a6439ebef646fad32ed8cb5a6 /src | |
parent | 71d9ee31c2f4aa90861c601a184b767a2cb84888 (diff) |
Made call to ByteOrder.nativeOrder() in BufferUtil reflective so it
can be done when running on Java SE even if the code is compiled on
CDC/FP. Fixed bug in WindowsWindow.c where upcalls from native WndProc
were not being made.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1647 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src')
-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; } /* |