Friday, March 24, 2006


OpenGL: Plane out of Triangles


pS: not my algorithm.


void drawPlane(int w, int h)
{
int i, j;
float dw = 1.0 / w;
float dh = 1.0 / h;

glNormal3f(0.0, 0.0, 1.0);
for (j = 0; j < h; ++j) {
glBegin(GL_TRIANGLE_STRIP);
for (i = 0; i <= w; ++i) {
glVertex2f(dw * i, dh * (j + 1));
glVertex2f(dw * i, dh * j);
}
glEnd();
}
}

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home