Blending and ColorMaterial

Why uncommenting the first and last line this code does not work (nothing displayed)?

// gl.Enable(gl.BLEND);
gl.Disable(gl.COLOR_MATERIAL);
gl.Materialfv(gl.FRONT, gl.AMBIENT_AND_DIFFUSE, new float[3] { 1, 1, 1 });
gl.Materialfv(gl.BACK, gl.AMBIENT_AND_DIFFUSE, new float[3] { 0, 0, 0 });
gl.Disable(gl.CULL_FACE);
gl.PolygonMode(gl.FRONT_AND_BACK, gl.FILL);

foreach (Entity ent in entities)

ent.Draw();

gl.Enable(gl.COLOR_MATERIAL);
// gl.Disable(gl.BLEND);

Thanks a lot,

Alberto

glMaterialfv for colors takes four floats, you have only three. Assuming the fourth which is the alpha happens to be zero in the diffuse case which is used during lighting to calculate the final alpha value, blending with the wrong glBlendFunc would render fully transparent.
Your question was with blending off. The back face color is black. Make sure you didn’t render only black backfaces. During debugging of the usual OpenGL “black screen problem” you should change the glClearColor from the default black to something fancy. I normally use glClearColor(1.0f, 0.0f, 1.0f, 0.0f) to be sure I don’t miss renderings.

Yes, yes, yes. Thanks great !!!

Too easy. :wink:
You’re welcome.