PDA

View Full Version : Blending and ColorMaterial



devdept
11-15-2006, 12:11 PM
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

Relic
11-15-2006, 12:16 PM
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.

devdept
11-16-2006, 02:28 AM
Yes, yes, yes. Thanks great !!!

Relic
11-16-2006, 06:00 AM
Too easy. ;)
You're welcome.