still me I have a new problem. I create a light source and I would like that it stays at the same place after a translation or a rotation. Should I put glLightfv inside the display function or outside (in init function for example). If someone could show me a general structure of an openGL program(what in display, what in init,…) it would be great.
Originally posted by zip7000: I create a light source and I would like that it stays at the same place after a translation or a rotation. Should I put glLightfv inside the display function or outside (in init function for example).
Light positions are modified by the modelview matrix, so translations and rotations affect them, as they were a simple point.
You must call glLightfv once if you aren’t going to change light’s properties. That is: you don’t need to call glLightfv() every frame.
[QUOTE]Originally posted by Azdo:
[b] Light positions are modified by the modelview matrix, so translations and rotations affect them, as they were a simple point.
is there a way so that the translation, and rotation doesn’t affect the light?
Thank you V-man. I have another problem. I would like to apply materials property just for one object. I create a material function and I call this material function when I dra the object but all the objects are affected by the material properties. why?
here is my materials function
// materials
void materials()
{
glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT, ambient);
glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE, diffuse);
glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR, specular);
}
Any call to glMaterial*() remain in effect until glMaterial*() is called again with parameters to change what was initially changed. So either you call glMaterial*() again to recover from the change or you use glPush/Pop() to preserve the material settings after you’ve finished drawing the desired object. Unfortunately I can’t remember the actual Push/Pop combination. Its something like glPushAttrib/glPopAttrib(GL_CURRENT_BIT).