Hi,
I’ve got to render a whole buch of lines resp. line-strips. Amount of vertices: 100.000 to 4.000.000.
And I get around 3.500.000 lines per second on a Quadro FX500 and 10.000.000 lines per second on a 6800LE graphics board (lighting and depth-buffering disabled).
Is this the maximum performance that I can expect?
And a second question … I used raw GL calls, display lists and vertex buffer objects. They all render at the same speed. So what’s wrong with my code?
TIA,
Moritz
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor4ub(128, 255, 128, 32);
unsigned i;
// several draw modes:
// raw GL, line-strip as GL_LINE_STRIP or GL_LINES
// displaylists, "
// vertex buffer objects, "
switch(dmode)
{
case 'r':
glBegin(GL_LINE_STRIP);
for (i = 0; i < LSIZE; i++)
{
glVertex3fv(lineData+3*i);
}
glEnd();
break;
case 'R':
for (i = 1; i < LSIZE; i++)
{
glBegin(GL_LINES);
glVertex3fv(lineData+3*(i-1));
glVertex3fv(lineData+3*i);
glEnd();
}
break;
case 'd':
if (rlist[0] == 0) // init displaylist once
{
rlist[0] = glGenLists(1);
printf("rlist[0] = %d
", rlist[0]);
glNewList (rlist[0], GL_COMPILE);
glBegin(GL_LINE_STRIP);
for (i = 0; i < LSIZE; i++)
{
glVertex3fv(lineData+3*i);
}
glEnd();
glEndList();
}
else
{
glCallList(rlist[0]);
}
break;
case 'D':
if (rlist[1] == 0)
{
rlist[1] = glGenLists(1);
printf("rlist[1] = %d
", rlist[1]);
glNewList (rlist[1], GL_COMPILE);
for (i = 1; i < LSIZE; i++)
{
glBegin(GL_LINES);
glVertex3fv(lineData+3*(i-1));
glVertex3fv(lineData+3*i);
glEnd();
}
glEndList();
}
else
{
glCallList(rlist[1]);
}
break;
case 'v':
if (vlist[0] == 0)
{
glGenBuffersARB(1, vlist);
glBindBufferARB( GL_ARRAY_BUFFER_ARB, vlist[0] );
printf("vlist[0] = %d
", vlist[0]);
glBufferDataARB( GL_ARRAY_BUFFER_ARB, LSIZE*3*sizeof(float), lineData, GL_STATIC_DRAW_ARB );
}
else
{
glEnableClientState( GL_VERTEX_ARRAY );
glBindBufferARB( GL_ARRAY_BUFFER_ARB, vlist[0] );
glVertexPointer( 3, GL_FLOAT, 0, (char *) NULL );
glDrawArrays( GL_LINE_STRIP, 0, LSIZE );
glDisableClientState( GL_VERTEX_ARRAY );
}
break;
case 'V':
if (vlist[1] == 0)
{
glGenBuffersARB(1, vlist+1);
glBindBufferARB( GL_ARRAY_BUFFER_ARB, vlist[1] );
printf("vlist[1] = %d
", vlist[1]);
float *tmp = new float[2*(LSIZE-1)*3];
unsigned long offset = 0;
for (i = 1; i < LSIZE; i++)
{
memcpy(tmp+offset+0, lineData + 3*(i-1), 3*sizeof(float));
memcpy(tmp+offset+3, lineData + 3*(i), 3*sizeof(float));
offset += 6;
}
glBufferDataARB(GL_ARRAY_BUFFER_ARB, 2*(LSIZE-1)*3*sizeof(float), tmp, GL_STATIC_DRAW_ARB );
glFlush();
delete[] tmp;
}
else
{
glEnableClientState( GL_VERTEX_ARRAY );
glBindBufferARB( GL_ARRAY_BUFFER_ARB, vlist[1] );
glVertexPointer( 3, GL_FLOAT, 0, (char *) NULL );
glDrawArrays( GL_LINES, 0, 2*(LSIZE-1) );
glDisableClientState( GL_VERTEX_ARRAY );
}
break;
default:
break;
}
{
OrthoMode o;
glColor4ub(255,255,255,255);
if (dhelp)
drawHelp();
if (ddmode)
drawDrawMode();
drawFPS();
}
glutReportErrors();
glutSwapBuffers();
}