aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/javax/media/opengl/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/classes/javax/media/opengl/util')
-rwxr-xr-xsrc/classes/javax/media/opengl/util/BufferUtil.java.javame_cdc_fp17
-rwxr-xr-xsrc/classes/javax/media/opengl/util/BufferUtil.java.javase19
2 files changed, 36 insertions, 0 deletions
diff --git a/src/classes/javax/media/opengl/util/BufferUtil.java.javame_cdc_fp b/src/classes/javax/media/opengl/util/BufferUtil.java.javame_cdc_fp
index 2496950be..e743658cd 100755
--- a/src/classes/javax/media/opengl/util/BufferUtil.java.javame_cdc_fp
+++ b/src/classes/javax/media/opengl/util/BufferUtil.java.javame_cdc_fp
@@ -85,6 +85,23 @@ public class BufferUtil {
return -1;
}
+ public static final int sizeOfBufferElem(Buffer buffer) {
+ if (buffer == null) {
+ return 0;
+ }
+ if (buffer instanceof ByteBuffer) {
+ return BufferUtil.SIZEOF_BYTE;
+ } else if (buffer instanceof IntBuffer) {
+ return BufferUtil.SIZEOF_INT;
+ } else if (buffer instanceof ShortBuffer) {
+ return BufferUtil.SIZEOF_SHORT;
+ } else if (buffer instanceof FloatBuffer) {
+ return BufferUtil.SIZEOF_FLOAT;
+ }
+ throw new RuntimeException("Unexpected buffer type " +
+ buffer.getClass().getName());
+ }
+
private BufferUtil() {}
//----------------------------------------------------------------------
diff --git a/src/classes/javax/media/opengl/util/BufferUtil.java.javase b/src/classes/javax/media/opengl/util/BufferUtil.java.javase
index f9f6a5d24..2c0652b70 100755
--- a/src/classes/javax/media/opengl/util/BufferUtil.java.javase
+++ b/src/classes/javax/media/opengl/util/BufferUtil.java.javase
@@ -85,6 +85,25 @@ public class BufferUtil {
return -1;
}
+ public static final int sizeOfBufferElem(Buffer buffer) {
+ if (buffer == null) {
+ return 0;
+ }
+ if (buffer instanceof ByteBuffer) {
+ return BufferUtil.SIZEOF_BYTE;
+ } else if (buffer instanceof IntBuffer) {
+ return BufferUtil.SIZEOF_INT;
+ } else if (buffer instanceof ShortBuffer) {
+ return BufferUtil.SIZEOF_SHORT;
+ } else if (buffer instanceof FloatBuffer) {
+ return BufferUtil.SIZEOF_FLOAT;
+ } else if (buffer instanceof DoubleBuffer) {
+ return BufferUtil.SIZEOF_DOUBLE;
+ }
+ throw new RuntimeException("Unexpected buffer type " +
+ buffer.getClass().getName());
+ }
+
private BufferUtil() {}
//----------------------------------------------------------------------