Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making a light source visible in OpenGL

I want to move my light source in my OpenGL-Scene, which is working. But to actually I want to see thee light source as well.

How can I do this?

...
glPushMatrix();
GLfloat lightPos[]      = {0, 0, 200, 1};
glLightfv(GL_LIGHT0, GL_POSITION, lightPos);

GLfloat ambientLight[]  = { 0.2,  0.2,   0.2,  1.0};
GLfloat lightColor[]    = { 0.5,  0.5,   0.5, 1.0};

glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientLight);

glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor);          
glLightfv(GL_LIGHT0, GL_SPECULAR, lightColor);           
glutSolidSphere(5,50,50);
glPopMatrix();
...
like image 372
buddy Avatar asked Dec 09 '25 19:12

buddy


1 Answers

A light source is not a visible object, per se. If you want to "see" a light, you have to place some object at the position that your light is. Maybe use a sphere, a sprite, an arrow (pointing in the direction the light is pointing in, if it's a directional light), etc.

like image 89
Jim Buck Avatar answered Dec 12 '25 16:12

Jim Buck



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!