Mailing Lists: Apple Mailing Lists

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

Re: VBO not faster than immediate mode?



I've never used VBOs before, nor researched them very much; but I do
have a guess for you nonetheless.

I would assume that your use of GL_DYNAMIC_DRAW is preventing the card
from storing the data in an maximally optimized form.

Trying to adapt your application to use GL_STATIC_DRAW, or display
lists might be a fruitful venture. (If you haven't heard of display
lists yet then don't be afraid to give them a go; they're certainly no
more complicated than VBOs).

Also, googling "Vertex Buffers versus Display Lists" will
likely be of use as well.

-Patrick

P.S. I don't think you need to use the ARB suffixed functions as you
do in the source you posted.  GenBuffers, BindBuffers, and BufferData
have been in OpenGL since 1.5. You can find the standard here:
http://www.opengl.org/documentation/specs/

On May 23, 2008, at 12:34 PM, Mike wrote:

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

 _______________________________________________
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

References: 
 >VBO not faster than immediate mode? (From: Mike <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.