From 6e14457eac32f838fcdfe9b4b4e26fe7a7d13936 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 2 Sep 2008 05:33:27 +0000 Subject: Fix: TextureIO/TGA for ES2 (GL formats/types) git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1768 232f8b59-042b-4e1e-8c03-345bb8c30851 --- .../javax/media/opengl/util/BufferUtil.java.javase | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/classes/javax/media/opengl/util/BufferUtil.java.javase') 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() {} //---------------------------------------------------------------------- -- cgit v1.2.3