Hello,
I am learning OpenGL and building a simple particle demo with
velocity, friction, forces, etc.
I started with immediate mode and drew each particle with glVertex()
and it went up to 200k particles with about 50fps (2.4Ghz iMac & ati
2600 pro & no vsync).
Then I learned about VBO's and how much faster they're supposed to be.
I modified my code to use VBO instead but the speed difference is
only about 10% more compared to glBegin/end() with zillion individual
glColor() glVertex() pairs ?!?
I am using 4 threads to calculate the math and timer to render the
scene. Is there anything to speed up things or is GLSL -> FBO -> VBO
only possible solution? (well, frankly that is my next goal and
questions anyway).
But for now; Is it possible that there is something wrong in my VBO
usage or can driver somehow optimize the glVertex() calls and thus no
huge gains visible?
Thank You.
Here's how I do it:
// build VBO's once
bool buildVBO(int vertexCount,float* pVerArray,float* pColArray )
{
if (pVerArray && pColArray) {
glGenBuffersARB( 1, &m_nVBOVertices );
glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nVBOVertices );
glBufferDataARB( GL_ARRAY_BUFFER_ARB, vertexCount * 3 *
sizeof(GLfloat),pVerArray, GL_DYNAMIC_DRAW );
glGenBuffersARB( 1, &m_nVBOColors );
glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nVBOColors );
glBufferDataARB( GL_ARRAY_BUFFER_ARB, vertexCount * 3 *
sizeof(GLfloat), pColArray, GL_DYNAMIC_DRAW );
if (m_nVBOVertices && m_nVBOColors) return true;
}
return false;
}
// update new vertex-data
void refreshData(int vertexCount,float* pVerArray,float* pColArray )
{
glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_nVBOVertices);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, vertexCount * 3 *
sizeof(GLfloat), pVerArray, GL_DYNAMIC_DRAW );
glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_nVBOColors);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, vertexCount * 3 *
sizeof(GLfloat), pColArray, GL_DYNAMIC_DRAW );
}
// draw VBO's
void drawVbo(int vertexCount)
{
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_COLOR_ARRAY );
glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nVBOVertices );
glVertexPointer( 3, GL_FLOAT, 0, 0 );
glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nVBOColors );
glColorPointer( 3, GL_FLOAT, 0, 0 );
// Render
glDrawArrays( GL_POINTS, 0, vertexCount );
glDisableClientState( GL_COLOR_ARRAY );
glDisableClientState( GL_VERTEX_ARRAY );
}
__________ Information from ESET NOD32 Antivirus, version of virus
signature database 3128 (20080523) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com