OpenGL - 光值和位置
这就是我声明我的光值的方式,他们的立场
是正确的还是有其他更正式的方式?
// Lighting values
GLfloat greenLight[] = { 0.0f, 0.6f, 0.0f, 1.0f };
GLfloat redLight[] = { 0.6f, 0.0f, 0.0f, 1.0f };
GLfloat blueLight[] = { 0.0f, 0.6f, 0.0f, 1.0f };
GLfloat whiteLight[] = { 0.2f, 0.2f, 0.2f, 1.0f };
GLfloat sourceLight[] = { 0.9f, 0.9f, 0.9f, 1.0f };
GLfloat lightPos[] = { 0.0f, 0.0f, 0.0f, 1.0f };
GLfloat lightPos1[] = { 5.0f, -5.0f, 0.0f, 0.0f };
GLfloat lightPos2[] = { -5.0f, 5.0f, 0.0f, 0.0f };
GLfloat lightPos3[] = { 5.0f, 5.0f, 0.0f, 0.0f };
This is how i have declared my light values and their positions
is this correct or is there another more officiant way?
// Lighting values
GLfloat greenLight[] = { 0.0f, 0.6f, 0.0f, 1.0f };
GLfloat redLight[] = { 0.6f, 0.0f, 0.0f, 1.0f };
GLfloat blueLight[] = { 0.0f, 0.6f, 0.0f, 1.0f };
GLfloat whiteLight[] = { 0.2f, 0.2f, 0.2f, 1.0f };
GLfloat sourceLight[] = { 0.9f, 0.9f, 0.9f, 1.0f };
GLfloat lightPos[] = { 0.0f, 0.0f, 0.0f, 1.0f };
GLfloat lightPos1[] = { 5.0f, -5.0f, 0.0f, 0.0f };
GLfloat lightPos2[] = { -5.0f, 5.0f, 0.0f, 0.0f };
GLfloat lightPos3[] = { 5.0f, 5.0f, 0.0f, 0.0f };
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上没有任何其他方法可以使用固定功能 OpenGL 来实现这一点。设置参数只是照明成本的一小部分。如果您想要更高效的东西,我建议您学习未弃用的 OpenGL 并在着色器中实现照明,这可能比固定功能照明更快。
There really isn't any other way to do it using fixed-function OpenGL. Setting the parameters is a small part of the cost of lighting. If you want something more efficient, I would recommend you learn non-deprecated OpenGL and implement lighting in a shader, which will probably be faster than fixed-function lighting.