aboutsummaryrefslogtreecommitdiffstats
path: root/C2J
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2001-11-11 21:30:13 +0000
committerKenneth Russel <[email protected]>2001-11-11 21:30:13 +0000
commitf610ac01f50165b2ea6bc4a81d02abf2e222d876 (patch)
tree2b54144d82803e6665a371b6eeeae6812a16e3ac /C2J
parent3b0e7fd364c6d61b97f4f2daf405b30e662fddc7 (diff)
Support for NVidia AllocateMemoryNV extension and fixed problem with extensions not being loaded
Diffstat (limited to 'C2J')
-rw-r--r--C2J/manual/gl-manualCodedImplJNI1-14.java90
-rw-r--r--C2J/manual/gl-manualCodedImplJNI14.c136
-rw-r--r--C2J/manual/gl-manualCodedVirt1-14.java55
-rw-r--r--C2J/manual/glx-disp-fetch.hc6
-rw-r--r--C2J/manual/glx-disp-var.h3
-rw-r--r--C2J/manual/glx-disp-var.hc3
-rwxr-xr-xC2J/manual/wgl-disp-fetch.hc55
-rw-r--r--C2J/manual/wgl-disp-var.h4
-rw-r--r--C2J/manual/wgl-disp-var.hc3
9 files changed, 254 insertions, 101 deletions
diff --git a/C2J/manual/gl-manualCodedImplJNI1-14.java b/C2J/manual/gl-manualCodedImplJNI1-14.java
index 7e490ba..0fc04ce 100644
--- a/C2J/manual/gl-manualCodedImplJNI1-14.java
+++ b/C2J/manual/gl-manualCodedImplJNI1-14.java
@@ -1,20 +1,70 @@
-/**
- * @(#) GLFunc14JauJNI.java
- */
-
-
-package gl4java;
-
-import java.nio.*;
-
-/**
- * The default implementation class for OpenGL native function mapping
- *
- * @version 2.00, 21. April 1999
- * @author Sven Goethel
- */
-public class GLFunc14JauJNI
- implements GLFunc14
-{
-
-
+/**
+ * @(#) GLFunc14JauJNI.java
+ */
+
+
+package gl4java;
+
+import java.nio.*;
+import gl4java.utils.DirectBufferCleanup;
+
+/**
+ * The default implementation class for OpenGL native function mapping
+ *
+ * @version 2.00, 21. April 1999
+ * @author Sven Goethel
+ */
+public class GLFunc14JauJNI
+ implements GLFunc14
+{
+
+ //----------------------------------------------------------------------
+ // Special-case routines requiring hand coding
+ //
+
+ /** Access to the underlying wglAllocateMemoryNV or
+ glXAllocateMemoryNV routine, if present. Presence of this
+ routine can be queried by calling GLContext.gljTestGLProc with
+ the argument "glAllocateMemoryNV". */
+ public ByteBuffer glAllocateMemoryNV(int size,
+ float readFreq,
+ float writeFreq,
+ float priority) {
+ long address = glAllocateMemoryNV0(size, readFreq, writeFreq, priority);
+ if (address == 0) {
+ throw new OutOfMemoryError();
+ }
+ ByteBuffer buf = newDirectByteBuffer(address, size);
+ registerForCleanup(this, buf);
+ return buf;
+ }
+
+ /** This delegates to either wglAllocateMemoryNV or
+ glXAllocateMemoryNV in the native code, depending on the window
+ system */
+ private native long glAllocateMemoryNV0(int size, float readFreq, float writeFreq, float priority);
+
+ /** This delegates to either wglFreeMemoryNV or glXFreeMemoryNV in
+ the native code, depending on the window system */
+ private native void glFreeMemoryNV0(long addr);
+
+ /** Allocate a direct byte buffer pointing at an arbitrary memory
+ address -- must be hidden for security reasons */
+ private native ByteBuffer newDirectByteBuffer(long addr, int capacity);
+
+ private static volatile DirectBufferCleanup cleanup;
+ private static synchronized void registerForCleanup(final GLFunc14JauJNI gl, Buffer buf) {
+ if (cleanup == null) {
+ cleanup = new DirectBufferCleanup(new DirectBufferCleanup.Callback() {
+ public void cleanup(long addr) {
+ gl.glFreeMemoryNV0(addr);
+ }
+ });
+ }
+ cleanup.register(buf);
+ }
+
+ //----------------------------------------------------------------------
+ // All other routines below are autogenerated
+ //
+
diff --git a/C2J/manual/gl-manualCodedImplJNI14.c b/C2J/manual/gl-manualCodedImplJNI14.c
index 9bbf519..73bad7e 100644
--- a/C2J/manual/gl-manualCodedImplJNI14.c
+++ b/C2J/manual/gl-manualCodedImplJNI14.c
@@ -1,37 +1,99 @@
-/** THIS IS A MANUAL CODED PART
- gl-manualCodedImplJNI.java
-*/
-
-static const char _gl_n_a_string[] = "GL-String not avaiable !";
-
-JNIEXPORT jstring JNICALL
-Java_gl4java_GLFunc14JauJNI_glGetString ( JNIEnv *env, jobject obj,
- jint name )
-{
- const char * tmpString=0;
-
- if ( disp__glGetString == NULL )
- return (*env)->NewStringUTF(env, _gl_n_a_string);
-
- tmpString = disp__glGetString ( /* jint */ name);
- if(tmpString==NULL)
- tmpString=_gl_n_a_string;
-
- return (*env)->NewStringUTF(env, tmpString);
-}
-
-static const char * _gl_lib_vendor_="Jausoft - Sven Goethel Software Development";
-static const char * _gl_lib_version_="2.8.0.8";
-
-JNIEXPORT jstring JNICALL
-Java_gl4java_GLFunc14JauJNI_getNativeVendor ( JNIEnv *env, jobject obj )
-{
- return (*env)->NewStringUTF(env, _gl_lib_vendor_);
-}
-
-JNIEXPORT jstring JNICALL
-Java_gl4java_GLFunc14JauJNI_getNativeVersion ( JNIEnv *env, jobject obj )
-{
- return (*env)->NewStringUTF(env, _gl_lib_version_);
-}
-
+/** THIS IS A MANUAL CODED PART
+ gl-manualCodedImplJNI.java
+*/
+
+static const char _gl_n_a_string[] = "GL-String not avaiable !";
+
+JNIEXPORT jstring JNICALL
+Java_gl4java_GLFunc14JauJNI_glGetString ( JNIEnv *env, jobject obj,
+ jint name )
+{
+ const char * tmpString=0;
+
+ if ( disp__glGetString == NULL )
+ return (*env)->NewStringUTF(env, _gl_n_a_string);
+
+ tmpString = disp__glGetString ( /* jint */ name);
+ if(tmpString==NULL)
+ tmpString=_gl_n_a_string;
+
+ return (*env)->NewStringUTF(env, tmpString);
+}
+
+static const char * _gl_lib_vendor_="Jausoft - Sven Goethel Software Development";
+static const char * _gl_lib_version_="2.8.0.8";
+
+JNIEXPORT jstring JNICALL
+Java_gl4java_GLFunc14JauJNI_getNativeVendor ( JNIEnv *env, jobject obj )
+{
+ return (*env)->NewStringUTF(env, _gl_lib_vendor_);
+}
+
+JNIEXPORT jstring JNICALL
+Java_gl4java_GLFunc14JauJNI_getNativeVersion ( JNIEnv *env, jobject obj )
+{
+ return (*env)->NewStringUTF(env, _gl_lib_version_);
+}
+
+//----------------------------------------------------------------------
+// Support for NVidia routines
+//
+
+#include "ptrtypes.h"
+
+#ifdef _X11_
+ #include <GL/glx.h>
+ #include <dlfcn.h>
+ #include "glxtool.h"
+ #include <unistd.h>
+#endif
+
+#ifdef _WIN32_
+ #include "wgltool.h"
+#endif
+
+#define GET_GL_PROCADDRESS(a) getGLProcAddressHelper (NULL, NULL, (a), NULL, 1, 0);
+
+JNIEXPORT jlong JNICALL
+Java_gl4java_GLFunc14JauJNI_glAllocateMemoryNV0(JNIEnv* env, jobject unused,
+ jint size,
+ jfloat readFreq,
+ jfloat writeFreq,
+ jfloat priority)
+{
+ void* (CALLBACK *disp__glAllocateMemoryNV)(int, float, float, float) =
+#ifdef _WIN32_
+ disp__wglAllocateMemoryNV;
+#elif defined(_X11_)
+ disp__glXAllocateMemoryNV;
+#else
+ NULL;
+#endif
+
+ if (disp__glAllocateMemoryNV == NULL) return 0;
+
+ return ((uintptr_t) disp__glAllocateMemoryNV(size, readFreq, writeFreq, priority));
+}
+
+JNIEXPORT void JNICALL
+Java_gl4java_GLFunc14JauJNI_glFreeMemoryNV0(JNIEnv* env, jobject unused, jlong address)
+{
+ void (CALLBACK *disp__glFreeMemoryNV)(void*) =
+#if (defined(_WIN32_))
+ disp__wglFreeMemoryNV;
+#elif defined(_X11_)
+ disp__glXFreeMemoryNV;
+#else
+ NULL;
+#endif
+
+ if (disp__glFreeMemoryNV == NULL) return;
+
+ disp__glFreeMemoryNV((void*) ((uintptr_t) address));
+}
+
+JNIEXPORT jobject JNICALL
+Java_gl4java_GLFunc14JauJNI_newDirectByteBuffer(JNIEnv* env, jobject unused, jlong addr, jint capacity)
+{
+ return (*env)->NewDirectByteBuffer(env, (void *) ((uintptr_t) addr), capacity);
+}
diff --git a/C2J/manual/gl-manualCodedVirt1-14.java b/C2J/manual/gl-manualCodedVirt1-14.java
index 38bb132..881b23f 100644
--- a/C2J/manual/gl-manualCodedVirt1-14.java
+++ b/C2J/manual/gl-manualCodedVirt1-14.java
@@ -1,19 +1,36 @@
-/**
- * @(#) GLFunc14.java
- */
-
-
-package gl4java;
-
-import java.nio.*;
-
-/**
- * The base interface for OpenGL native function mapping
- *
- * @version 2.00, 21. April 1999
- * @author Sven Goethel
- */
-public interface GLFunc14
- extends GLFunc
-{
-
+/**
+ * @(#) GLFunc14.java
+ */
+
+
+package gl4java;
+
+import java.nio.*;
+
+/**
+ * The base interface for OpenGL native function mapping
+ *
+ * @version 2.00, 21. April 1999
+ * @author Sven Goethel
+ */
+public interface GLFunc14
+ extends GLFunc
+{
+
+ //----------------------------------------------------------------------
+ // Special-case routines requiring hand coding
+ //
+
+ /** Access to the underlying wglAllocateMemoryNV or
+ glXAllocateMemoryNV routine, if present. Presence of this
+ routine can be queried by calling GLContext.gljTestGLProc with
+ the argument "glAllocateMemoryNV". */
+ public ByteBuffer glAllocateMemoryNV(int size,
+ float readFreq,
+ float writeFreq,
+ float priority);
+
+ //----------------------------------------------------------------------
+ // All other routines below are autogenerated
+ //
+
diff --git a/C2J/manual/glx-disp-fetch.hc b/C2J/manual/glx-disp-fetch.hc
index 89ae276..f35991c 100644
--- a/C2J/manual/glx-disp-fetch.hc
+++ b/C2J/manual/glx-disp-fetch.hc
@@ -35,3 +35,9 @@
disp__glXSwapBuffers = (void (CALLBACK *) (Display *, GLXDrawable))
GET_GL_PROCADDRESS("glXSwapBuffers");
+ /* NVidia support */
+ disp__glXAllocateMemoryNV = (void* (CALLBACK * )(int, float, float, float))
+ GET_GL_PROCADDRESS("glXAllocateMemoryNV");
+
+ disp__glXFreeMemoryNV = (void (CALLBACK * )(void*))
+ GET_GL_PROCADDRESS("glXFreeMemoryNV");
diff --git a/C2J/manual/glx-disp-var.h b/C2J/manual/glx-disp-var.h
index c87ccfd..2c05490 100644
--- a/C2J/manual/glx-disp-var.h
+++ b/C2J/manual/glx-disp-var.h
@@ -13,3 +13,6 @@ LIBAPI int (CALLBACK * disp__glXGetConfig) (Display *, XVisualInfo *, int, int *
LIBAPI Bool (CALLBACK * disp__glXMakeCurrent) (Display *, GLXDrawable, GLXContext);
LIBAPI void (CALLBACK * disp__glXSwapBuffers) (Display *, GLXDrawable);
+/* NVidia support */
+LIBAPI void* (CALLBACK * disp__glXAllocateMemoryNV)(int, float, float, float);
+LIBAPI void (CALLBACK * disp__glXFreeMemoryNV) (void*);
diff --git a/C2J/manual/glx-disp-var.hc b/C2J/manual/glx-disp-var.hc
index c24a839..99cc0a3 100644
--- a/C2J/manual/glx-disp-var.hc
+++ b/C2J/manual/glx-disp-var.hc
@@ -13,3 +13,6 @@ int (CALLBACK * disp__glXGetConfig) (Display *, XVisualInfo *, int, int *) = NUL
Bool (CALLBACK * disp__glXMakeCurrent) (Display *, GLXDrawable, GLXContext) = NULL;
void (CALLBACK * disp__glXSwapBuffers) (Display *, GLXDrawable) = NULL;
+/* NVidia support */
+void* (CALLBACK * disp__glXAllocateMemoryNV)(int, float, float, float) = NULL;
+void (CALLBACK * disp__glXFreeMemoryNV) (void*) = NULL;
diff --git a/C2J/manual/wgl-disp-fetch.hc b/C2J/manual/wgl-disp-fetch.hc
index 4a84ecc..049ca18 100755
--- a/C2J/manual/wgl-disp-fetch.hc
+++ b/C2J/manual/wgl-disp-fetch.hc
@@ -1,26 +1,31 @@
-
- disp__wglCopyContext = (BOOL (CALLBACK *)(HGLRC, HGLRC, UINT))
- GET_GL_PROCADDRESS("wglCopyContext");
-
- disp__wglCreateContext = (HGLRC (CALLBACK *)(HDC))
- GET_GL_PROCADDRESS("wglCreateContext");
-
- disp__wglCreateLayerContext = (HGLRC (CALLBACK *)(HDC, int))
- GET_GL_PROCADDRESS("wglCreateLayerContext");
-
- disp__wglDeleteContext = (BOOL (CALLBACK *)(HGLRC))
- GET_GL_PROCADDRESS("wglDeleteContext");
-
- disp__wglGetCurrentContext = (HGLRC (CALLBACK *)(VOID))
- GET_GL_PROCADDRESS("wglGetCurrentContext");
-
- disp__wglGetCurrentDC = (HDC (CALLBACK *)(VOID))
- GET_GL_PROCADDRESS("wglGetCurrentDC");
-
- disp__wglMakeCurrent = (BOOL (CALLBACK *)(HDC, HGLRC))
- GET_GL_PROCADDRESS("wglMakeCurrent");
-
- disp__wglShareLists = (BOOL (CALLBACK *)(HGLRC, HGLRC))
- GET_GL_PROCADDRESS("wglShareLists");
-
+ disp__wglCopyContext = (BOOL (CALLBACK *)(HGLRC, HGLRC, UINT))
+ GET_GL_PROCADDRESS("wglCopyContext");
+
+ disp__wglCreateContext = (HGLRC (CALLBACK *)(HDC))
+ GET_GL_PROCADDRESS("wglCreateContext");
+
+ disp__wglCreateLayerContext = (HGLRC (CALLBACK *)(HDC, int))
+ GET_GL_PROCADDRESS("wglCreateLayerContext");
+
+ disp__wglDeleteContext = (BOOL (CALLBACK *)(HGLRC))
+ GET_GL_PROCADDRESS("wglDeleteContext");
+
+ disp__wglGetCurrentContext = (HGLRC (CALLBACK *)(VOID))
+ GET_GL_PROCADDRESS("wglGetCurrentContext");
+
+ disp__wglGetCurrentDC = (HDC (CALLBACK *)(VOID))
+ GET_GL_PROCADDRESS("wglGetCurrentDC");
+
+ disp__wglMakeCurrent = (BOOL (CALLBACK *)(HDC, HGLRC))
+ GET_GL_PROCADDRESS("wglMakeCurrent");
+
+ disp__wglShareLists = (BOOL (CALLBACK *)(HGLRC, HGLRC))
+ GET_GL_PROCADDRESS("wglShareLists");
+
+ /* NVidia support */
+ disp__wglAllocateMemoryNV = (void* (CALLBACK * )(int, float, float, float))
+ GET_GL_PROCADDRESS("wglAllocateMemoryNV");
+
+ disp__wglFreeMemoryNV = (void (CALLBACK * )(void*))
+ GET_GL_PROCADDRESS("wglFreeMemoryNV");
diff --git a/C2J/manual/wgl-disp-var.h b/C2J/manual/wgl-disp-var.h
index 44b47e3..8bf14ce 100644
--- a/C2J/manual/wgl-disp-var.h
+++ b/C2J/manual/wgl-disp-var.h
@@ -9,4 +9,8 @@ LIBAPI HDC (CALLBACK * disp__wglGetCurrentDC)(VOID);
LIBAPI BOOL (CALLBACK * disp__wglMakeCurrent)(HDC, HGLRC);
LIBAPI BOOL (CALLBACK * disp__wglShareLists)(HGLRC, HGLRC);
+/* NVidia support */
+LIBAPI void* (CALLBACK * disp__wglAllocateMemoryNV)(int, float, float, float);
+LIBAPI void (CALLBACK * disp__wglFreeMemoryNV) (void*);
+
diff --git a/C2J/manual/wgl-disp-var.hc b/C2J/manual/wgl-disp-var.hc
index 8d4cde1..81dc2e5 100644
--- a/C2J/manual/wgl-disp-var.hc
+++ b/C2J/manual/wgl-disp-var.hc
@@ -8,4 +8,7 @@ HDC (CALLBACK * disp__wglGetCurrentDC)(VOID) = NULL;
BOOL (CALLBACK * disp__wglMakeCurrent)(HDC, HGLRC) = NULL;
BOOL (CALLBACK * disp__wglShareLists)(HGLRC, HGLRC) = NULL;
+/* NVidia support */
+void* (CALLBACK * disp__wglAllocateMemoryNV)(int, float, float, float) = NULL;
+void (CALLBACK * disp__wglFreeMemoryNV) (void*) = NULL;