PDA

View Full Version : lines vs. vertex arrays

Dalhia
02-17-2001, 03:35 PM
which one is faster or is there a faster way than these?

note: each value in the indice array corresponds to a grid of points like this:

1 2 3
4 5 6
7 8 9

the conditions are that each point must be connected to each point directly around it by a line. For example, 1 should be connected to 2 and 4, whereas 5 should be connected to 2, 4, 6, and 8.

static GLuint indices = {1, 4, 4, 5, 5, 2, 2, 3, 3, 6, 6, 5, 5, 8, 8, 7, 7, 4, 1, 2, 6, 9, 9, 8};

glDrawElements (GL_LINES, 24, GL_UNSIGNED_INT, indices);

or...

glBegin (GL_LINE_STRIP);
glVertex3f (point[1]);
glVertex3f (point[4]);
glVertex3f (point[5]);
glVertex3f (point[2]);
glVertex3f (point[3]);
glVertex3f (point[6]);
glVertex3f (point[5]);
glVertex3f (point[8]);
glVertex3f (point[7]);
glVertex3f (point[4]);
glEnd();
glBegin (GL_LINES);
glVertex3f (point[1]);
glVertex3f (point[2]);

glVertex3f (point[6]);
glVertex3f (point[9]);

glVertex3f (point[9]);
glVertex3f (point[8]);
glEnd();

I know one may be much longer than the other, but speed is more of an issue. I know that glDrawElements doesn't use GL_LINE_STRIP, so is it faster to call two points in glDrawElements or is it faster to call one glVertex3f that connects to the previous call of glVertex3f?
Or is there a better way to draw a grid with non-uniform heights?