Model / Material Woes
I just wrote a class for loading and displaying models. Everything works fine except for a problem with the materials. In every frame, I set up each material with glMaterialf() and glMaterialfv(), then I draw all the faces for that material. When I set the material, it ends up only drawing the faces that go with the last material. All faces are draw (but without materials) when I comment out the glMaterial*() lines. Any ideas?
EDIT: The problem described above has been fixed and replaced with a different one. Two of my three materials work perfectly, but one doesn't. It's supposed to be black, but it only sometimes is. I'm rotating a model to see what it looks like from all sides, and this material is only black when it passes by a certain angle. It's white otherwise.
[Edited by - Tokage on September 11, 2004 11:40:18 PM]
It looks like side effects with your state changes.
Make sure you effectively setup the right material just before rendering the model.
For instance, this will not work :
glMaterial(/*set material #1*/);
glMaterial(/*set material #2*/);
glBegin(/*render model #1*/);
glEnd();
glBegin(/*render model #2*/);
glEnd();
Also make sure lighting is enabled, as lighting is mandatory for materials to take effect. Also make sure you're calling color-material enables and setting (resp. glEnable(GL_COLOR_MATERIAL) and glColorMaterial(/*whatever*/)) at the right place. It's pretty hard to call color-material correctly. do you use that feature ?
Make sure you effectively setup the right material just before rendering the model.
For instance, this will not work :
glMaterial(/*set material #1*/);
glMaterial(/*set material #2*/);
glBegin(/*render model #1*/);
glEnd();
glBegin(/*render model #2*/);
glEnd();
Also make sure lighting is enabled, as lighting is mandatory for materials to take effect. Also make sure you're calling color-material enables and setting (resp. glEnable(GL_COLOR_MATERIAL) and glColorMaterial(/*whatever*/)) at the right place. It's pretty hard to call color-material correctly. do you use that feature ?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement