PDA

View Full Version : setting color/material of textured object



mikemor
09-29-2002, 09:21 AM
I need to paste a texture onto a sphere. I then want to give the sphere some color and have it with some emmisive and opacity components. I guess I need to use the texture functions?

Any hints on how to do it?

Thanks

nexusone
09-29-2002, 05:15 PM
Well if you apply a texture say from a file, it texture will give it color.
But if you can use just a colored sphere and change the material settings to get what you want.

Here is example of material setting, you will need to have lighting enable also:

glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT); // Adjust ambient
glColor4f(0.5, 0.5, 0.5, 1.0); amount of change to ambient.
glColorMaterial(GL_FRONT_AND_BACK, GL_EMISSION);
glColor4f(0.0, 0.0, 0.0, 1.0);
glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR);
glColor4f(0.25, 0.25, 0.25, 1.0);
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
glColor4f(1.0, 1.0, 1.0, 1.0);
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 80.0);


Hint the fouth value in the glColor, alpha value, lower the number the more transparent the object.


Originally posted by mikemor:
I need to paste a texture onto a sphere. I then want to give the sphere some color and have it with some emmisive and opacity components. I guess I need to use the texture functions?

Any hints on how to do it?

Thanks



[This message has been edited by nexusone (edited 09-29-2002).]

mikemor
09-30-2002, 04:31 AM
Thanks! Thats what I needed.

vincoof
09-30-2002, 05:03 AM
note: if you don't set all the color materials (for instance, if you *only* setup ambient, diffuse and emissive) then you'd better call glEnable(GL_COLOR_MATERIAL) after the first call to glColorMaterial.