aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-08-01 15:14:39 +0200
committerSven Gothel <[email protected]>2011-08-01 15:14:39 +0200
commit2dbd16fc3edf29b39ba37a11b9fbf1b2aad75c45 (patch)
tree70367f094a969e9387b506cef79ee846b0bd6d3b /src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java
parent0f0f6162cfbce1ad7db86e7e627721c4c918933c (diff)
StateTracker: Map's KeyNotFound value -1 -> 0xffffffff... allowing unusual values. Impl -> final.
Map's KeyNotFound value -1 -> 0xffffffff Turns out some GL impl. use VBO names like 0xa2d67443, which is (int) < 0. This is now handled in GLBufferStateTracker as well as for the others. Make methods final to restrict 'em.
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();
+ }
}
}