The buffer binding state is local to it's OpenGL context, i.e. not shared across multiple OpenGL context. Hence this code is thread safe due to no multithreading usage.
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.
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.
| Modifier and Type | Field and Description |
|---|---|
| private final IntIntHashMap | |
| private static final int | |
| private final int[] | |
| protected static final boolean |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private static final void | |
| public final void | |
| public final int | getBoundBufferObject(final int target, final GL caller)
Note returns an unspecified value if the binding for the specified target (e.g. GL_ARRAY_BUFFER) is currently unknown. |
| private static final int | getQueryName(final int target)
GL_ARRAY_BUFFER, GL_ATOMIC_COUNTER_BUFFER, GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, GL_DRAW_INDIRECT_BUFFER, GL_DISPATCH_INDIRECT_BUFFER, GL_ELEMENT_ARRAY_BUFFER, GL_PIXEL_PACK_BUFFER, GL_PIXEL_UNPACK_BUFFER, GL_SHADER_STORAGE_BUFFER, GL_TEXTURE_BUFFER, GL_TRANSFORM_FEEDBACK_BUFFER or GL_UNIFORM_BUFFER. |
| public final void | setBoundBufferObject(final int target, final int bufferName)
Must be called when binding a buffer, e.g.:
|
| private final String |
| bindingMap | back to summary |
|---|---|
| private final IntIntHashMap bindingMap | |
| bindingNotFound | back to summary |
|---|---|
| private static final int bindingNotFound | |
| bufTmp | back to summary |
|---|---|
| private final int[] bufTmp | |
| DEBUG | back to summary |
|---|---|
| protected static final boolean DEBUG | |
| GLBufferStateTracker | back to summary |
|---|---|
| public GLBufferStateTracker() | |
| checkTargetName | back to summary |
|---|---|
| private static final void checkTargetName(final int target) | |
| clear | back to summary |
|---|---|
| public final void clear() 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. | |
| getBoundBufferObject | back to summary |
|---|---|
| public final int getBoundBufferObject(final int target, final 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. | |
| getQueryName | back to summary |
|---|---|
| private static final int getQueryName(final int target) GL_ARRAY_BUFFER, GL_ATOMIC_COUNTER_BUFFER, GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, GL_DRAW_INDIRECT_BUFFER, GL_DISPATCH_INDIRECT_BUFFER, GL_ELEMENT_ARRAY_BUFFER, GL_PIXEL_PACK_BUFFER, GL_PIXEL_UNPACK_BUFFER, GL_SHADER_STORAGE_BUFFER, GL_TEXTURE_BUFFER, GL_TRANSFORM_FEEDBACK_BUFFER or GL_UNIFORM_BUFFER. GL_VERTEX_ARRAY_BINDING | |
| setBoundBufferObject | back to summary |
|---|---|
| public final void setBoundBufferObject(final int target, final int bufferName) Must be called when binding a buffer, e.g.:
| |
| toHexString | back to summary |
|---|---|
| private final String toHexString(final int i) | |