PDA

View Full Version : glmaterial



Ali S. Alfaraj
09-30-2010, 10:41 PM
Hello friends,

I'm using the glmaterial to change the colour of objects in a scene in openGl. The problem is that I want to change the colour of one object, but end up changing the colour of all objects in the scene. I used glPushMatrix and glPopMatrix, but it didn't help.
Hope you can help me,

Ali

Alfonse Reinheart
09-30-2010, 11:34 PM
glPushMatrix and glPopMatrix, as the names suggest, operate on matrices. Matrices do not affect color.

Just use whatever function you're using to change object color, but set it back after you've rendered the object.

Ali S. Alfaraj
10-01-2010, 12:57 AM
Thanks for the reply Alfonse,

You are right. But the thing is that I have several objects in the scene. Fore example, I have an object standing on a ground and I only want to change the colour this object. The glMaterial will cause the colour of both (object& ground) to change.
How to overcome that?

Alfonse Reinheart
10-01-2010, 01:12 AM
Change the color. Render the object you want to render in that color. Then change the color to the next object's color. Render that object. Keep doing that until you're out of objects.