summaryrefslogtreecommitdiffstats
path: root/src/net/java/games/jogl/util
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2003-08-07 22:59:28 +0000
committerKenneth Russel <[email protected]>2003-08-07 22:59:28 +0000
commitc26d94809629a6c65d1bda01799e9356bd2386e6 (patch)
tree01c5baa7d4d104d3ca395f2db98b9480a0158baf /src/net/java/games/jogl/util
parentdb0bdc71eec40d7fcd22ddcea87178c8805d4312 (diff)
Fixed bug abies pointed out in ARBVBOKey where it was necessary to
override hashCode() and therefore equals(). Added caching of BufferUtils.bufferOffset() buffers. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@48 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/net/java/games/jogl/util')
-rw-r--r--src/net/java/games/jogl/util/BufferUtils.java15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/net/java/games/jogl/util/BufferUtils.java b/src/net/java/games/jogl/util/BufferUtils.java
index 05125b75e..88afa1c8f 100644
--- a/src/net/java/games/jogl/util/BufferUtils.java
+++ b/src/net/java/games/jogl/util/BufferUtils.java
@@ -40,6 +40,7 @@
package net.java.games.jogl.util;
import java.nio.*;
+import java.util.*;
/** Utility routines for dealing with direct buffers. */
@@ -70,6 +71,8 @@ public class BufferUtils {
return dest;
}
+ private static Map bufferOffsetCache = Collections.synchronizedMap(new HashMap());
+
/** Creates an "offset buffer" for use with the
ARB_vertex_buffer_object extension. The resulting Buffers are
suitable for use with routines such as glVertexPointer <em>when
@@ -77,5 +80,15 @@ public class BufferUtils {
capacity and are not suitable for passing to OpenGL routines
that do not support buffer offsets, or to non-OpenGL
routines. */
- public static native ByteBuffer bufferOffset(int offset);
+ public static ByteBuffer bufferOffset(int offset) {
+ Integer key = new Integer(offset);
+ ByteBuffer buf = (ByteBuffer) bufferOffsetCache.get(key);
+ if (buf == null) {
+ buf = bufferOffset0(offset);
+ bufferOffsetCache.put(key, buf);
+ }
+ return buf;
+ }
+
+ private static native ByteBuffer bufferOffset0(int offset);
}