My vidio card is ATI X300, when I used vbo with dynamic method in this card, I found the rendering speed is slower than rendering from system memory. The code is below:
Let’s define “Method 1” as using vbo
define “Method 2” as no using vbo
// Method 1,
// the code create vb with vbo
glGenBuffersARB( 1, &m_nVBOVertices );
glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nVBOVertices );
glBufferDataARB( GL_ARRAY_BUFFER_ARB, m_nVertexCount3sizeof(float), m_pVertices, GL_DYNAMIC_DRAW_ARB );
glGenBuffersARB( 1, &m_nVBOTexCoords );
glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nVBOTexCoords );
glBufferDataARB( GL_ARRAY_BUFFER_ARB, m_nVertexCount2sizeof(float), m_pTexCoords, GL_DYNAMIC_DRAW_ARB );
// the code rendering
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nVBOVertices );
float* ver = (float*)glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
memcpy( ver, m_pVertices, m_nVertexCount3sizeof(float) );
GLboolean b = glUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
glVertexPointer( 3, GL_FLOAT, 0, (char *) NULL );
glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nVBOTexCoords );
ver = (float*)glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
memcpy( ver, m_pTexCoords, m_nVertexCount2sizeof(float) );
b = glUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
glTexCoordPointer( 2, GL_FLOAT, 0, (char *) NULL );
glDrawArrays( GL_TRIANGLES, 0, m_nVertexCount );
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
// Method 2 ,
// the code create vb in system memory
m_pVertices and m_pTexCoords and valid system memory
address and have valid data
// the code rendering
before darwing, their data are also be updated
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glVertexPointer( 3, GL_FLOAT, 0, g_pMesh->m_pVertices );
glTexCoordPointer( 2, GL_FLOAT, 0, g_pMesh->m_pTexCoords );
glDrawArrays( GL_TRIANGLES, 0, g_pMesh->m_nVertexCount );
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
When rendering the same thing in Ati x300, the “Method 1” is much slower than “Method 2”. But in Nvidia card Gfx7300, I found “Method 1” is faster than “Method 2”. I don’t know why, whether it is the vidio driver’s problem or other problem? Is the driver of ATI not so good supporting vbo?