diff options
author | Daniel Borca <[email protected]> | 2005-01-19 07:52:49 +0000 |
---|---|---|
committer | Daniel Borca <[email protected]> | 2005-01-19 07:52:49 +0000 |
commit | 9ebce91a66a5775fbb0d3bfce162531d1ad2d975 (patch) | |
tree | 73649d9e6767a71c75db74be2a239916dfac46e6 | |
parent | 59c2e16e755c0cba78b27525681cd79456a2f496 (diff) |
glVertex* is the provoking "cmd" (that is, by the time of glVertex*, we must have all other attributes already set).
i am committing this before i forget. however, i'm still leaving my code disabled, because the old code seems legal.
-rw-r--r-- | progs/tests/dinoshade.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/progs/tests/dinoshade.c b/progs/tests/dinoshade.c index d0a79c1923f..ed7b879bc71 100644 --- a/progs/tests/dinoshade.c +++ b/progs/tests/dinoshade.c @@ -260,6 +260,7 @@ extrudeSolidFromPolygon(GLfloat data[][2], unsigned int dataSize, from being "smoothed" */ glBegin(GL_QUAD_STRIP); for (i = 0; i <= count; i++) { +#if 1 /* weird, but seems to be legal */ /* mod function handles closing the edge */ glVertex3f(data[i % count][0], data[i % count][1], 0.0); glVertex3f(data[i % count][0], data[i % count][1], thickness); @@ -271,6 +272,19 @@ extrudeSolidFromPolygon(GLfloat data[][2], unsigned int dataSize, dy = data[i % count][0] - data[(i + 1) % count][0]; len = sqrt(dx * dx + dy * dy); glNormal3f(dx / len, dy / len, 0.0); +#else /* the nice way of doing it */ + /* Calculate a unit normal by dividing by Euclidean + distance. We * could be lazy and use + glEnable(GL_NORMALIZE) so we could pass in * arbitrary + normals for a very slight performance hit. */ + dx = data[i % count][1] - data[(i - 1 + count) % count][1]; + dy = data[(i - 1 + count) % count][0] - data[i % count][0]; + len = sqrt(dx * dx + dy * dy); + glNormal3f(dx / len, dy / len, 0.0); + /* mod function handles closing the edge */ + glVertex3f(data[i % count][0], data[i % count][1], 0.0); + glVertex3f(data[i % count][0], data[i % count][1], thickness); +#endif } glEnd(); glEndList(); |