简体   繁体   English

在OpenGL中使光源可见

[英]Making a light source visible in OpenGL

I want to move my light source in my OpenGL-Scene, which is working. 我想在我的OpenGL-Scene中移动我的光源,这是有效的。 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();
...

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. 也许使用球体,精灵,箭头(指向光指向的方向,如果它是定向光)等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM