GeeXLab
Current version: 0.45.1
>GeeXLab homepage

FurMark
Current version: 1.30.0
>FurMark homepage

GPU Caps Viewer
Current version: 1.55.0.0
>GPU Caps Viewer homepage

GPU Shark
Current version: 0.26.0.0
>GPU Shark homepage


Blogs
>JeGX's HackLab

Geeks3D's Articles
>GPU Memory Speed Demystified

>Multi-Threading Programming Resources

>GeForce and Radeon OpenCL Overview

>How to Get your Multi-core CPU Busy at 100%

>How To Make a VGA Dummy Plug

>Night Vision Post Processing Filter

PhysX FluidMark
Current version: 1.5.4
>FluidMark homepage

TessMark
Current version: 0.3.0
>TessMark homepage

ShaderToyMark
Current version: 0.3.0
>ShaderToyMark homepage
>ShaderToyMark Scores

Demoniak3D
Current Version: 1.23.0
>Demoniak3D
>Download
>Libraries and Plugins
>Demos
>Online Help - Reference Guide
>Codes Samples
 
OpenGL Vertex Buffer Objects

By Christophe [Groove] Riccio - www.g-truc.net
And
Jerome [JeGX] Guinot - jegx[NO-SPAM-THANKS]@ozone3d.net

Initial draft: May 1, 2006

Last Update: January 7, 2007


[ Index ]

Intro | Page 1 | Page 2 | Page 3



3 - References

3.1. Buffers Usage

STREAM1DYNAMIC1STATIC1
DRAW1GL_STREAM_DRAWGL_DYNAMIC_DRAWGL_STATIC_DRAW
READ2GL_STREAM_READGL_DYNAMIC_READGL_STATIC_ READ
COPY2GL_STREAM_COPYGL_DYNAMIC_COPYGL_STATIC_COPY

1: It is available with all OpenGL 1.5 graphics card and all the ones that support GL_ARB_vertex_buffer_object extension

2: There are none available yet; this could change with the release of nVidia G80 and ATI R600.

3.2. Rendering Functions

3.2.1. glArrayElement (deprecated)

This function is obsolete because it comes from the immediate mode.

GLvoid glArrayElement(GLint i);

Draw the ith vertex of an array and could be used in immediate mode like this:

glColorPointer(3, GL_FLOAT, 0, Colors);
glVertexPointer(3, GL_FLOAT, 0, Positions);

glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);

glBegin(GL_TRIANGLES);
    glArrayElement(0);
    glArrayElement(1);
    glArrayElement(2);
glEnd();

glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);

Witch corresponds to the following sequence of functions:

glBegin(GL_TRIANGLES);
    glColor3fv(Colors + 0 * 3);
    glVertex3fv(Positions + 0 * 3);
    glColor3fv(Colors + 1 * 3);
    glVertex3fv(Positions + 1 * 3);
    glColor3fv(Colors + 2 * 3);
    glVertex3fv(Positions + 2 * 3);
glEnd();

3.2.2. glDrawElements

Draw a set of geometric primitives according to an index array composed by count indexes.

GLvoid glDrawElements(GLenum mode, GLsizei count, GLenum type, GLvoid* indices)
{
    glBegin(mode);
    for(GLint i = 0; i < count; ++i)
        glArrayElement(indices[i]);
    glEnd();
}

3.2.3. glDrawRangeElements

Draw a set of geometric primitives according to an index array by keeping only indexes between start and end included.

GLvoid glDrawRangeElements(GLenum mode, GLuint start, GLuint end, 
GLsizei count, GLenum type, GLvoid* indices)
{
    glBegin(mode);
    for(GLint i = 0; i < count; ++i)
        if(indices[i] >= start && indices[i] <= end)
            glArrayElement(indices[i]);
    glEnd();
}

3.2.4. glDrawArrays

Draw a set of geometric primitives composed by count vertices starting by (and including) the first element.

GLvoid glDrawArrays(GLenum mode, GLint first, GLsizei count)
{
    glBegin(mode);
    for(GLint i = 0; i < count; ++i)
        glArrayElement(first + i);
    glEnd();
}

3.2.5. glMultiDrawArrays

Draw a set of geometric primitives composed by count vertices starting by (and including) the first element.

GLvoid glMultiDrawArrays(GLenum mode, GLint* first, GLsizei* count, 
GLsizei primcount)
{
    for(GLint i = 0; i < primcount; ++i)
    {
        if(count[i] > 0)
            glDrawArrays(mode, first[i], count[i]);
    }
}

3.2.6. glMultiDrawElements

Draw a set of geometric primitives describe by a set of index arrays.

GLvoid glMultiDrawElements(GLenum mode, GLsizei* count, GLenum type,
GLvoid** indices, GLsizei primcount)
{
    for(GLint i = 0; i < primcount; ++i)
    {
        if(count[i]) > 0)
            glDrawElements(mode, count[i], type, indices[i]);
    }
}

3.3. Array Types

3.3.1. Fixed pipeline types of array

Specify the fixed pipeline array that we want to enable or to disable:

GLvoid glEnableClientState(GLenum array);
GLvoid glDisableClientState(GLenum array);

Specify the fixed pipeline array that we want to enable or to disable:

  • GL_VERTEX_ARRAY
  • GL_NORMAL_ARRAY
  • GL_COLOR_ARRAY
  • GL_SECONDARY_COLOR_ARRAY
  • GL_INDEX_ARRAY
  • GL_EDGE_FLAG_ARRAY
  • GL_FOG_COORD_ARRAY
  • GL_TEXTURE_COORD_ARRAY

3.3.2. Shader pipeline types of array

Specify the shader pipeline array that we want to enable or disable:

GLvoid glEnableVertexAttribArray(GLuint index);
GLvoid glDisableVertexAttribArray(GLuint index);

index is an identifier of attribute variable.

3.4. Arrays Data

3.4.1. Description of fixed pipeline data

Since OpenGL 1.1 and GL_EXT_vertex_array and GL_ARB_vertex_buffer_object:

GLvoid glVertexPointer(GLint size, GLenum type, GLsizei stride, GLvoid* pointer);
GLvoid glNormalPointer(GLenum type, GLsizei stride, GLvoid* pointer);
GLvoid glColorPointer(GLint size, GLenum type, GLsizei stride, GLvoid* pointer);
GLvoid glEdgeFlagPointer(GLsizei stride, GLvoid* pointer);
GLvoid glTexCoordPointer(GLint size, GLenum type, GLsizei stride, GLvoid* pointer);

The function glIndexPointer is useless with Vertex Buffer Objects.

GLvoid glIndexPointer(GLenum type, GLsizei stride, GLvoid* pointer);

Since OpenGL 1.4 and GL_EXT_secondary_color :

GLvoid glSecondaryColorPointer(GLint size, GLenum type, GLsizei stride, 
GLvoid* pointer);

Since OpenGL 1.4 and GL_EXT_fog_coord :

GLvoid glFogCoordPointer(GLenum type, GLsizei stride, GLvoid* pointer);

3.4.2. Description of the whole data (Obsolete)

The glInterleavedArrays function implicated the use of array with predefined structure which is annoying and not adapted to multitexturing or shader based rendering. It is obsolete since OpenGL 1.3 and GL_ARB_multitexture. Moreover, the VBOs solution to manage interleaved array is really better because it fixes both issues.

GLvoid glInterleavedArrays(GLenum format, GLsizei stride, GLvoid* pointer);

3.4.3. Description of shader pipeline data

All attributes defined by the fixed pipeline are available in the OpenGL vertex shaders. If the user wants to send customized attributes, he can create a new attributes variable. Then, the data will be sent to the vertex shaders by using the glVertexAttribPointer function.

GLvoid glVertexAttribPointer(GLuint index, GLint size, GLenum type, 
GLboolean normalized, GLsizei stride, const GLvoid* pointer);

OpenGL ES doesn’t support fixed pipeline attributes. Consequently, it’s necessary to use customized attributes and glVertexAttribPointer for all the attributes. This approach can be used with OpenGL as well and it seems that it will be generalized in the future especially with OpenGL LM. This method increases flexibility and code sturdiness for a whole shader design. nVidia drivers are ready but not yet the ATI ones. The CTest5 class among the examples shows that difference between ATI and nVidia.

3.5. Types of Primitive

  • GL_POINTS : Points.
  • GL_LINES : List of independent segments.
  • GL_LINE_STRIP : Single line formed by a list of segments..
  • GL_LINE_LOOP : Single line formed by a list of segments that loops.
  • GL_TRIANGLES : List of independent triangles.
  • GL_TRIANGLE_STRIP : List of triangles that forms a strip.
  • GL_TRIANGLE_FAN : Create a fan using the first vertex as reference for all triangles.
  • GL_QUADS : List of independent quadrilateral.
  • GL_QUAD_STRIP : List of quadrilateral that forms a strip.
  • GL_POLYGON : Convex polygon.


4 - Further Reading

A topic is availbale on the oZone3D.Net's forums: [TUTO] OpenGL VBO.



5 - Downloads


VBO C++ / OpenGL Code Samples / CTest Classes - (1964k)
Last update: October 6, 2006


XPGL - Mesh Twister - OpenGL / VBO / GLSL - Visual C++ 6.0 Project - (1105k)
Mise à jour: 11 Octobre 2006


[ Index ]

Intro | Page 1 | Page 2 | Page 3





GeeXLab demos


GLSL - Mesh exploder


PhysX 3 cloth demo


Normal visualizer with GS


Compute Shaders test on Radeon


Raymarching in GLSL



Misc
>Texture DataPack #1
>Asus Silent Knight CPU Cooler
Page generated in 0.0044288635253906 seconds.