Class ARBVertexBufferObject
- java.lang.Object
-
- org.lwjgl.opengl.ARBVertexBufferObject
-
public class ARBVertexBufferObject extends java.lang.Object
Native bindings to the ARB_vertex_buffer_object extension.This extension defines an interface that allows various types of data (especially vertex array data) to be cached in high-performance graphics memory on the server, thereby increasing the rate of data transfers.
Chunks of data are encapsulated within "buffer objects", which conceptually are nothing more than arrays of bytes, just like any chunk of memory. An API is provided whereby applications can read from or write to buffers, either via the GL itself (
BufferDataARB
,BufferSubDataARB
,GetBufferSubDataARB
) or via a pointer to the memory.The latter technique is known as "mapping" a buffer. When an application maps a buffer, it is given a pointer to the memory. When the application finishes reading from or writing to the memory, it is required to "unmap" the buffer before it is once again permitted to use that buffer as a GL data source or sink. Mapping often allows applications to eliminate an extra data copy otherwise required to access the buffer, thereby enhancing performance. In addition, requiring that applications unmap the buffer to use it as a data source or sink ensures that certain classes of latent synchronization bugs cannot occur.
Although this extension only defines hooks for buffer objects to be used with OpenGL's vertex array APIs, the API defined in this extension permits buffer objects to be used as either data sources or sinks for any GL command that takes a pointer as an argument. Normally, in the absence of this extension, a pointer passed into the GL is simply a pointer to the user's data. This extension defines a mechanism whereby this pointer is used not as a pointer to the data itself, but as an offset into a currently bound buffer object. The buffer object ID zero is reserved, and when buffer object zero is bound to a given target, the commands affected by that buffer binding behave normally. When a nonzero buffer ID is bound, then the pointer represents an offset.
In the case of vertex arrays, this extension defines not merely one binding for all attributes, but a separate binding for each individual attribute. As a result, applications can source their attributes from multiple buffers. An application might, for example, have a model with constant texture coordinates and variable geometry. The texture coordinates might be retrieved from a buffer object with the usage mode "STATIC_DRAW", indicating to the GL that the application does not expect to update the contents of the buffer frequently or even at all, while the vertices might be retrieved from a buffer object with the usage mode "STREAM_DRAW", indicating that the vertices will be updated on a regular basis.
In addition, a binding is defined by which applications can source index data (as used by
DrawElements
,DrawRangeElements
, andMultiDrawElements
) from a buffer object. On some platforms, this enables very large models to be rendered with no more than a few small commands to the graphics device.It is expected that a future extension will allow sourcing pixel data from and writing pixel data to a buffer object.
Promoted to core in
OpenGL 1.5
.
-
-
Field Summary
Fields Modifier and Type Field and Description static int
GL_ARRAY_BUFFER_ARB
Accepted by thetarget
parameters of BindBufferARB, BufferDataARB, BufferSubDataARB, MapBufferARB, UnmapBufferARB, GetBufferSubDataARB, GetBufferParameterivARB, and GetBufferPointervARB.static int
GL_ARRAY_BUFFER_BINDING_ARB
Accepted by thepname
parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev.static int
GL_BUFFER_ACCESS_ARB
Accepted by thepname
parameter of GetBufferParameterivARB.static int
GL_BUFFER_MAP_POINTER_ARB
Accepted by thepname
parameter of GetBufferPointervARB.static int
GL_BUFFER_MAPPED_ARB
GL_BUFFER_SIZE_ARB
GL_BUFFER_USAGE_ARBAccepted by thepname
parameter of GetBufferParameterivARB.static int
GL_COLOR_ARRAY_BUFFER_BINDING_ARB
Accepted by thepname
parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev.static int
GL_DYNAMIC_COPY_ARB
GL_DYNAMIC_DRAW_ARB
GL_DYNAMIC_READ_ARBAccepted by theusage
parameter of BufferDataARB.static int
GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB
Accepted by thepname
parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev.static int
GL_ELEMENT_ARRAY_BUFFER_ARB
Accepted by thetarget
parameters of BindBufferARB, BufferDataARB, BufferSubDataARB, MapBufferARB, UnmapBufferARB, GetBufferSubDataARB, GetBufferParameterivARB, and GetBufferPointervARB.static int
GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB
GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB
GL_INDEX_ARRAY_BUFFER_BINDING_ARB
GL_NORMAL_ARRAY_BUFFER_BINDING_ARBAccepted by thepname
parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev.static int
GL_READ_ONLY_ARB
GL_READ_WRITE_ARBAccepted by theaccess
parameter of MapBufferARB.static int
GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB
Accepted by thepname
parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev.static int
GL_STATIC_COPY_ARB
GL_STATIC_DRAW_ARB
GL_STATIC_READ_ARB
GL_STREAM_COPY_ARB
GL_STREAM_DRAW_ARB
GL_STREAM_READ_ARBAccepted by theusage
parameter of BufferDataARB.static int
GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB
GL_VERTEX_ARRAY_BUFFER_BINDING_ARBAccepted by thepname
parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev.static int
GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB
Accepted by thepname
parameter of GetVertexAttribivARB.static int
GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB
Accepted by thepname
parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev.static int
GL_WRITE_ONLY_ARB
Accepted by theaccess
parameter of MapBufferARB.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static void
glBindBufferARB(int target, int buffer)
Binds a named buffer object.static void
glBufferDataARB(int target, java.nio.ByteBuffer data, int usage)
Creates and initializes a buffer object's data store.static void
glBufferDataARB(int target, double[] data, int usage)
Array version of:BufferDataARB
static void
glBufferDataARB(int target, java.nio.DoubleBuffer data, int usage)
Creates and initializes a buffer object's data store.static void
glBufferDataARB(int target, float[] data, int usage)
Array version of:BufferDataARB
static void
glBufferDataARB(int target, java.nio.FloatBuffer data, int usage)
Creates and initializes a buffer object's data store.static void
glBufferDataARB(int target, int[] data, int usage)
Array version of:BufferDataARB
static void
glBufferDataARB(int target, java.nio.IntBuffer data, int usage)
Creates and initializes a buffer object's data store.static void
glBufferDataARB(int target, long size, int usage)
Creates and initializes a buffer object's data store.static void
glBufferDataARB(int target, short[] data, int usage)
Array version of:BufferDataARB
static void
glBufferDataARB(int target, java.nio.ShortBuffer data, int usage)
Creates and initializes a buffer object's data store.static void
glBufferSubDataARB(int target, long offset, java.nio.ByteBuffer data)
Updates a subset of a buffer object's data store.static void
glBufferSubDataARB(int target, long offset, double[] data)
Array version of:BufferSubDataARB
static void
glBufferSubDataARB(int target, long offset, java.nio.DoubleBuffer data)
Updates a subset of a buffer object's data store.static void
glBufferSubDataARB(int target, long offset, float[] data)
Array version of:BufferSubDataARB
static void
glBufferSubDataARB(int target, long offset, java.nio.FloatBuffer data)
Updates a subset of a buffer object's data store.static void
glBufferSubDataARB(int target, long offset, int[] data)
Array version of:BufferSubDataARB
static void
glBufferSubDataARB(int target, long offset, java.nio.IntBuffer data)
Updates a subset of a buffer object's data store.static void
glBufferSubDataARB(int target, long offset, short[] data)
Array version of:BufferSubDataARB
static void
glBufferSubDataARB(int target, long offset, java.nio.ShortBuffer data)
Updates a subset of a buffer object's data store.static void
glDeleteBuffersARB(int buffer)
Deletes named buffer objects.static void
glDeleteBuffersARB(int[] buffers)
Array version of:DeleteBuffersARB
static void
glDeleteBuffersARB(java.nio.IntBuffer buffers)
Deletes named buffer objects.static int
glGenBuffersARB()
Generates buffer object names.static void
glGenBuffersARB(int[] buffers)
Array version of:GenBuffersARB
static void
glGenBuffersARB(java.nio.IntBuffer buffers)
Generates buffer object names.static int
glGetBufferParameteriARB(int target, int pname)
Returns the value of a buffer object parameter.static void
glGetBufferParameterivARB(int target, int pname, int[] params)
Array version of:GetBufferParameterivARB
static void
glGetBufferParameterivARB(int target, int pname, java.nio.IntBuffer params)
Returns the value of a buffer object parameter.static long
glGetBufferPointerARB(int target, int pname)
Returns the pointer to a mapped buffer object's data store.static void
glGetBufferPointervARB(int target, int pname, org.lwjgl.PointerBuffer params)
Returns the pointer to a mapped buffer object's data store.static void
glGetBufferSubDataARB(int target, long offset, java.nio.ByteBuffer data)
Returns a subset of a buffer object's data store.static void
glGetBufferSubDataARB(int target, long offset, double[] data)
Array version of:GetBufferSubDataARB
static void
glGetBufferSubDataARB(int target, long offset, java.nio.DoubleBuffer data)
Returns a subset of a buffer object's data store.static void
glGetBufferSubDataARB(int target, long offset, float[] data)
Array version of:GetBufferSubDataARB
static void
glGetBufferSubDataARB(int target, long offset, java.nio.FloatBuffer data)
Returns a subset of a buffer object's data store.static void
glGetBufferSubDataARB(int target, long offset, int[] data)
Array version of:GetBufferSubDataARB
static void
glGetBufferSubDataARB(int target, long offset, java.nio.IntBuffer data)
Returns a subset of a buffer object's data store.static void
glGetBufferSubDataARB(int target, long offset, short[] data)
Array version of:GetBufferSubDataARB
static void
glGetBufferSubDataARB(int target, long offset, java.nio.ShortBuffer data)
Returns a subset of a buffer object's data store.static boolean
glIsBufferARB(int buffer)
Determines if a name corresponds to a buffer object.static java.nio.ByteBuffer
glMapBufferARB(int target, int access)
Maps a buffer object's data store.static java.nio.ByteBuffer
glMapBufferARB(int target, int access, java.nio.ByteBuffer old_buffer)
Maps a buffer object's data store.static java.nio.ByteBuffer
glMapBufferARB(int target, int access, long length, java.nio.ByteBuffer old_buffer)
Maps a buffer object's data store.static boolean
glUnmapBufferARB(int target)
Relinquishes the mapping of a buffer object and invalidates the pointer to its data store.
-
-
-
Field Detail
-
GL_ARRAY_BUFFER_ARB, GL_ELEMENT_ARRAY_BUFFER_ARB
Accepted by thetarget
parameters of BindBufferARB, BufferDataARB, BufferSubDataARB, MapBufferARB, UnmapBufferARB, GetBufferSubDataARB, GetBufferParameterivARB, and GetBufferPointervARB.
-
GL_ARRAY_BUFFER_BINDING_ARB, GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, GL_VERTEX_ARRAY_BUFFER_BINDING_ARB, GL_NORMAL_ARRAY_BUFFER_BINDING_ARB, GL_COLOR_ARRAY_BUFFER_BINDING_ARB, GL_INDEX_ARRAY_BUFFER_BINDING_ARB, GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB, GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB, GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB, GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB, GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB
Accepted by thepname
parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev.
-
GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB
Accepted by thepname
parameter of GetVertexAttribivARB.
-
GL_STREAM_DRAW_ARB, GL_STREAM_READ_ARB, GL_STREAM_COPY_ARB, GL_STATIC_DRAW_ARB, GL_STATIC_READ_ARB, GL_STATIC_COPY_ARB, GL_DYNAMIC_DRAW_ARB, GL_DYNAMIC_READ_ARB, GL_DYNAMIC_COPY_ARB
Accepted by theusage
parameter of BufferDataARB.
-
GL_READ_ONLY_ARB, GL_WRITE_ONLY_ARB, GL_READ_WRITE_ARB
Accepted by theaccess
parameter of MapBufferARB.
-
GL_BUFFER_SIZE_ARB, GL_BUFFER_USAGE_ARB, GL_BUFFER_ACCESS_ARB, GL_BUFFER_MAPPED_ARB
Accepted by thepname
parameter of GetBufferParameterivARB.
-
GL_BUFFER_MAP_POINTER_ARB
Accepted by thepname
parameter of GetBufferPointervARB.
-
-
Method Detail
-
glBindBufferARB
public static void glBindBufferARB(int target, int buffer)
Binds a named buffer object.- Parameters:
target
- the target to which the buffer object is bound. One of:buffer
- the name of a buffer object
-
glDeleteBuffersARB
public static void glDeleteBuffersARB(java.nio.IntBuffer buffers)
Deletes named buffer objects.- Parameters:
buffers
- an array of buffer objects to be deleted
-
glDeleteBuffersARB
public static void glDeleteBuffersARB(int buffer)
Deletes named buffer objects.
-
glGenBuffersARB
public static void glGenBuffersARB(java.nio.IntBuffer buffers)
Generates buffer object names.- Parameters:
buffers
- a buffer in which the generated buffer object names are stored
-
glGenBuffersARB
public static int glGenBuffersARB()
Generates buffer object names.
-
glIsBufferARB
public static boolean glIsBufferARB(int buffer)
Determines if a name corresponds to a buffer object.- Parameters:
buffer
- a value that may be the name of a buffer object
-
glBufferDataARB
public static void glBufferDataARB(int target, long size, int usage)
Creates and initializes a buffer object's data store.usage
is a hint to the GL implementation as to how a buffer object's data store will be accessed. This enables the GL implementation to make more intelligent decisions that may significantly impact buffer object performance. It does not, however, constrain the actual usage of the data store.usage
can be broken down into two parts: first, the frequency of access (modification and usage), and second, the nature of that access. The frequency of access may be one of these:- STREAM - The data store contents will be modified once and used at most a few times.
- STATIC - The data store contents will be modified once and used many times.
- DYNAMIC - The data store contents will be modified repeatedly and used many times.
The nature of access may be one of these:
- DRAW - The data store contents are modified by the application, and used as the source for GL drawing and image specification commands.
- READ - The data store contents are modified by reading data from the GL, and used to return that data when queried by the application.
- COPY - The data store contents are modified by reading data from the GL, and used as the source for GL drawing and image specification commands.
- Parameters:
target
- the target buffer object. One of:size
- the size in bytes of the buffer object's new data storeusage
- the expected usage pattern of the data store. One of:STREAM_DRAW_ARB
STREAM_READ_ARB
STREAM_COPY_ARB
STATIC_DRAW_ARB
STATIC_READ_ARB
STATIC_COPY_ARB
DYNAMIC_DRAW_ARB
DYNAMIC_READ_ARB
DYNAMIC_COPY_ARB
-
glBufferDataARB
public static void glBufferDataARB(int target, java.nio.ByteBuffer data, int usage) public static void glBufferDataARB(int target, java.nio.ShortBuffer data, int usage) public static void glBufferDataARB(int target, java.nio.IntBuffer data, int usage) public static void glBufferDataARB(int target, java.nio.FloatBuffer data, int usage) public static void glBufferDataARB(int target, java.nio.DoubleBuffer data, int usage)
Creates and initializes a buffer object's data store.usage
is a hint to the GL implementation as to how a buffer object's data store will be accessed. This enables the GL implementation to make more intelligent decisions that may significantly impact buffer object performance. It does not, however, constrain the actual usage of the data store.usage
can be broken down into two parts: first, the frequency of access (modification and usage), and second, the nature of that access. The frequency of access may be one of these:- STREAM - The data store contents will be modified once and used at most a few times.
- STATIC - The data store contents will be modified once and used many times.
- DYNAMIC - The data store contents will be modified repeatedly and used many times.
The nature of access may be one of these:
- DRAW - The data store contents are modified by the application, and used as the source for GL drawing and image specification commands.
- READ - The data store contents are modified by reading data from the GL, and used to return that data when queried by the application.
- COPY - The data store contents are modified by reading data from the GL, and used as the source for GL drawing and image specification commands.
- Parameters:
target
- the target buffer object. One of:data
- a pointer to data that will be copied into the data store for initialization, orNULL
if no data is to be copiedusage
- the expected usage pattern of the data store. One of:STREAM_DRAW_ARB
STREAM_READ_ARB
STREAM_COPY_ARB
STATIC_DRAW_ARB
STATIC_READ_ARB
STATIC_COPY_ARB
DYNAMIC_DRAW_ARB
DYNAMIC_READ_ARB
DYNAMIC_COPY_ARB
-
glBufferSubDataARB
public static void glBufferSubDataARB(int target, long offset, java.nio.ByteBuffer data) public static void glBufferSubDataARB(int target, long offset, java.nio.ShortBuffer data) public static void glBufferSubDataARB(int target, long offset, java.nio.IntBuffer data) public static void glBufferSubDataARB(int target, long offset, java.nio.FloatBuffer data) public static void glBufferSubDataARB(int target, long offset, java.nio.DoubleBuffer data)
Updates a subset of a buffer object's data store.- Parameters:
target
- the target buffer object. One of:offset
- the offset into the buffer object's data store where data replacement will begin, measured in bytesdata
- a pointer to the new data that will be copied into the data store
-
glGetBufferSubDataARB
public static void glGetBufferSubDataARB(int target, long offset, java.nio.ByteBuffer data) public static void glGetBufferSubDataARB(int target, long offset, java.nio.ShortBuffer data) public static void glGetBufferSubDataARB(int target, long offset, java.nio.IntBuffer data) public static void glGetBufferSubDataARB(int target, long offset, java.nio.FloatBuffer data) public static void glGetBufferSubDataARB(int target, long offset, java.nio.DoubleBuffer data)
Returns a subset of a buffer object's data store.- Parameters:
target
- the target buffer object. One of:offset
- the offset into the buffer object's data store from which data will be returned, measured in bytesdata
- a pointer to the location where buffer object data is returned
-
glMapBufferARB
public static java.nio.ByteBuffer glMapBufferARB(int target, int access) public static java.nio.ByteBuffer glMapBufferARB(int target, int access, java.nio.ByteBuffer old_buffer) public static java.nio.ByteBuffer glMapBufferARB(int target, int access, long length, java.nio.ByteBuffer old_buffer)
Maps a buffer object's data store.LWJGL note: This method comes in 3 flavors:
ARBVertexBufferObject.glMapBufferARB(int, int)
- CallsGetBufferParameterivARB
to retrieve the buffer size and a new ByteBuffer instance is always returned.ARBVertexBufferObject.glMapBufferARB(int, int, ByteBuffer)
- CallsGetBufferParameterivARB
to retrieve the buffer size and theold_buffer
parameter is reused if not null.ARBVertexBufferObject.glMapBufferARB(int, int, long, ByteBuffer)
- The buffer size is explicitly specified and theold_buffer
parameter is reused if not null. This is the most efficient method.
- Parameters:
target
- the target buffer object being mapped. One of:access
- the access policy, indicating whether it will be possible to read from, write to, or both read from and write to the buffer object's mapped data store. One of:READ_ONLY_ARB
WRITE_ONLY_ARB
READ_WRITE_ARB
-
glUnmapBufferARB
public static boolean glUnmapBufferARB(int target)
Relinquishes the mapping of a buffer object and invalidates the pointer to its data store.Returns TRUE unless data values in the buffer’s data store have become corrupted during the period that the buffer was mapped. Such corruption can be the result of a screen resolution change or other window system-dependent event that causes system heaps such as those for high-performance graphics memory to be discarded. GL implementations must guarantee that such corruption can occur only during the periods that a buffer’s data store is mapped. If such corruption has occurred, UnmapBuffer returns FALSE, and the contents of the buffer’s data store become undefined.
- Parameters:
target
- the target buffer object being unmapped. One of:
-
glGetBufferParameterivARB
public static void glGetBufferParameterivARB(int target, int pname, java.nio.IntBuffer params)
Returns the value of a buffer object parameter.- Parameters:
target
- the target buffer object. One of:pname
- the symbolic name of a buffer object parameter. One of:BUFFER_SIZE
BUFFER_USAGE
BUFFER_ACCESS
BUFFER_MAPPED
BUFFER_ACCESS_FLAGS
BUFFER_MAP_LENGTH
BUFFER_MAP_OFFSET
BUFFER_IMMUTABLE_STORAGE
BUFFER_STORAGE_FLAGS
params
- the requested parameter
-
glGetBufferParameteriARB
public static int glGetBufferParameteriARB(int target, int pname)
Returns the value of a buffer object parameter.- Parameters:
target
- the target buffer object. One of:pname
- the symbolic name of a buffer object parameter. One of:BUFFER_SIZE
BUFFER_USAGE
BUFFER_ACCESS
BUFFER_MAPPED
BUFFER_ACCESS_FLAGS
BUFFER_MAP_LENGTH
BUFFER_MAP_OFFSET
BUFFER_IMMUTABLE_STORAGE
BUFFER_STORAGE_FLAGS
-
glGetBufferPointervARB
public static void glGetBufferPointervARB(int target, int pname, org.lwjgl.PointerBuffer params)
Returns the pointer to a mapped buffer object's data store.- Parameters:
target
- the target buffer object. One of:pname
- the pointer to be returned. Must be:BUFFER_MAP_POINTER_ARB
params
- the pointer value specified bypname
-
glGetBufferPointerARB
public static long glGetBufferPointerARB(int target, int pname)
Returns the pointer to a mapped buffer object's data store.- Parameters:
target
- the target buffer object. One of:pname
- the pointer to be returned. Must be:BUFFER_MAP_POINTER_ARB
-
glDeleteBuffersARB
public static void glDeleteBuffersARB(int[] buffers)
Array version of:DeleteBuffersARB
-
glGenBuffersARB
public static void glGenBuffersARB(int[] buffers)
Array version of:GenBuffersARB
-
glBufferDataARB
public static void glBufferDataARB(int target, short[] data, int usage) public static void glBufferDataARB(int target, int[] data, int usage) public static void glBufferDataARB(int target, float[] data, int usage) public static void glBufferDataARB(int target, double[] data, int usage)
Array version of:BufferDataARB
-
glBufferSubDataARB
public static void glBufferSubDataARB(int target, long offset, short[] data) public static void glBufferSubDataARB(int target, long offset, int[] data) public static void glBufferSubDataARB(int target, long offset, float[] data) public static void glBufferSubDataARB(int target, long offset, double[] data)
Array version of:BufferSubDataARB
-
glGetBufferSubDataARB
public static void glGetBufferSubDataARB(int target, long offset, short[] data) public static void glGetBufferSubDataARB(int target, long offset, int[] data) public static void glGetBufferSubDataARB(int target, long offset, float[] data) public static void glGetBufferSubDataARB(int target, long offset, double[] data)
Array version of:GetBufferSubDataARB
-
glGetBufferParameterivARB
public static void glGetBufferParameterivARB(int target, int pname, int[] params)
Array version of:GetBufferParameterivARB
-
-