aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com/sun/gluegen/runtime
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2006-02-05 18:09:23 +0000
committerKenneth Russel <[email protected]>2006-02-05 18:09:23 +0000
commit875652cab75b68ac30b9b1cc81ee62f7ff1e165d (patch)
tree7e6d85cee9453f6864d9067ac1c90213244ab4e0 /src/java/com/sun/gluegen/runtime
parent98da87017cb72785ca13f5b0657ce2c5d8a067c3 (diff)
Intermediate checkin for FBO support in Java2D/JOGL bridge. Needed to
keep track of server-side OpenGL objects, like textures and display lists, created by the end user to preserve the illusion of independent contexts even though they will all share textures and display lists with the Java2D OpenGL context in order to access its FBO. Added GLObjectTracker class to track creation and destruction of these objects and to support cleanup when the last referring context has been destroyed. Modified GLContextShareSet to create and install GLObjectTrackers when necessary and GLContext to ref and unref tracker appropriately. Changed GlueGen's JavaPrologue and JavaEpilogue directives (and their documentation) to perform argument name substitution. Wrote documentation section on argument name substitution and specified behavior for primitive arrays (converts to string "array_name, array_name_offset" in substitution). Rephrased GlueGen's RangeCheck directives in terms of JavaPrologue directives and deleted old specialized code. Fixed bug in handling of VBO support in GLConfiguration when JavaPrologue was present for affected functions. Added JavaPrologue and JavaEpilogue directives to all existing OpenGL routines creating server-side objects (though it's possible some were missed) to call GLObjectTracker when necessary. Added RangeCheck directives for these routines as well. Worked around bug in JOGL demos where shutdownDemo() was being called more than once. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/gluegen/trunk@13 a78bb65f-1512-4460-ba86-f6dc96a7bf27
Diffstat (limited to 'src/java/com/sun/gluegen/runtime')
-rw-r--r--src/java/com/sun/gluegen/runtime/BufferFactory.java39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/java/com/sun/gluegen/runtime/BufferFactory.java b/src/java/com/sun/gluegen/runtime/BufferFactory.java
index ce46d14..4f095f4 100644
--- a/src/java/com/sun/gluegen/runtime/BufferFactory.java
+++ b/src/java/com/sun/gluegen/runtime/BufferFactory.java
@@ -44,6 +44,7 @@ import java.nio.*;
public class BufferFactory {
public static final int SIZEOF_BYTE = 1;
public static final int SIZEOF_SHORT = 2;
+ public static final int SIZEOF_CHAR = 2;
public static final int SIZEOF_INT = 4;
public static final int SIZEOF_FLOAT = 4;
public static final int SIZEOF_LONG = 8;
@@ -77,7 +78,7 @@ public class BufferFactory {
} else if (buf instanceof LongBuffer) {
return ((LongBuffer) buf).isDirect();
}
- throw new RuntimeException("Unknown buffer type " + buf.getClass().getName());
+ throw new RuntimeException("Unexpected buffer type " + buf.getClass().getName());
}
@@ -101,6 +102,8 @@ public class BufferFactory {
return (buf.position() * SIZEOF_DOUBLE);
} else if (buf instanceof LongBuffer) {
return (buf.position() * SIZEOF_LONG);
+ } else if (buf instanceof CharBuffer) {
+ return (buf.position() * SIZEOF_CHAR);
}
throw new RuntimeException("Disallowed array backing store type in buffer "
@@ -127,6 +130,8 @@ public class BufferFactory {
return ((DoubleBuffer) buf).array();
} else if (buf instanceof LongBuffer) {
return ((LongBuffer) buf).array();
+ } else if (buf instanceof CharBuffer) {
+ return ((CharBuffer) buf).array();
}
throw new RuntimeException("Disallowed array backing store type in buffer "
@@ -156,48 +161,78 @@ public class BufferFactory {
return (SIZEOF_DOUBLE*(((DoubleBuffer)buf).arrayOffset() + pos));
} else if(buf instanceof LongBuffer) {
return (SIZEOF_LONG*(((LongBuffer)buf).arrayOffset() + pos));
+ } else if(buf instanceof CharBuffer) {
+ return (SIZEOF_CHAR*(((CharBuffer)buf).arrayOffset() + pos));
}
throw new RuntimeException("Unknown buffer type " + buf.getClass().getName());
}
public static void rangeCheck(byte[] array, int offset, int minElementsRemaining) {
+ if (array == null) {
+ return;
+ }
+
if (array.length < offset + minElementsRemaining) {
throw new ArrayIndexOutOfBoundsException("Required " + minElementsRemaining + " elements in array, only had " + (array.length - offset));
}
}
public static void rangeCheck(char[] array, int offset, int minElementsRemaining) {
+ if (array == null) {
+ return;
+ }
+
if (array.length < offset + minElementsRemaining) {
throw new ArrayIndexOutOfBoundsException("Required " + minElementsRemaining + " elements in array, only had " + (array.length - offset));
}
}
public static void rangeCheck(short[] array, int offset, int minElementsRemaining) {
+ if (array == null) {
+ return;
+ }
+
if (array.length < offset + minElementsRemaining) {
throw new ArrayIndexOutOfBoundsException("Required " + minElementsRemaining + " elements in array, only had " + (array.length - offset));
}
}
public static void rangeCheck(int[] array, int offset, int minElementsRemaining) {
+ if (array == null) {
+ return;
+ }
+
if (array.length < offset + minElementsRemaining) {
throw new ArrayIndexOutOfBoundsException("Required " + minElementsRemaining + " elements in array, only had " + (array.length - offset));
}
}
public static void rangeCheck(long[] array, int offset, int minElementsRemaining) {
+ if (array == null) {
+ return;
+ }
+
if (array.length < offset + minElementsRemaining) {
throw new ArrayIndexOutOfBoundsException("Required " + minElementsRemaining + " elements in array, only had " + (array.length - offset));
}
}
public static void rangeCheck(float[] array, int offset, int minElementsRemaining) {
+ if (array == null) {
+ return;
+ }
+
if (array.length < offset + minElementsRemaining) {
throw new ArrayIndexOutOfBoundsException("Required " + minElementsRemaining + " elements in array, only had " + (array.length - offset));
}
}
public static void rangeCheck(double[] array, int offset, int minElementsRemaining) {
+ if (array == null) {
+ return;
+ }
+
if (array.length < offset + minElementsRemaining) {
throw new ArrayIndexOutOfBoundsException("Required " + minElementsRemaining + " elements in array, only had " + (array.length - offset));
}
@@ -232,6 +267,8 @@ public class BufferFactory {
bytesRemaining = elementsRemaining * SIZEOF_DOUBLE;
} else if (buffer instanceof LongBuffer) {
bytesRemaining = elementsRemaining * SIZEOF_LONG;
+ } else if (buffer instanceof CharBuffer) {
+ bytesRemaining = elementsRemaining * SIZEOF_CHAR;
}
if (bytesRemaining < minBytesRemaining) {
throw new IndexOutOfBoundsException("Required " + minBytesRemaining + " remaining bytes in buffer, only had " + bytesRemaining);