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?



Depends on what you are doing with them.

If you are reusing the vertices, then the VBO can stay in memory, and it's _very_ fast.

If you are modifying a relatively small number of vertices in the VBO, you can memory map the array, and it's also fairly fast.

If you are changing the entire array via the CPU and reloading it each frame, then you lose much of the advantage of using VBOs - although memory mapping is generally faster than rendering all your data via immediate mode (depends on the driver implementation).

If the changes to your dataset are procedural, then you can use shaders (rather than the CPU) to modify the array. In such cases, you are probably better off using FBOs.

- Bob


----- Original Message ----- From: "Mike" <email@hidden>
To: <email@hidden>
Sent: Friday, May 23, 2008 9:34 AM
Subject: 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 );
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



--------------------------------------------------------------------------------


_______________________________________________
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


__________ Information from ESET NOD32 Antivirus, version of virus signature database 3128 (20080523) __________


The message was checked by ESET NOD32 Antivirus.

http://www.eset.com


_______________________________________________ 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.