Closed. This question is off-topic。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
                        
                        6年前关闭。
                                                                                            
                
        
我无法绘制颜色材料。如何绘制彩色材料?
我尝试了下面的代码:

 glMaterialfv(GL_FRONT, GL_AMBIENT, material._Ka);
 glMaterialfv(GL_FRONT, GL_DIFFUSE, material._Kd);
 glMaterialfv(GL_FRONT, GL_SPECULAR, material._Ks);
 // glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, ...);
 glMaterialfv(GL_FRONT, GL_SHININESS, material.Ns);

 //glColor4fv(material._Kd);

 glColorMaterial(GL_FRONT, GL_DIFFUSE);
 glColorMaterial(GL_FRONT, GL_SPECULAR);
 glColorMaterial(GL_FRONT, GL_AMBIENT);
 glColorMaterial(GL_FRONT, GL_SHININESS);


这将导致以下错误(错误1280):

glColorMaterial(GL_FRONT, GL_SHININESS);

最佳答案

如果您查找error code 1280(十六进制的0x0500),您会注意到它是GL_INVALID_ENUM

换句话说,您使用的枚举值不适合glColorMaterial

查找glColorMaterial,不难发现GL_SHININESS不是可接受的值。所以这是你的问题。

关于c++ - OpenGL glColorMaterial无法正常工作,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18079076/

10-12 17:27