Glut Lightning不适用于GL_TRIANGLES

时间:2013-01-23 12:49:12

标签: c glut

我遇到闪电问题。闪电的作用是:

//...
gluSphere(qobj, r1, precision, precision);
//...

但它有效:

//...
glBegin(GL_TRIANGLES);
glColor3fv(colors[4]);
glVertex3fv(vertices[triangles[fig2][1]]);
glVertex3fv(vertices[triangles[fig2][2]]);
glVertex3fv(vertices[triangles[fig2][3]]);
glEnd();
//...

以下是它的外观:

img http://img72.imageshack.us/img72/2158/36156234.jpg

正如您所看到的,只有“gluSphere”被减轻了。如何在GL_TRIANGLES和GL_POLYGON上制作相同的闪电?

1 个答案:

答案 0 :(得分:1)

照明引擎需要知道多边形面向哪个方向。 OpenGL要求您通过法线提供此信息,而不是自己计算这些信息:

//...
glBegin(GL_TRIANGLES);
glColor3fv(colors[4]);
// put a call to glNormal3fv or glNormal3f here!
glVertex3fv(vertices[triangles[fig2][1]]);
glVertex3fv(vertices[triangles[fig2][2]]);
glVertex3fv(vertices[triangles[fig2][3]]);
glEnd();
//...