summaryrefslogtreecommitdiffstats
path: root/src/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/net')
-rw-r--r--src/net/java/games/jogl/impl/GLContext.java10
-rw-r--r--src/net/java/games/jogl/util/BufferUtils.java27
2 files changed, 31 insertions, 6 deletions
diff --git a/src/net/java/games/jogl/impl/GLContext.java b/src/net/java/games/jogl/impl/GLContext.java
index 443d009dc..2aa8e9640 100644
--- a/src/net/java/games/jogl/impl/GLContext.java
+++ b/src/net/java/games/jogl/impl/GLContext.java
@@ -67,13 +67,9 @@ public abstract class GLContext {
protected GLCapabilities capabilities;
protected GLCapabilitiesChooser chooser;
protected GL gl;
- // All GLU interfaces eventually route calls down to gluRoot. It can be
- // static because GLU it doesn't actually need to own context, it just makes
- // GL calls and assumes some context is active.
protected static final GLUProcAddressTable gluProcAddressTable = new GLUProcAddressTable();
- protected static final GLU gluRoot = new GLUImpl(gluProcAddressTable);
protected static boolean haveResetGLUProcAddressTable;
- protected GLU glu = gluRoot; // this is the context's GLU interface
+ protected GLU glu = new GLUImpl(gluProcAddressTable);
protected Thread renderingThread;
protected Runnable deferredReshapeAction;
// Support for OpenGL context destruction and recreation in the face
@@ -155,7 +151,7 @@ public abstract class GLContext {
throw new GLException(e);
}
this.chooser = chooser;
- gl = createGL();
+ setGL(createGL());
functionAvailability = new FunctionAvailabilityCache(this);
if (shareWith != null) {
GLContextShareSet.registerSharing(this, shareWith);
@@ -374,6 +370,8 @@ public abstract class GLContext {
public void setGL(GL gl) {
this.gl = gl;
+ // Also reset the GL object for the pure-Java GLU implementation
+ ((GLUImpl) glu).setGL(gl);
}
public GLU getGLU() {
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