diff options
Diffstat (limited to 'src/classes/javax/media/opengl/util/BufferUtil.java.javase')
-rwxr-xr-x | src/classes/javax/media/opengl/util/BufferUtil.java.javase | 19 |
1 files changed, 19 insertions, 0 deletions
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() {} //---------------------------------------------------------------------- |