scyth3s's picture

Material properties issue

I'm having an issue with material properties (whoa... Its like you already knew that coming into the topic!). I have this strip of code to initialize the materials

 internal void Bind()
        {
            //GL.Material(MaterialFace.Front, MaterialParameter.Ambient, Color4.White);   //Ka);
           // GL.Material(MaterialFace.Front, MaterialParameter.Diffuse, Color4.White);      //Kd);
            //GL.Material(MaterialFace.Front, MaterialParameter.Specular, Color4.White);    //Ks);
            //GL.Material(MaterialFace.Front, MaterialParameter.Emission, Color4.White);    // Ke);
 
            //only bind if we are textured
            if (diffuseMap != null)
            {
                GL.Enable(EnableCap.Texture2D);
                diffuseMap.Bind();
            }
            else
                GL.Disable(EnableCap.Texture2D);
        }

Obviously, the code is not optimized. There are state changes for texture2D that should be somewhere else, but I will optimize that later. If I uncomment the material properties lines (ie: GL.Material(MaterialFace.Front, MaterialParameter.Ambient, Color4.White);), then it seems to screw up my camera matrices. The camera will simply jump around at random.

Leaving those lines commented, it works fine, except for the lack of materials (everything reflects light 100%, as expected). Why would setting material properties mess with the ModelView matrix? I have no console idea why binding a color4 to a material would ever do that.