Hi Chaps,
I’m new to the forums and programming in general.
At the moment I’m trying to move a light around my scene but unfortunatley, there’s no visual representation of it. I was wondering if there was perhaps a method I could use to indicate it’s position when rendering.
My code is below:
static void lighting (void)
{
GLfloat light_position[] = {10.0,0.0,0.0,0.0};
GLfloat ambi[] = {0.1, 0.1, 0.1, 0.1};
GLfloat lightZeroColor[] = {0.9, 0.9, 0.9, 0.1};
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glLightfv(GL_LIGHT0, GL_AMBIENT, ambi);
glLightfv(GL_LIGHT0, GL_DIFFUSE, lightZeroColor);
//glDisable( GL_LIGHTING );
}
Any help would be appriciated,
MasterDunx
Just draw a sphere or whatever where the light is.
i think you need some code to add.like object Materials.
here is my code.
gluSpHere();//it is not total but i forget how to write-_-
glMaterialfv(GL_FRONT_AND_BACK,GL_SHINESS,100);
glMaterialfv(GL_FRONT,GL_SPECULAR,mat->diffuse);
Cool, but how would I specify the sphere’s position to be in aligned with the light?
you needed to aligened your light,
here i post you simeple example i had write.
glDisable(GL_LIGHT0);
glLightfv(GL_LIGHT0, GL_POSITION, light_position1);
glEnable(GL_LIGHT0);
you could just declare a global variable wich is used in the light pos settings and the object pos settings
You object is simply at the same position defined with
glLightfv(GL_LIGHT0 + i, GL_POSITION, m_lightPos );
glDisable( GL_LIGHTING );
glPushMatrix();
glTranslatefv( lightPos );
//Draw your preferred shape for the light source
glPopMatrix();
glEnable( GL_LIGHTING );