PDA

View Full Version : GL_TRIANGLE_FAN versus GL_QUADS performance



suriogl
02-25-2010, 03:02 AM
GLfloat Vertices[] = {
-0.75, -0.12,
-0.75, 0.12,
0.75, 0.12,
0.75, -0.12 };

1. using GL_TRIANGLE_FAN
glColor3f (1.0f, 0.0f, 0.0f);
glVertexPointer (2, GL_FLOAT, 0, Vertices);
glDrawArrays (GL_TRIANGLE_FAN, 0, 4);

2. using GL_QUADS
glColor3f (1.0f, 0.0f, 0.0f);
glVertexPointer (2, GL_FLOAT, 0, Vertices);
glDrawArrays (GL_QUADS, 0, 4);

Both 1 and 2 draw rectangle. Does it make any difference with respect to the performance? Which one is easier for OpenGL to draw?

randall
02-25-2010, 04:16 AM
Use GL_TRIANGLE_FAN. GL_QUADS are removed from OpenGL 3.1 and newer.

aqnuep
02-25-2010, 09:43 AM
For that simple geometry it actually doesn't matter.

If you would like to be forward compatible use GL_TIRANGLE_STRIP instead as it is the best supported way beside normal triangle soups.

As randall mentioned, GL_QUADS were removed, personally I expect the same regarding the GL_TRIANGLE_FAN as its usage is quite limited and sometimes not directly supported by the hardware.