summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java')
-rw-r--r--src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java44
1 files changed, 32 insertions, 12 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java b/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java
index 5a31431d8..c7e27da2a 100644
--- a/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java
+++ b/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java
@@ -40,6 +40,8 @@
package jogamp.opengl;
+import java.util.HashMap;
+
import javax.media.opengl.*;
import com.jogamp.common.util.IntIntHashMap;
@@ -89,26 +91,32 @@ public class GLBufferStateTracker {
public GLBufferStateTracker() {
bindingMap = new IntIntHashMap();
- bindingMap.setKeyNotFoundValue(-1);
+ bindingMap.setKeyNotFoundValue(0xFFFFFFFF);
// Start with known unbound targets for known keys
- bindingMap.put(GL.GL_ARRAY_BUFFER, 0);
- bindingMap.put(GL.GL_ELEMENT_ARRAY_BUFFER, 0);
- bindingMap.put(GL2.GL_PIXEL_PACK_BUFFER, 0);
- bindingMap.put(GL2.GL_PIXEL_UNPACK_BUFFER, 0);
+ setBoundBufferObject(GL.GL_ARRAY_BUFFER, 0);
+ setBoundBufferObject(GL.GL_ELEMENT_ARRAY_BUFFER, 0);
+ setBoundBufferObject(GL2.GL_PIXEL_PACK_BUFFER, 0);
+ setBoundBufferObject(GL2.GL_PIXEL_UNPACK_BUFFER, 0);
}
- public void setBoundBufferObject(int target, int buffer) {
+ public final void setBoundBufferObject(int target, int buffer) {
bindingMap.put(target, buffer);
+ if (DEBUG) {
+ System.err.println();
+ System.err.println("GLBufferStateTracker.setBoundBufferObject(): mapped bound buffer 0x" +
+ Integer.toHexString(buffer) + " for query target 0x" + Integer.toHexString(target));
+ Thread.dumpStack();
+ }
}
/** Note: returns an unspecified value if the binding for the
specified target (e.g. GL_ARRAY_BUFFER) is currently unknown.
You must use isBoundBufferObjectKnown() to see whether the
return value is valid. */
- public int getBoundBufferObject(int target, GL caller) {
+ public final int getBoundBufferObject(int target, GL caller) {
int value = bindingMap.get(target);
- if (0 > value) {
+ if (0xFFFFFFFF == value) {
// User probably either called glPushClientAttrib /
// glPopClientAttrib or is querying an unknown target. See
// whether we know how to fetch this state.
@@ -124,15 +132,22 @@ public class GLBufferStateTracker {
if (gotQueryTarget) {
caller.glGetIntegerv(queryTarget, bufTmp, 0);
if (DEBUG) {
- System.err.println("GLBufferStateTracker.getBoundBufferObject(): queried bound buffer " +
- bufTmp[0] +
- " for query target 0x" + Integer.toHexString(queryTarget));
+ System.err.println();
+ System.err.println("GLBufferStateTracker.getBoundBufferObject(): queried bound buffer 0x" +
+ Integer.toHexString(bufTmp[0]) +
+ " for target 0x" + Integer.toHexString(target)+" / query 0x"+Integer.toHexString(queryTarget));
}
setBoundBufferObject(target, bufTmp[0]);
return bufTmp[0];
}
return 0;
}
+ if (DEBUG) {
+ System.err.println();
+ System.err.println("GLBufferStateTracker.getBoundBufferObject(): mapped bound buffer 0x" +
+ Integer.toHexString(value) + " for query target 0x" + Integer.toHexString(target));
+ Thread.dumpStack();
+ }
return value;
}
@@ -143,7 +158,12 @@ public class GLBufferStateTracker {
from GLContext.makeCurrent() in the future to possibly increase
the robustness of these caches in the face of external native
code manipulating OpenGL state. */
- public void clearBufferObjectState() {
+ public final void clearBufferObjectState() {
bindingMap.clear();
+ if (DEBUG) {
+ System.err.println();
+ System.err.println("GLBufferStateTracker.clearBufferObjectState()");
+ Thread.dumpStack();
+ }
}
}