PDA

View Full Version : How could I put a visual marker to show lights?



MasterDunx
03-18-2010, 09:21 AM
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

Rosario Leonardi
03-18-2010, 01:59 PM
Just draw a sphere or whatever where the light is.

beginnertom
03-19-2010, 12:16 AM
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);

MasterDunx
03-19-2010, 03:10 AM
Cool, but how would I specify the sphere's position to be in aligned with the light?

beginnertom
03-19-2010, 03:43 AM
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);

rats_ogl
03-19-2010, 04:03 AM
you could just declare a global variable wich is used in the light pos settings and the object pos settings

Ehsan Kamrani
03-19-2010, 04:12 AM
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 );