Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

VBO not faster than immediate mode?



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 );
glColorPointer3, GL_FLOAT, 0, 0 );

// Render
glDrawArrays( GL_POINTS, 0, vertexCount );


glDisableClientState( GL_COLOR_ARRAY );
glDisableClientState( GL_VERTEX_ARRAY );

}

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/mac-opengl/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.