下面只谈在光源处画球与移动光源的方法,不贴全部代码,所有具体代码以及教程见我的 github : https://github.com/David-Guo/OpenGLTrain/tree/master/hw3%28Buffer%29
在光源处画球
// postion[3] 为光源所在坐标
glPushMatrix();
glDisable(GL_LIGHTING);
glTranslatef(position[0], position[1], position[2]);//移动绘图原点到光源处
glColor3f (1.0f, 1.0f, 0.0f); //设置球的颜色为黄色
glutSolidSphere(0.5f, 50.0f, 50.0f); //绘制球
glEnable(GL_LIGHTING);