summaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/common/nio
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-05-01 07:37:05 +0200
committerSven Gothel <[email protected]>2011-05-01 07:37:05 +0200
commitc5a56e10677e9dc0a048c2be3de16701aac9ad17 (patch)
tree9bdaf542760679d516d7e286cf8f9d8af0a18a23 /src/java/com/jogamp/common/nio
parentee90bc9e9c90b81e786fc9eb114c18a0e08b9599 (diff)
PointerBuffer: Add duplicate() method (as req by JOCL)
Diffstat (limited to 'src/java/com/jogamp/common/nio')
-rw-r--r--src/java/com/jogamp/common/nio/PointerBuffer.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/java/com/jogamp/common/nio/PointerBuffer.java b/src/java/com/jogamp/common/nio/PointerBuffer.java
index 69f8bbd..089b8b1 100644
--- a/src/java/com/jogamp/common/nio/PointerBuffer.java
+++ b/src/java/com/jogamp/common/nio/PointerBuffer.java
@@ -97,6 +97,25 @@ public class PointerBuffer extends AbstractBuffer<PointerBuffer> {
return new PointerBuffer(src);
}
+ /**
+ * @return new PointerBuffer sharing the same buffer data of this instance (identity),
+ * but having independent position, limit and capacity.
+ */
+ public final PointerBuffer duplicate() {
+ PointerBuffer npb;
+ if (Platform.is32Bit()) {
+ npb = new PointerBuffer((IntBuffer)buffer);
+ } else {
+ npb = new PointerBuffer((LongBuffer)buffer);
+ }
+ if(null != dataMap) {
+ npb.dataMap = (LongObjectHashMap) dataMap.clone();
+ }
+ npb.capacity = capacity;
+ npb.position = position;
+ return npb;
+ }
+
/**
* Relative bulk get method. Copy the source values <code> src[position .. capacity] [</code>
* to this buffer and increment the position by <code>capacity-position</code>. */