Jump to content
  • Advertisement
Sign in to follow this  
Tokage

Model / Material Woes

This topic is 5151 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!