Original Post
Hi all, I am experimenting with VBO's to see if it can help me speed up my app. I use a triangle fan with 8 triangles and draw it for 1000 times each frame. I get the same fps whether i use VBO or just use glVertex3f. So my question is, is it the way i use the VBO that causes no improvement in fps or are VBO's not suitable for ~10 vertices of data?
GLfloat data[] = {0.0f, 0.0f, 0.0f,
1.0f, 1.0f, 0.0f,
0.0f, 1.0f, 0.0f,
-1.0f, 1.0f, 0.0f,
-1.0f, 0.0f, 0.0f,
-1.0f, -1.0f, 0.0f,
0.0f, -1.0f, 0.0f,
1.0f, -1.0f, 0.0f,
1.0f, 0.0f, 0.0f,
1.0f, 1.0f, 0.0f };
int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
glLoadIdentity(); // Reset The View
glTranslatef(0.0f,1.0f,z);
glRotatef(xrot,1.0f,0.0f,0.0f);
glRotatef(yrot,0.0f,1.0f,0.0f);
if( GetTickCount() - g_dwLastFPS >= 1000 ) // When A Second Has Passed...
{
g_dwLastFPS = GetTickCount(); // Update Our Time Variable
g_nFPS = g_nFrames; // Save The FPS
g_nFrames = 0;
// sprintf(title,"triangles= %d fps=%d throughput:%.2g MT/s vbo=%d",triangles,g_nFPS,(float)g_nFPS*triangles/1000000,vbo);
sprintf(title,"fps=%d",g_nFPS);
SetWindowText( hWnd, title );
}
g_nFrames++;
triangles=0;
if(vbo)
{
for(int i=0;i<1000;i++)
{
glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer);
glVertexPointer(3, GL_FLOAT, 0, 0);
glDrawArrays(GL_TRIANGLE_FAN, 0, 10);
}
}
else
{
for(int i=0;i<1000;i++)
{
glBegin(GL_TRIANGLE_FAN);
for(int i=0;i<3*10;i+=3)
glVertex3f(data,data[i+1],data[i+2]);
glEnd();
}
}
triangles+=8;
xrot+=xspeed;
yrot+=yspeed;
return TRUE; // Keep Going
}