aboutsummaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-03-05 23:44:41 +0100
committerSven Gothel <[email protected]>2012-03-05 23:44:41 +0100
commitb78966195b2dca68b4aa971651005a787e62a54f (patch)
tree5f27d78b3d23c1b7a2ad5956b9f7b25f882fa90c /src/java
parent7e8ff7c755b5b4bc9e63c08ab161598a99cad38a (diff)
Fix NIO Buffers<T> .put<Type1>(<Type2>) - Add appropriate source -> destination handling (Float/Long/Double/..)
Diffstat (limited to 'src/java')
-rwxr-xr-xsrc/java/com/jogamp/common/nio/Buffers.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/java/com/jogamp/common/nio/Buffers.java b/src/java/com/jogamp/common/nio/Buffers.java
index c1bcffd..27000fe 100755
--- a/src/java/com/jogamp/common/nio/Buffers.java
+++ b/src/java/com/jogamp/common/nio/Buffers.java
@@ -632,6 +632,14 @@ public class Buffers {
return (B) ((ShortBuffer) dest).put((short) v);
} else if (dest instanceof IntBuffer) {
return (B) ((IntBuffer) dest).put((int) v);
+ } else if (dest instanceof FloatBuffer) {
+ return (B) ((FloatBuffer) dest).put((float) v);
+ } else if (dest instanceof LongBuffer) {
+ return (B) ((LongBuffer) dest).put((long) v);
+ } else if (dest instanceof DoubleBuffer) {
+ return (B) ((DoubleBuffer) dest).put((double) v);
+ } else if (dest instanceof CharBuffer) {
+ return (B) ((CharBuffer) dest).put((char) v);
} else {
throw new IllegalArgumentException("Byte doesn't match Buffer Class: " + dest);
}
@@ -643,6 +651,12 @@ public class Buffers {
return (B) ((ShortBuffer) dest).put(v);
} else if (dest instanceof IntBuffer) {
return (B) ((IntBuffer) dest).put((int) v);
+ } else if (dest instanceof FloatBuffer) {
+ return (B) ((FloatBuffer) dest).put((float) v);
+ } else if (dest instanceof LongBuffer) {
+ return (B) ((LongBuffer) dest).put((long) v);
+ } else if (dest instanceof DoubleBuffer) {
+ return (B) ((DoubleBuffer) dest).put((double) v);
} else {
throw new IllegalArgumentException("Short doesn't match Buffer Class: " + dest);
}
@@ -652,14 +666,23 @@ public class Buffers {
public static <B extends Buffer> B puti(B dest, int v) {
if (dest instanceof IntBuffer) {
return (B) ((IntBuffer) dest).put(v);
+ } else if (dest instanceof FloatBuffer) {
+ return (B) ((FloatBuffer) dest).put((float) v);
+ } else if (dest instanceof LongBuffer) {
+ return (B) ((LongBuffer) dest).put((long) v);
+ } else if (dest instanceof DoubleBuffer) {
+ return (B) ((DoubleBuffer) dest).put((double) v);
} else {
throw new IllegalArgumentException("Integer doesn't match Buffer Class: " + dest);
}
}
+ @SuppressWarnings("unchecked")
public static <B extends Buffer> B putf(B dest, float v) {
if (dest instanceof FloatBuffer) {
return (B) ((FloatBuffer) dest).put(v);
+ } else if (dest instanceof DoubleBuffer) {
+ return (B) ((DoubleBuffer) dest).put((double) v);
/* TODO FixedPoint required
} else if (dest instanceof IntBuffer) {
return (B) ((IntBuffer) dest).put(FixedPoint.toFixed(v));
@@ -668,6 +691,8 @@ public class Buffers {
throw new IllegalArgumentException("Float doesn't match Buffer Class: " + dest);
}
}
+
+ @SuppressWarnings("unchecked")
public static <B extends Buffer> B putd(B dest, double v) {
if (dest instanceof FloatBuffer) {
return (B) ((FloatBuffer) dest).put((float) v);