Sign in to follow this  

Model / Material Woes

This topic is 4842 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
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 ?

Share this post


Link to post
Share on other sites

This topic is 4842 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this