hazelwood
11-06-2005, 06:15 AM
I'm looking for techniques to optimize the rendering of my billboards. I have a few thousand trees on a heightmap (the engine is 3D but fixed at an isometric angle and a very low FOV; the trees are sorted by depth for alpha-blending).
Here's my routine for drawing an object:
glPushMatrix();
glTranslatef(x,y,z);
glRotatef(-camera->pitch,0.0f,1.0f,0.0f); /* anti-tilt on y-axis */
glRotatef(-camera->yaw, 1.0f,0.0f,0.0f); /* anti-tilt on x-axis */
glScalef(sx,sy,0.0f);
glBegin(GL_TRIANGLE_FAN);
glTexCoord2f(0.0f,0.0f);
glVertex2f(0.0f,1.0f);
glTexCoord2f(1.0f,0.0f);
glVertex2f(1.0f,1.0f);
glTexCoord2f(1.0f,1.0f);
glVertex2f(1.0f,0.0f);
glTexCoord2f(0.0f,1.0f);
glVertex2f(0.0f,0.0f);
glEnd();
glPopMatrix();
So the first thing I did was stuffing the billboard graphics into as few textures as possible. This seemed to help a bit.
The next thing I tried was replacing the glBegin/glEnd part with an vertex array (I just learned how to do that)
glInterleavedArrays(GL_T2F_V3F,0,vb);
glDrawArrays(GL_TRIANGLE_FAN,0,4);
Though that turned out to be actually slower than the glBegin. Needless to say I'm not so proficient in OpenGL and now I'm stumped. How could I possibly speed this up?
Here's my routine for drawing an object:
glPushMatrix();
glTranslatef(x,y,z);
glRotatef(-camera->pitch,0.0f,1.0f,0.0f); /* anti-tilt on y-axis */
glRotatef(-camera->yaw, 1.0f,0.0f,0.0f); /* anti-tilt on x-axis */
glScalef(sx,sy,0.0f);
glBegin(GL_TRIANGLE_FAN);
glTexCoord2f(0.0f,0.0f);
glVertex2f(0.0f,1.0f);
glTexCoord2f(1.0f,0.0f);
glVertex2f(1.0f,1.0f);
glTexCoord2f(1.0f,1.0f);
glVertex2f(1.0f,0.0f);
glTexCoord2f(0.0f,1.0f);
glVertex2f(0.0f,0.0f);
glEnd();
glPopMatrix();
So the first thing I did was stuffing the billboard graphics into as few textures as possible. This seemed to help a bit.
The next thing I tried was replacing the glBegin/glEnd part with an vertex array (I just learned how to do that)
glInterleavedArrays(GL_T2F_V3F,0,vb);
glDrawArrays(GL_TRIANGLE_FAN,0,4);
Though that turned out to be actually slower than the glBegin. Needless to say I'm not so proficient in OpenGL and now I'm stumped. How could I possibly speed this up?