WARN:变量不能绑定(它要么不存在,要么已经被优化掉了)

WARN: Variable cannot be bound (it either doesn't exist or has been optimized away)

本文关键字:优化 掉了 不存在 绑定 不能 WARN 变量      更新时间:2023-10-16

我试图传递一个变量timeVar(一个浮点数最初设置为0.0),它在我的display()方法中改变了

timeVar = time(0);

到我的片段着色器。然后写入

safe_glUniform1f(h_uTime, timeVar); 
并将其传递给我的着色器程序,像这样
h_uTime = safe_glGetAttribLocation(h_program, "uTime");

但是我一直得到这个错误。请帮助!

WARN: uTime cannot be bound (it either doesn't exist or has been optimized 
away). safe_glAttrib calls will silently ignore it.

由于uTime是统一的而不是属性,使用glGetAttribLocation总是会导致错误。必须使用glGetUniformLocation