OpenGL billboarding

I’ve asked similar questions regarding this, but I’m not sure if I quite understand how to do this…

I have approximately 20k circles I want to render (the circles are line loops with ~64 vertices each). The circles should always be user facing, but I need to be able to do depth testing because I don’t want to render these circles if they are behind other objects.

I need the circles to be a constant size in pixels.

Since I want to be able to draw in pixel sizes, I setup my projections to be able to draw in pixel coordinates

(note: code in Java OpenGL)


gl.glMatrixMode(GL.GL_PROJECTION);
gl.glDisable(GL.GL_LIGHTING);
gl.glPushMatrix();
gl.glLoadIdentity();
gl.glOrtho(0d, width, height, -1, 1);
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glPushMatrix();
gl.glLoadIdentity();

But this causes the depth test not to function properly since this is essentially drawing in 2d.

To do the actual drawing of the circles, I enable vertex arrays and then do the following:


// some code here to set the color for the current circle
gl.glVertexPointer(2, GL.GL_FLOAT, 0, buffer);
gl.glDrawArrays(GL.GL_POLYGON, offset, numVerticesPerCircle);

So there are (at least) 2 main issues here. It draws correctly, but the performance is very poor with 20k vertices.

  1. How do I a bunch of user facing objects but still allow for depth testing

  2. Am I drawing the circles efficiently? This seems very slow and my frame rate is terrible.

Any specific help here would be appreciated. I’ve done some research on billboarding, but I’m kind of stuck at this point…

Thanks,
Jeff