View Full Version : light
05-06-2002, 10:34 AM
still me http://www.opengl.org/discussion_boards/ubb/smile.gif 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.
thank you for any help you can give!!
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.
05-07-2002, 12:00 PM
[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?
05-07-2002, 12:54 PM
glLightfv(GL_LIGHTX, GL_POSITION, positionarray);
and so on.
or just keep modelview as identity.
05-07-2002, 01:15 PM
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
05-10-2002, 07:46 AM
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).
Material properties belongs to the lighting attribute group, so
will save the current material color, including all other lighting related stuff of course.
But, if you are unsure which attribute groupe a certain state belongs to, this will always work http://www.opengl.org/discussion_boards/ubb/biggrin.gif
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.