aboutsummaryrefslogtreecommitdiffstats
path: root/C2J/manual/gl-manualCodedImplJNI1-14.java
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/manual/gl-manualCodedImplJNI1-14.java
parent3b0e7fd364c6d61b97f4f2daf405b30e662fddc7 (diff)
Support for NVidia AllocateMemoryNV extension and fixed problem with extensions not being loaded
Diffstat (limited to 'C2J/manual/gl-manualCodedImplJNI1-14.java')
-rw-r--r--C2J/manual/gl-manualCodedImplJNI1-14.java90
1 files changed, 70 insertions, 20 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
+ //
+