启用光的那一刻,我就会失去色彩。我正在使用与OpenGL相同的代码,效果很好,但是我可以使用glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);就在glEnable(GL_COLOR_MATERIAL);之前
我读过的文章提到您不需要在OpenGLES上使用该调用,我缺少一些调用序列吗?
我还应该补充一点,我正在为模型使用3ds文件,在我尝试添加光之前,它工作正常。
//draw function
//ofSetSmoothLighting()
glShadeModel(GL_SMOOTH)
//ofEnableDepthTest();
glEnable(GL_DEPTH_TEST);
//ofEnableLighting();
glEnable(GL_LIGHTING);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_NORMALIZE);
//pointLight.enable();
//setup
glLightfv(GL_LIGHT0 + /*my index*/, GL_AMBIENT, &/*first member of my aray*/);
glLightfv(GL_LIGHT0 + /*my index*/, GL_DIFFUSE, &/*first member of my aray*/);
glLightfv(GL_LIGHT0 + /*my index*/, GL_SPECULAR, &/*first member of my aray*/);
//on position change
glLightfv(GL_LIGHT0 + /*my index*/, GL_POSITION, cc);
//on orientation
glLightfv(GL_LIGHT0 + /*my index*/, GL_SPOT_DIRECTION, spot_direction);
//setAttenuation(1.f,0.f,0.f);
glLightf(GL_LIGHT0 + /*my index*/, GL_CONSTANT_ATTENUATION, attenuation_constant);
glLightf(GL_LIGHT0 + /*my index*/, GL_LINEAR_ATTENUATION, attenuation_linear);
glLightf(GL_LIGHT0 + /*my index*/, GL_QUADRATIC_ATTENUATION, attenuation_quadratic);
//ofEnablelighting
glEnable(GL_LIGHTING);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_NORMALIZE);
glEnable(GL_LIGHT0 + /*my index*/);
//modelDraw()
//for each mesh
glShadeModel(GL_SMOOTH);
glBindTexture(GL_TEXTURE_2D, 0);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, currentMaterial.getDiffuseColor());
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, currentMaterial.getAmbientColor());
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, adjustedSpecular);
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 128.f * currentMaterial.getSpecularExponent());
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_NORMAL_ARRAY );
glVertexPointer( 3, GL_FLOAT, 0, &m_vertices[0] );
glNormalPointer(GL_FLOAT, 0, &m_normals[0] );
glDrawElements(GL_TRIANGLES, numFaces, GL_UNSIGNED_SHORT, &(materialsIter->second[0]));
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_NORMAL_ARRAY );
//point light disable
glDisable(GL_LIGHT0 + /*my index*/);
//ofDisableLighting()
glDisable(GL_LIGHTING);
glDisable(GL_NORMALIZE);
启用光的那一刻,我就会失去色彩。我正在使用与OpenGL相同的代码,效果很好,但是我可以使用glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);就在...
用于设置材料的多种呼叫组合没有多大意义。您可以在此处设置材质的环境色和漫反射色: