Top Description Fields Constructors Methods
jogamp.opengl

public Class GLBufferStateTracker

extends Object
Class Inheritance
Imports
com.jogamp.opengl.*, com.jogamp.common.util.IntIntHashMap, .PropertyAccess

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-OpenGL-context basis. 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.

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.

Field Summary

Modifier and TypeField and Description
private final IntIntHashMap
private static final int
private final int[]
protected static final boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static final void
checkTargetName(final int target)

public final void
clear()

Clears out the known/unknown state of the various buffer object binding states.

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.:

  • glBindBuffer
  • glBindBufferBase
  • glBindBufferRange
private final String
toHexString(final int i)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bindingMapback to summary
private final IntIntHashMap bindingMap
bindingNotFoundback to summary
private static final int bindingNotFound
bufTmpback to summary
private final int[] bufTmp
DEBUGback to summary
protected static final boolean DEBUG

Constructor Detail

GLBufferStateTrackerback to summary
public GLBufferStateTracker()

Method Detail

checkTargetNameback to summary
private static final void checkTargetName(final int target)
clearback 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.

getBoundBufferObjectback 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.

getQueryNameback 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

setBoundBufferObjectback to summary
public final void setBoundBufferObject(final int target, final int bufferName)

Must be called when binding a buffer, e.g.:

  • glBindBuffer
  • glBindBufferBase
  • glBindBufferRange
toHexStringback to summary
private final String toHexString(final int i)