3D graphics eBook - Course Materials Repository
3D graphics eBook - Course Materials Repository
3D graphics eBook - Course Materials Repository
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Vertex Buffer Object 227<br />
Vertex Buffer Object<br />
A Vertex Buffer Object (VBO) is an OpenGL extension that provides methods for uploading data (vertex, normal<br />
vector, color, etc.) to the video device for non-immediate-mode rendering. VBOs offer substantial performance gains<br />
over immediate mode rendering primarily because the data resides in the video device memory rather than the<br />
system memory and so it can be rendered directly by the video device.<br />
The Vertex Buffer Object specification has been standardized by the OpenGL Architecture Review Board [1] as of<br />
OpenGL Version 1.5. Similar functionality was available before the standardization of VBOs via the Nvidia-created<br />
extension "Vertex Array Range" [2] or the ATI's "Vertex Array Object" [3] extension.<br />
Basic VBO functions<br />
The following functions form the core of VBO access and manipulation:<br />
In OpenGL 2.1 [4] :<br />
GenBuffersARB(sizei n, uint *buffers)<br />
Generates a new VBO and returns its ID number as an unsigned integer. Id 0 is reserved.<br />
BindBufferARB(enum target, uint buffer)<br />
Use a previously created buffer as the active VBO.<br />
BufferDataARB(enum target, sizeiptrARB size, const void *data, enum usage)<br />
Upload data to the active VBO.<br />
DeleteBuffersARB(sizei n, const uint *buffers)<br />
Deletes the specified number of VBOs from the supplied array or VBO id.<br />
In OpenGL 3.x [5] and OpenGL 4.x [6] :<br />
GenBuffers(sizei n, uint *buffers)<br />
Generates a new VBO and returns its ID number as an unsigned integer. Id 0 is reserved.<br />
BindBuffer(enum target, uint buffer)<br />
Use a previously created buffer as the active VBO.<br />
BufferData(enum target, sizeiptrARB size, const void *data, enum usage)<br />
Upload data to the active VBO.<br />
DeleteBuffers(sizei n, const uint *buffers)<br />
Deletes the specified number of VBOs from the supplied array or VBO id.<br />
Example usage in C Using OpenGL 2.1<br />
//Initialise VBO - do only once, at start of program<br />
//Create a variable to hold the VBO identifier<br />
GLuint triangleVBO;<br />
//Vertices of a triangle (counter-clockwise winding)<br />
float data[] = {1.0, 0.0, 1.0, 0.0, 0.0, -1.0, -1.0, 0.0, 1.0};<br />
//Create a new VBO and use the variable id to store the VBO id<br />
glGenBuffers(1, &triangleVBO);