public class ARBUniformBufferObject
extends java.lang.Object
This extension introduces the concept of a group of GLSL uniforms known as a "uniform block", and the API mechanisms to store "uniform blocks" in GL buffer objects.
The extension also defines both a standard cross-platform layout in memory for uniform block data, as well as mechanisms to allow the GL to optimize the data layout in an implementation-defined manner.
Prior to this extension, the existing interface for modification of uniform values allowed modification of large numbers of values using glUniform* calls, but only for a single uniform name (or a uniform array) at a time. However, updating uniforms in this manner may not map well to heterogenous uniform data structures defined for a GL application and in these cases, the application is forced to either:
These solutions have their disadvantages. Solution A imposes considerable development overhead on the application developer. Solution B may impose considerable run-time overhead on the application if the number of uniforms modified in a given frame of rendering is sufficiently large.
This extension provides a better alternative to either (A) or (B) by allowing buffer object backing for the storage associated with all uniforms of a given GLSL program.
Storing uniform blocks in buffer objects enables several key use cases:
The data storage for a uniform block can be declared to use one of three layouts in memory: packed, shared, or std140.
Any uniforms not declared in a named uniform block are said to be part of the "default uniform block".
While uniforms in the default uniform block are updated with glUniform* entry points and can have static initializers, uniforms in named uniform blocks are not. Instead, uniform block data is updated using the routines that update buffer objects and can not use static initializers.
Rules and Concepts Guiding this Specification:
For reference, a uniform has a "uniform index" (subsequently referred to as "u_index) and also a "uniform location" to efficiently identify it in the uniform data store of the implementation. We subsequently refer to this uniform data store of the implementation as the "uniform database".
A "uniform block" only has a "uniform block index" used for queries and connecting the "uniform block" to a buffer object. A "uniform block" has no "location" because "uniform blocks" are not updated directly. The buffer object APIs are used instead.
Properties of Uniforms and uniform blocks:
INVALID_INDEX.INVALID_INDEX.INVALID_INDEX generates the INVALID_VALUE error if given as a function argument.Requires OpenGL 2.0 or ARB_shader_objects and OpenGL 1.5 or ARB_vertex_buffer_object. Promoted to core in OpenGL 3.1.
| Modifier and Type | Field and Description |
|---|---|
static int |
GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH
Accepted by the
pname parameter of GetProgramiv. |
static int |
GL_ACTIVE_UNIFORM_BLOCKS
Accepted by the
pname parameter of GetProgramiv. |
static int |
GL_INVALID_INDEX
Returned by GetActiveUniformsiv and GetUniformBlockIndex.
|
static int |
GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS
Accepted by the
pname parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev. |
static int |
GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS
Accepted by the
pname parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev. |
static int |
GL_MAX_COMBINED_UNIFORM_BLOCKS
Accepted by the
pname parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev. |
static int |
GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS
Accepted by the
pname parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev. |
static int |
GL_MAX_FRAGMENT_UNIFORM_BLOCKS
Accepted by the
pname parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev. |
static int |
GL_MAX_GEOMETRY_UNIFORM_BLOCKS
Accepted by the
pname parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev. |
static int |
GL_MAX_UNIFORM_BLOCK_SIZE
Accepted by the
pname parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev. |
static int |
GL_MAX_UNIFORM_BUFFER_BINDINGS
Accepted by the
pname parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev. |
static int |
GL_MAX_VERTEX_UNIFORM_BLOCKS
Accepted by the
pname parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev. |
static int |
GL_UNIFORM_ARRAY_STRIDE
Accepted by the
pname parameter of GetActiveUniformsiv. |
static int |
GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES
Accepted by the
pname parameter of GetActiveUniformBlockiv. |
static int |
GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS
Accepted by the
pname parameter of GetActiveUniformBlockiv. |
static int |
GL_UNIFORM_BLOCK_BINDING
Accepted by the
pname parameter of GetActiveUniformBlockiv. |
static int |
GL_UNIFORM_BLOCK_DATA_SIZE
Accepted by the
pname parameter of GetActiveUniformBlockiv. |
static int |
GL_UNIFORM_BLOCK_INDEX
Accepted by the
pname parameter of GetActiveUniformsiv. |
static int |
GL_UNIFORM_BLOCK_NAME_LENGTH
Accepted by the
pname parameter of GetActiveUniformBlockiv. |
static int |
GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER
Accepted by the
pname parameter of GetActiveUniformBlockiv. |
static int |
GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER
Accepted by the
pname parameter of GetActiveUniformBlockiv. |
static int |
GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER
Accepted by the
pname parameter of GetActiveUniformBlockiv. |
static int |
GL_UNIFORM_BUFFER
Accepted by the
target parameters of BindBuffer, BufferData, BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData, and GetBufferPointerv. |
static int |
GL_UNIFORM_BUFFER_BINDING
Accepted by the
pname parameter of GetIntegeri_v, GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev. |
static int |
GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT
Accepted by the
pname parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev. |
static int |
GL_UNIFORM_BUFFER_SIZE
Accepted by the
pname parameter of GetIntegeri_v. |
static int |
GL_UNIFORM_BUFFER_START
Accepted by the
pname parameter of GetIntegeri_v. |
static int |
GL_UNIFORM_IS_ROW_MAJOR
Accepted by the
pname parameter of GetActiveUniformsiv. |
static int |
GL_UNIFORM_MATRIX_STRIDE
Accepted by the
pname parameter of GetActiveUniformsiv. |
static int |
GL_UNIFORM_NAME_LENGTH
Accepted by the
pname parameter of GetActiveUniformsiv. |
static int |
GL_UNIFORM_OFFSET
Accepted by the
pname parameter of GetActiveUniformsiv. |
static int |
GL_UNIFORM_SIZE
Accepted by the
pname parameter of GetActiveUniformsiv. |
static int |
GL_UNIFORM_TYPE
Accepted by the
pname parameter of GetActiveUniformsiv. |
| Modifier and Type | Method and Description |
|---|---|
static void |
glBindBufferBase(int target,
int index,
int buffer)
Binds a buffer object to an indexed buffer target.
|
static void |
glBindBufferRange(int target,
int index,
int buffer,
long offset,
long size)
Binds a range within a buffer object to an indexed buffer target.
|
static int |
glGetActiveUniformBlocki(int program,
int uniformBlockIndex,
int pname)
Queries information about an active uniform block.
|
static void |
glGetActiveUniformBlockiv(int program,
int uniformBlockIndex,
int pname,
int[] params)
Array version of:
GetActiveUniformBlockiv |
static void |
glGetActiveUniformBlockiv(int program,
int uniformBlockIndex,
int pname,
java.nio.IntBuffer params)
Queries information about an active uniform block.
|
static java.lang.String |
glGetActiveUniformBlockName(int program,
int uniformBlockIndex)
Retrieves the name of an active uniform block.
|
static java.lang.String |
glGetActiveUniformBlockName(int program,
int uniformBlockIndex,
int bufSize)
Retrieves the name of an active uniform block.
|
static void |
glGetActiveUniformBlockName(int program,
int uniformBlockIndex,
int[] length,
java.nio.ByteBuffer uniformBlockName)
Array version of:
GetActiveUniformBlockName |
static void |
glGetActiveUniformBlockName(int program,
int uniformBlockIndex,
java.nio.IntBuffer length,
java.nio.ByteBuffer uniformBlockName)
Retrieves the name of an active uniform block.
|
static java.lang.String |
glGetActiveUniformName(int program,
int uniformIndex)
Queries the name of an active uniform.
|
static java.lang.String |
glGetActiveUniformName(int program,
int uniformIndex,
int bufSize)
Queries the name of an active uniform.
|
static void |
glGetActiveUniformName(int program,
int uniformIndex,
int[] length,
java.nio.ByteBuffer uniformName)
Array version of:
GetActiveUniformName |
static void |
glGetActiveUniformName(int program,
int uniformIndex,
java.nio.IntBuffer length,
java.nio.ByteBuffer uniformName)
Queries the name of an active uniform.
|
static int |
glGetActiveUniformsi(int program,
int uniformIndex,
int pname)
Returns information about several active uniform variables for the specified program object.
|
static void |
glGetActiveUniformsiv(int program,
int[] uniformIndices,
int pname,
int[] params)
Array version of:
GetActiveUniformsiv |
static void |
glGetActiveUniformsiv(int program,
java.nio.IntBuffer uniformIndices,
int pname,
java.nio.IntBuffer params)
Returns information about several active uniform variables for the specified program object.
|
static void |
glGetIntegeri_v(int target,
int index,
int[] data)
Array version of:
GetIntegeri_v |
static void |
glGetIntegeri_v(int target,
int index,
java.nio.IntBuffer data)
Queries the integer value of an indexed state variable.
|
static int |
glGetIntegeri(int target,
int index)
Queries the integer value of an indexed state variable.
|
static int |
glGetUniformBlockIndex(int program,
java.nio.ByteBuffer uniformBlockName)
Retrieves the index of a named uniform block.
|
static int |
glGetUniformBlockIndex(int program,
java.lang.CharSequence uniformBlockName)
Retrieves the index of a named uniform block.
|
static int |
glGetUniformIndices(int program,
java.lang.CharSequence uniformName)
Retrieves the indices of a number of uniforms within a program object
|
static void |
glGetUniformIndices(int program,
java.lang.CharSequence[] uniformNames,
java.nio.IntBuffer uniformIndices)
Retrieves the indices of a number of uniforms within a program object
|
static void |
glGetUniformIndices(int program,
org.lwjgl.PointerBuffer uniformNames,
int[] uniformIndices)
Array version of:
GetUniformIndices |
static void |
glGetUniformIndices(int program,
org.lwjgl.PointerBuffer uniformNames,
java.nio.IntBuffer uniformIndices)
Retrieves the indices of a number of uniforms within a program object
|
static void |
glUniformBlockBinding(int program,
int uniformBlockIndex,
int uniformBlockBinding)
Assigns a binding point to an active uniform block.
|
static void |
nglGetActiveUniformBlockiv(int program,
int uniformBlockIndex,
int pname,
long params)
Unsafe version of:
GetActiveUniformBlockiv |
static void |
nglGetActiveUniformBlockName(int program,
int uniformBlockIndex,
int bufSize,
long length,
long uniformBlockName)
Unsafe version of:
GetActiveUniformBlockName |
static void |
nglGetActiveUniformName(int program,
int uniformIndex,
int bufSize,
long length,
long uniformName)
Unsafe version of:
GetActiveUniformName |
static void |
nglGetActiveUniformsiv(int program,
int uniformCount,
long uniformIndices,
int pname,
long params)
Unsafe version of:
GetActiveUniformsiv |
static void |
nglGetIntegeri_v(int target,
int index,
long data)
Unsafe version of:
GetIntegeri_v |
static int |
nglGetUniformBlockIndex(int program,
long uniformBlockName)
Unsafe version of:
GetUniformBlockIndex |
static void |
nglGetUniformIndices(int program,
int uniformCount,
long uniformNames,
long uniformIndices)
Unsafe version of:
GetUniformIndices |
public static final int GL_UNIFORM_BUFFER
target parameters of BindBuffer, BufferData, BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData, and GetBufferPointerv.public static final int GL_UNIFORM_BUFFER_BINDING
pname parameter of GetIntegeri_v, GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev.public static final int GL_UNIFORM_BUFFER_START
pname parameter of GetIntegeri_v.public static final int GL_UNIFORM_BUFFER_SIZE
pname parameter of GetIntegeri_v.public static final int GL_MAX_VERTEX_UNIFORM_BLOCKS
pname parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev.public static final int GL_MAX_GEOMETRY_UNIFORM_BLOCKS
pname parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev.public static final int GL_MAX_FRAGMENT_UNIFORM_BLOCKS
pname parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev.public static final int GL_MAX_COMBINED_UNIFORM_BLOCKS
pname parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev.public static final int GL_MAX_UNIFORM_BUFFER_BINDINGS
pname parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev.public static final int GL_MAX_UNIFORM_BLOCK_SIZE
pname parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev.public static final int GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS
pname parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev.public static final int GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS
pname parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev.public static final int GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS
pname parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev.public static final int GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT
pname parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev.public static final int GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH
pname parameter of GetProgramiv.public static final int GL_ACTIVE_UNIFORM_BLOCKS
pname parameter of GetProgramiv.public static final int GL_UNIFORM_TYPE
pname parameter of GetActiveUniformsiv.public static final int GL_UNIFORM_SIZE
pname parameter of GetActiveUniformsiv.public static final int GL_UNIFORM_NAME_LENGTH
pname parameter of GetActiveUniformsiv.public static final int GL_UNIFORM_BLOCK_INDEX
pname parameter of GetActiveUniformsiv.public static final int GL_UNIFORM_OFFSET
pname parameter of GetActiveUniformsiv.public static final int GL_UNIFORM_ARRAY_STRIDE
pname parameter of GetActiveUniformsiv.public static final int GL_UNIFORM_MATRIX_STRIDE
pname parameter of GetActiveUniformsiv.public static final int GL_UNIFORM_IS_ROW_MAJOR
pname parameter of GetActiveUniformsiv.public static final int GL_UNIFORM_BLOCK_BINDING
pname parameter of GetActiveUniformBlockiv.public static final int GL_UNIFORM_BLOCK_DATA_SIZE
pname parameter of GetActiveUniformBlockiv.public static final int GL_UNIFORM_BLOCK_NAME_LENGTH
pname parameter of GetActiveUniformBlockiv.public static final int GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS
pname parameter of GetActiveUniformBlockiv.public static final int GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES
pname parameter of GetActiveUniformBlockiv.public static final int GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER
pname parameter of GetActiveUniformBlockiv.public static final int GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER
pname parameter of GetActiveUniformBlockiv.public static final int GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER
pname parameter of GetActiveUniformBlockiv.public static final int GL_INVALID_INDEX
public static void nglGetUniformIndices(int program,
int uniformCount,
long uniformNames,
long uniformIndices)
GetUniformIndicesuniformCount - the number of uniforms whose indices to querypublic static void glGetUniformIndices(int program,
org.lwjgl.PointerBuffer uniformNames,
java.nio.IntBuffer uniformIndices)
program - the name of a program containing uniforms whose indices to queryuniformNames - an array of pointers to buffers containing the names of the queried uniformsuniformIndices - an array that will receive the indices of the uniformspublic static void glGetUniformIndices(int program,
java.lang.CharSequence[] uniformNames,
java.nio.IntBuffer uniformIndices)
program - the name of a program containing uniforms whose indices to queryuniformNames - an array of pointers to buffers containing the names of the queried uniformsuniformIndices - an array that will receive the indices of the uniformspublic static int glGetUniformIndices(int program,
java.lang.CharSequence uniformName)
program - the name of a program containing uniforms whose indices to querypublic static void nglGetActiveUniformsiv(int program,
int uniformCount,
long uniformIndices,
int pname,
long params)
GetActiveUniformsivuniformCount - the number of elements in the array of indices uniformIndices and the number of parameters written to params upon successful returnpublic static void glGetActiveUniformsiv(int program,
java.nio.IntBuffer uniformIndices,
int pname,
java.nio.IntBuffer params)
program - the program object to be querieduniformIndices - an array of uniformCount integers containing the indices of uniforms within programpname - the property of the each uniform in uniformIndices that should be written into the corresponding element of paramsparams - an array of uniformCount integers which are to receive the value of pname for each uniform in uniformIndicespublic static int glGetActiveUniformsi(int program,
int uniformIndex,
int pname)
program - the program object to be queriedpname - the property of the each uniform in uniformIndices that should be written into the corresponding element of paramspublic static void nglGetActiveUniformName(int program,
int uniformIndex,
int bufSize,
long length,
long uniformName)
GetActiveUniformNamebufSize - the size of the buffer, in units of GLchar, of the buffer whose address is specified in uniformNamepublic static void glGetActiveUniformName(int program,
int uniformIndex,
@Nullable
java.nio.IntBuffer length,
java.nio.ByteBuffer uniformName)
program - the program containing the active uniform index uniformIndexuniformIndex - the index of the active uniform whose name to querylength - the address of a variable that will receive the number of characters that were or would have been written to the buffer addressed by uniformNameuniformName - the address of a buffer into which the GL will place the name of the active uniform at uniformIndex within programpublic static java.lang.String glGetActiveUniformName(int program,
int uniformIndex,
int bufSize)
program - the program containing the active uniform index uniformIndexuniformIndex - the index of the active uniform whose name to querybufSize - the size of the buffer, in units of GLchar, of the buffer whose address is specified in uniformNamepublic static java.lang.String glGetActiveUniformName(int program,
int uniformIndex)
program - the program containing the active uniform index uniformIndexuniformIndex - the index of the active uniform whose name to querypublic static int nglGetUniformBlockIndex(int program,
long uniformBlockName)
GetUniformBlockIndexpublic static int glGetUniformBlockIndex(int program,
java.nio.ByteBuffer uniformBlockName)
program - the name of a program containing the uniform blockuniformBlockName - an array of characters to containing the name of the uniform block whose index to retrievepublic static int glGetUniformBlockIndex(int program,
java.lang.CharSequence uniformBlockName)
program - the name of a program containing the uniform blockuniformBlockName - an array of characters to containing the name of the uniform block whose index to retrievepublic static void nglGetActiveUniformBlockiv(int program,
int uniformBlockIndex,
int pname,
long params)
GetActiveUniformBlockivpublic static void glGetActiveUniformBlockiv(int program,
int uniformBlockIndex,
int pname,
java.nio.IntBuffer params)
program - the name of a program containing the uniform blockuniformBlockIndex - the index of the uniform block within programpname - the name of the parameter to query. One of:params - the address of a variable to receive the result of the querypublic static int glGetActiveUniformBlocki(int program,
int uniformBlockIndex,
int pname)
program - the name of a program containing the uniform blockuniformBlockIndex - the index of the uniform block within programpname - the name of the parameter to query. One of:public static void nglGetActiveUniformBlockName(int program,
int uniformBlockIndex,
int bufSize,
long length,
long uniformBlockName)
GetActiveUniformBlockNamebufSize - the size of the buffer addressed by uniformBlockNamepublic static void glGetActiveUniformBlockName(int program,
int uniformBlockIndex,
@Nullable
java.nio.IntBuffer length,
java.nio.ByteBuffer uniformBlockName)
program - the name of a program containing the uniform blockuniformBlockIndex - the index of the uniform block within programlength - the address of a variable to receive the number of characters that were written to uniformBlockNameuniformBlockName - an array of characters to receive the name of the uniform block at uniformBlockIndexpublic static java.lang.String glGetActiveUniformBlockName(int program,
int uniformBlockIndex,
int bufSize)
program - the name of a program containing the uniform blockuniformBlockIndex - the index of the uniform block within programbufSize - the size of the buffer addressed by uniformBlockNamepublic static java.lang.String glGetActiveUniformBlockName(int program,
int uniformBlockIndex)
program - the name of a program containing the uniform blockuniformBlockIndex - the index of the uniform block within programpublic static void glBindBufferRange(int target,
int index,
int buffer,
long offset,
long size)
target - the target of the bind operation. One of:TRANSFORM_FEEDBACK_BUFFER | UNIFORM_BUFFER | ATOMIC_COUNTER_BUFFER | SHADER_STORAGE_BUFFER |
index - the index of the binding point within the array specified by targetbuffer - a buffer object to bind to the specified binding pointoffset - the starting offset in basic machine units into the buffer object buffersize - the amount of data in machine units that can be read from the buffer object while used as an indexed targetpublic static void glBindBufferBase(int target,
int index,
int buffer)
target - the target of the bind operation. One of:TRANSFORM_FEEDBACK_BUFFER | UNIFORM_BUFFER | ATOMIC_COUNTER_BUFFER | SHADER_STORAGE_BUFFER |
index - the index of the binding point within the array specified by targetbuffer - a buffer object to bind to the specified binding pointpublic static void nglGetIntegeri_v(int target,
int index,
long data)
GetIntegeri_vpublic static void glGetIntegeri_v(int target,
int index,
java.nio.IntBuffer data)
target - the indexed state to queryindex - the index of the element being querieddata - a scalar or buffer in which to place the returned datapublic static int glGetIntegeri(int target,
int index)
target - the indexed state to queryindex - the index of the element being queriedpublic static void glUniformBlockBinding(int program,
int uniformBlockIndex,
int uniformBlockBinding)
program - the name of a program object containing the active uniform block whose binding to assignuniformBlockIndex - the index of the active uniform block within program whose binding to assignuniformBlockBinding - the binding point to which to bind the uniform block with index uniformBlockIndex within programpublic static void glGetUniformIndices(int program,
org.lwjgl.PointerBuffer uniformNames,
int[] uniformIndices)
GetUniformIndicespublic static void glGetActiveUniformsiv(int program,
int[] uniformIndices,
int pname,
int[] params)
GetActiveUniformsivpublic static void glGetActiveUniformName(int program,
int uniformIndex,
@Nullable
int[] length,
java.nio.ByteBuffer uniformName)
GetActiveUniformNamepublic static void glGetActiveUniformBlockiv(int program,
int uniformBlockIndex,
int pname,
int[] params)
GetActiveUniformBlockivpublic static void glGetActiveUniformBlockName(int program,
int uniformBlockIndex,
@Nullable
int[] length,
java.nio.ByteBuffer uniformBlockName)
GetActiveUniformBlockNamepublic static void glGetIntegeri_v(int target,
int index,
int[] data)
GetIntegeri_vCopyright LWJGL. All Rights Reserved. License terms.