diff options
author | Kenneth Russel <[email protected]> | 2007-04-21 17:30:20 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2007-04-21 17:30:20 +0000 |
commit | c791ac0ce54c774d8e1aa74d683acd4a4350ed53 (patch) | |
tree | f73bc2f8953c46d33b61a9002a69907e0911cf74 | |
parent | da78f003d6c617e533ff4f0425c7d26d8119e9dd (diff) |
Bug fixes to addition and removal operations in Vec[234]fCollections
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/joglutils/trunk@67 83d24430-9974-4f80-8418-2cc3294053b9
3 files changed, 15 insertions, 15 deletions
diff --git a/src/net/java/joglutils/msg/collections/Vec2fCollection.java b/src/net/java/joglutils/msg/collections/Vec2fCollection.java index a5ad3d3..d0dadc1 100644 --- a/src/net/java/joglutils/msg/collections/Vec2fCollection.java +++ b/src/net/java/joglutils/msg/collections/Vec2fCollection.java @@ -39,8 +39,6 @@ package net.java.joglutils.msg.collections; import java.nio.*; -import com.sun.opengl.util.*; - import net.java.joglutils.msg.impl.*; import net.java.joglutils.msg.math.*; @@ -103,9 +101,10 @@ public class Vec2fCollection { public void add(Vec2f value) { FloatBuffer buf = data; if (buf.limit() == buf.capacity()) { - FloatBuffer newBuf = BufferUtil.newFloatBuffer(Math.max(buf.capacity() + ELEMENT_SIZE, - round((int) (buf.capacity() * 1.5f)))); + FloatBuffer newBuf = BufferFactory.newFloatBuffer(Math.max(buf.capacity() + ELEMENT_SIZE, + round((int) (buf.capacity() * 1.5f)))); newBuf.put(buf); + newBuf.rewind(); newBuf.limit(buf.limit()); data = newBuf; buf = newBuf; @@ -129,11 +128,12 @@ public class Vec2fCollection { // Simply lower the limit buf.limit(buf.limit() - ELEMENT_SIZE); } else { - buf.position(pos + 1); + buf.position(pos + ELEMENT_SIZE); FloatBuffer rest = buf.slice(); buf.position(pos); buf.put(rest); buf.limit(buf.limit() - ELEMENT_SIZE); + buf.rewind(); } return res; } diff --git a/src/net/java/joglutils/msg/collections/Vec3fCollection.java b/src/net/java/joglutils/msg/collections/Vec3fCollection.java index 698017d..887b4c9 100644 --- a/src/net/java/joglutils/msg/collections/Vec3fCollection.java +++ b/src/net/java/joglutils/msg/collections/Vec3fCollection.java @@ -39,8 +39,6 @@ package net.java.joglutils.msg.collections; import java.nio.*; -import com.sun.opengl.util.*; - import net.java.joglutils.msg.impl.*; import net.java.joglutils.msg.math.*; @@ -104,9 +102,10 @@ public class Vec3fCollection { public void add(Vec3f value) { FloatBuffer buf = data; if (buf.limit() == buf.capacity()) { - FloatBuffer newBuf = BufferUtil.newFloatBuffer(Math.max(buf.capacity() + ELEMENT_SIZE, - round((int) (buf.capacity() * 1.5f)))); + FloatBuffer newBuf = BufferFactory.newFloatBuffer(Math.max(buf.capacity() + ELEMENT_SIZE, + round((int) (buf.capacity() * 1.5f)))); newBuf.put(buf); + newBuf.rewind(); newBuf.limit(buf.limit()); data = newBuf; buf = newBuf; @@ -131,11 +130,12 @@ public class Vec3fCollection { // Simply lower the limit buf.limit(buf.limit() - ELEMENT_SIZE); } else { - buf.position(pos + 1); + buf.position(pos + ELEMENT_SIZE); FloatBuffer rest = buf.slice(); buf.position(pos); buf.put(rest); buf.limit(buf.limit() - ELEMENT_SIZE); + buf.rewind(); } return res; } diff --git a/src/net/java/joglutils/msg/collections/Vec4fCollection.java b/src/net/java/joglutils/msg/collections/Vec4fCollection.java index a1d1e86..2f940cd 100644 --- a/src/net/java/joglutils/msg/collections/Vec4fCollection.java +++ b/src/net/java/joglutils/msg/collections/Vec4fCollection.java @@ -39,8 +39,6 @@ package net.java.joglutils.msg.collections; import java.nio.*; -import com.sun.opengl.util.*; - import net.java.joglutils.msg.impl.*; import net.java.joglutils.msg.math.*; @@ -105,9 +103,10 @@ public class Vec4fCollection { public void add(Vec4f value) { FloatBuffer buf = data; if (buf.limit() == buf.capacity()) { - FloatBuffer newBuf = BufferUtil.newFloatBuffer(Math.max(buf.capacity() + ELEMENT_SIZE, - round((int) (buf.capacity() * 1.5f)))); + FloatBuffer newBuf = BufferFactory.newFloatBuffer(Math.max(buf.capacity() + ELEMENT_SIZE, + round((int) (buf.capacity() * 1.5f)))); newBuf.put(buf); + newBuf.rewind(); newBuf.limit(buf.limit()); data = newBuf; buf = newBuf; @@ -133,11 +132,12 @@ public class Vec4fCollection { // Simply lower the limit buf.limit(buf.limit() - ELEMENT_SIZE); } else { - buf.position(pos + 1); + buf.position(pos + ELEMENT_SIZE); FloatBuffer rest = buf.slice(); buf.position(pos); buf.put(rest); buf.limit(buf.limit() - ELEMENT_SIZE); + buf.rewind(); } return res; } |