我试图找出如何编写自己的原语,如gluSolidCube()..
在下面的代码中,我绘制了2个四边形。一个借助于这个方法(红色的)和另一个 - 由我自己在glBegin()/ glEnd()(蓝色的)的帮助下。
glPushMatrix();
glRotatef(-angleX, 0, 0, 1);
glRotatef(angleY, 0, 1, 0);
glColor3f(1, 0, 0);
glTranslatef(0.6, 0, 0);
glutSolidCube(1);
glColor3f(0, 0, 1);
glTranslatef(-1.2, 0, 0);
glPolygonMode(GL_FRONT, GL_FILL);
glShadeModel(GL_SMOOTH);
glBegin(GL_QUADS);
glVertex3f(0.5, 0.5, 0.5);
glVertex3f(0.5, 0.5, -0.5);
glVertex3f(-0.5, 0.5, -0.5);
glVertex3f(-0.5, 0.5, 0.5);
glVertex3f(0.5, 0.5, 0.5);
glVertex3f(0.5, 0.5, -0.5);
glVertex3f(0.5, -0.5, -0.5);
glVertex3f(0.5, -0.5, 0.5);
glVertex3f(-0.5, 0.5, -0.5);
glVertex3f(-0.5, 0.5, 0.5);
glVertex3f(-0.5, -0.5, 0.5);
glVertex3f(-0.5, -0.5, -0.5);
glVertex3f(0.5, 0.5, -0.5);
glVertex3f(-0.5, 0.5, -0.5);
glVertex3f(-0.5, -0.5, -0.5);
glVertex3f(0.5, -0.5, -0.5);
glVertex3f(0.5, 0.5, 0.5);
glVertex3f(-0.5, 0.5, 0.5);
glVertex3f(-0.5, -0.5, 0.5);
glVertex3f(0.5, -0.5, 0.5);
glVertex3f(0.5, -0.5, 0.5);
glVertex3f(0.5, -0.5, -0.5);
glVertex3f(-0.5, -0.5, -0.5);
glVertex3f(-0.5, -0.5, 0.5);
glEnd();
glPopMatrix();
因此,您可以在下面的屏幕截图中看到,红色四边形上的闪光与蓝色闪光灯不同。怎么解决这个问题?