View Full Version : Light Rotation using C++

05-06-2009, 03:33 AM
Hello,This is the first time for me to post in a forum and I hope that this will help me.
I need to ask how can I animate the light and make it rotate around a sphere..
I think it is easy but I can't get it
Thank u in advance

James A.
05-06-2009, 05:39 PM
There is a redbook sample for this here:


if you want to make the torus a sphere change the line that reads

glutSolidTorus (0.275, 0.85, 8, 15);

to something like this:

glutSolidSphere(1.0, 20, 20);

the part you are interested in is here:

glPushMatrix ();
glRotatef (spin, 1.0, 0.0, 0.0);
glLightfv (GL_LIGHT0, GL_POSITION, position);

glTranslated (0.0, 0.0, 1.5);
glPopMatrix ();

which rotates the light by spin degrees at a distance of 1.5 from the sphere.

05-08-2009, 12:46 AM
Thank u James very much =)