PDA

View Full Version : Opengl limitations on number of primitives?



alex_mal
05-01-2002, 03:44 PM
I need to create software for displaying a huge number of geometrical objects.
It can be more than 2000000 primitives.
OpenGL begin to fail if the number of primitives is about 800000.
I wrote a simple program that generates a number of GL_QUADS.
Here is the part of the code:
//***************
GLuint list;
list = glGenLists( 1 );
glNewList( list, GL_COMPILE );
glBegin(GL_QUADS);
GLdouble x,dx;
long i=0;

qglColor( green );

long numOfFaces=700000;
dx=2./numOfFaces;

for (i=0;i<numOfFaces;i++)
{
x=double(i*2.)/numOfFaces -1.;
glVertex3d(x, 0.2,1.0);
glVertex3d(x+dx,0.2, 1.0);
glVertex3d(x+dx,- 0.2, 1.0);
glVertex3d(x, -0.2, 1.0);
}
glEnd();
glEndList();
//************

If numOfFaces is up to 600000 it works.
It should not be any problem with precision, if OpenGL store the data with double precision. (glVertex3d function is used)
Unfortunately I need to be able to draw a huge number of geometrical primitives.

Are there any ideas why the problem occurs and how it can be solved?

Thank you in advance.

My Computer:
Windows XP (problem also exists at least on Windows 2000, 95 )
Intel Pentium 4 CPU 2,00 GHz
512 MB RAM
64 MB NVIDIA GeForce2MX

thewizard75
05-01-2002, 03:50 PM
1. Put it in more than one display list! Having 600,000 faces in a single list is quite enormous, and probably won't perform well. Most OpenGL drivers also place limits on how many primatives can be in a single display list (or maybe even across all display lists). Look into Vertex arrays and the like.
2. Certainly there are several people on this forum that easily draw more than 600,000 primatives at once =), so it can certainly be done =).

Don't Disturb
05-02-2002, 04:43 AM
GeForce 1 & 2 are limited to 65536 elements per vertex array, this might have something to do with the limitation on the display list. I read in an NVidia FAQ somewhere that you should split large models into smaller sections, and draw the sections separately.
Don't use doubles, use floats. All OpenGL implementations I've seen only support floats, so the doubles have to be converted to floats before the vertices can be rendered.