将 GLfloat 作为统一传递失败(ios)
我有一个着色器,声明了以下制服:
uniform highp float fr;
在我的渲染方法中,它被相应地设置:
GLfloat num = 1.0f;
glUniform1f(glGetUniformLocation(self.Program, "fr"), num);
但它根本没有被设置。这些看起来很基本,所以我不明白为什么它不起作用。 我使用了正确的语法吗?
I have a shader that has the following uniform declared:
uniform highp float fr;
In my rendering method, it gets set accordingly:
GLfloat num = 1.0f;
glUniform1f(glGetUniformLocation(self.Program, "fr"), num);
But it doesn't get set at all. These seems pretty basic so I can't spot why it isn't working.
Have I used the correct syntax?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许您没有在着色器代码中使用这个 fr 值?然后编译器会将其设置为非活动统一,并且不会真正将其包含在编译的程序中,glGetUniformLocation 将返回类似 -1 左右的索引。检查您的着色器以及 glGetUniformLocation 返回的值是什么。
干杯,
克日什托夫·扎布沃茨基
Maybe you are not using this fr value in shader code? Then compiler would make it inactive uniform and not really include it in compiled program, glGetUniformLocation would return index like -1 or so. Check your shader and what value is returned by glGetUniformLocation.
Cheers,
Krzysztof Zabłocki
我已经找到我的问题了。
我在调用使用程序之前设置了制服。对于找到此答案的任何人,请确保在为该程序设置制服之前调用使用程序。
I have found my issue.
I was setting the uniform before calling use program. For anyone that finds this answer, ensure you call use program before setting the uniform for that program.