com.sun.opengl.impl
Class GLBufferStateTracker

java.lang.Object
  extended by com.sun.opengl.impl.GLBufferStateTracker

public class GLBufferStateTracker
extends java.lang.Object

Tracks as closely as possible which OpenGL buffer object is bound to which binding target in the current OpenGL context. GLBufferStateTracker objects are allocated on a per-GLImpl basis, which is basically identical to a per-OpenGL-context basis (assuming correct usage of the GLImpl objects, which is checked by the DebugGL). This class is used to verify that e.g. the vertex buffer object extension is in use when the glVertexPointer variant taking a long as argument is called.

Note that because the enumerated value used for the binding of a buffer object (e.g. GL_ARRAY_BUFFER) is different than that used to query the binding using glGetIntegerv (e.g. GL_ARRAY_BUFFER_BINDING), then in the face of new binding targets being added to the GL (e.g. GL_TRANSFORM_FEEDBACK_BUFFER_NV) it is impossible to set up a query of the buffer object currently bound to a particular state. It turns out that for some uses, such as finding the size of the currently bound buffer, this doesn't matter, though of course without knowing the buffer object we can't re-associate the queried size with the buffer object ID.

Because the namespace of buffer objects is the unsigned integers with 0 reserved by the GL, and because we have to be able to return both 0 and other integers as valid answers from getBoundBufferObject(), we need a second query, which is to ask whether we know the state of the binding for a given target. For "unknown" targets such as GL_TRANSFORM_FEEDBACK_BUFFER_NV we return false from this, but we also clear the valid bit and later refresh the binding state if glPushClientAttrib / glPopClientAttrib are called, since we don't want the complexity of tracking stacks of these attributes.


Constructor Summary
GLBufferStateTracker()
           
 
Method Summary
 void clearBufferObjectState()
          Clears out the known/unknown state of the various buffer object binding states.
 int getBoundBufferObject(int target, GL caller)
          Note: returns an unspecified value if the binding for the specified target (e.g.
 boolean isBoundBufferObjectKnown(int target)
          Indicates whether the binding state for the specified target is currently known.
 void setBoundBufferObject(int target, int buffer)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GLBufferStateTracker

public GLBufferStateTracker()
Method Detail

setBoundBufferObject

public void setBoundBufferObject(int target,
                                 int buffer)

getBoundBufferObject

public int getBoundBufferObject(int target,
                                GL caller)
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.


isBoundBufferObjectKnown

public boolean isBoundBufferObjectKnown(int target)
Indicates whether the binding state for the specified target is currently known. Should be called after getBoundBufferObject() because that method may change the answer for a given target.


clearBufferObjectState

public void clearBufferObjectState()
Clears out the known/unknown state of the various buffer object binding states. These will be refreshed later on an as-needed basis. This is called by the implementations of glPushClientAttrib / glPopClientAttrib. Might want to call this from GLContext.makeCurrent() in the future to possibly increase the robustness of these caches in the face of external native code manipulating OpenGL state.



Copyright 2005 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.