From e088362d49d9c64fa3c862d7a3cd6f07485985eb Mon Sep 17 00:00:00 2001 From: Kenneth Russel Date: Thu, 18 Nov 2004 23:17:23 +0000 Subject: Partial fix for Issue 42: Problems invoking GLU functions Incorporated the LWJGL team's port of the GLU quadric and projection routines to be able to eliminate calls to the native GLU library for these cases, which was problematic on certain Linux distributions. Still need to port at least some of the mipmap routines and the NURBS tesselator. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@172 232f8b59-042b-4e1e-8c03-345bb8c30851 --- src/net/java/games/jogl/util/BufferUtils.java | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/net/java/games/jogl/util') diff --git a/src/net/java/games/jogl/util/BufferUtils.java b/src/net/java/games/jogl/util/BufferUtils.java index 88afa1c8f..1572b749b 100644 --- a/src/net/java/games/jogl/util/BufferUtils.java +++ b/src/net/java/games/jogl/util/BufferUtils.java @@ -45,9 +45,15 @@ import java.util.*; /** Utility routines for dealing with direct buffers. */ public class BufferUtils { + public static final int SIZEOF_DOUBLE = 8; public static final int SIZEOF_FLOAT = 4; public static final int SIZEOF_INT = 4; + public static DoubleBuffer newDoubleBuffer(int numElements) { + ByteBuffer bb = newByteBuffer(numElements * SIZEOF_DOUBLE); + return bb.asDoubleBuffer(); + } + public static FloatBuffer newFloatBuffer(int numElements) { ByteBuffer bb = newByteBuffer(numElements * SIZEOF_FLOAT); return bb.asFloatBuffer(); @@ -64,6 +70,13 @@ public class BufferUtils { return bb; } + public static DoubleBuffer copyDoubleBuffer(DoubleBuffer orig) { + DoubleBuffer dest = newDoubleBuffer(orig.capacity()); + orig.rewind(); + dest.put(orig); + return dest; + } + public static FloatBuffer copyFloatBuffer(FloatBuffer orig) { FloatBuffer dest = newFloatBuffer(orig.capacity()); orig.rewind(); @@ -71,6 +84,20 @@ public class BufferUtils { return dest; } + public static IntBuffer copyIntBuffer(IntBuffer orig) { + IntBuffer dest = newIntBuffer(orig.capacity()); + orig.rewind(); + dest.put(orig); + return dest; + } + + public static ByteBuffer copyByteBuffer(ByteBuffer orig) { + ByteBuffer dest = newByteBuffer(orig.capacity()); + orig.rewind(); + dest.put(orig); + return dest; + } + private static Map bufferOffsetCache = Collections.synchronizedMap(new HashMap()); /** Creates an "offset buffer" for use with the -- cgit v1.2.3