当我使用数组:
时,为什么阴影从我的立方体形状的未被照亮的面消失vertices[]
indices[]
colors[]
normals[]
texcoords[]
// and draw them by
glDrawElements();
但是当我使用时:
glBegin(...);
glVertex3f(...);
glEnd(...);
阴影还可以。 在这里,您可以看到正在发生的事情:
我的灯光设置如下:
glShadeModel (GL_SMOOTH);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
GLfloat AmbientLight[] = {0.0, 0.0, 0,0, 1.0};
GLfloat DiffuseLight[] = {1.0, 1.0, 1,0, 1.0};
GLfloat SpecularLight[] = {1.0, 1.0, 1.0, 1.0};
GLfloat Shininess[] = { 90.0 };
GLfloat Emission[] = {0.0, 0.0, 0.0, 1.0};
glLightfv(GL_LIGHT0, GL_AMBIENT, AmbientLight);
glLightfv(GL_LIGHT0, GL_DIFFUSE, DiffuseLight);
glLightfv(GL_LIGHT0, GL_SPECULAR, SpecularLight);
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, AmbientLight);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, DiffuseLight);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, SpecularLight);
glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, Shininess);
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, Emission);
答案 0 :(得分:0)
您可能错过了对
的调用glEnableClientState( GL_NORMAL_ARRAY );