GLSL: Can't get uniforms location

孤街醉人 提交于 2019-12-05 10:49:28

The compiler is allowed to optimize away any unused uniforms, which is why you get this error.

You can safely ignore this. If the uniform isn't found, glGetUniformLocation returns -1. From the OpenGL 4.3 specs, section 7.6.1:

If the value of location is -1, the Uniform* commands will silently ignore the data passed in, and the current uniform values will not be changed.

This is an extension to Andreas's answer.

In my case, when I put glGetUniformLocation or glUniform* before glUseProgram, I got -1; however, when I put those two after glUseProgram, I can get the correct uniform location.

( My version is OpenGL 3.3, GLSL 3.30)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!