Graphics Reference
In-Depth Information
Example 6-8
Mapping a Buffer Object for Writing (continued)
idxMappedBuf = (GLushort*)
glMapBufferRange ( GL_ELEMENT_ARRAY_BUFFER, 0,
sizeof(GLushort) * numIndices,
GL_MAP_WRITE_BIT |
GL_MAP_INVALIDATE_BUFFER_BIT );
if ( idxMappedBuf == NULL )
{
esLogMessage( "Error mapping element buffer object." );
return;
}
// Copy the data into the mapped buffer
memcpy ( idxMappedBuf, indices,
sizeof(GLushort) * numIndices );
// Unmap the buffer
if ( glUnmapBuffer( GL_ELEMENT_ARRAY_BUFFER ) == GL_FALSE )
{
esLogMessage( "Error unmapping element buffer object." );
return;
}
Flushing a Mapped Buffer
An application may wish to map a range (or all) of a buffer object using
glMapBufferRange , but update only discrete subregions of the mapped
range. To avoid the potential performance penalty for flushing the entire
mapped range when calling glUnmapBuffer , the application can map
with the GL_MAP_FLUSH_EXPLICIT_BIT access flag (along with GL_MAP_
WRITE_BIT ). When the application has finished updating a portion of the
mapped range, it can indicate this fact using glFlushMappedBufferRange .
void * glFlushMappedBufferRange (GLenum target ,
GLintptr offset,
GLsizeiptr length )
target
can be set to any of the following targets:
GL_ARRAY_BUFFER
GL_ELEMENT_ARRAY_BUFFER
GL_COPY_READ_BUFFER
GL_COPY_WRITE_BUFFER
GL_PIXEL_PACK_BUFFER
GL_PIXEL_UNPACK_BUFFER
 
 
 
Search WWH ::




Custom Search