【发布时间】:2016-09-22 11:16:22
【问题描述】:
我出于教育目的编写 glsl 包装器,但因为我有一些误解而停止了。当我想将变量插入特定位置时,我会收到不匹配警告。因为location是GLint,但是glVertexAttrib location必须是GLuint。
这是我的代码示例
bool Material::AddAttrib(GLchar *variable, std::vector<GLdouble> values) {
GLint location = glGetAttribLocation(program,variable);
GLenum error = glGetError();
bool isNor = PrintError(error);
if(!isNor) return isNor;
switch (values.size()) {
case 1:
glVertexAttrib1d(location, values.at(0));
break;
case 2:
glVertexAttrib2d(location, values.at(0), values.at(1));
break;
case 3:
glVertexAttrib3d(location, values.at(0), values.at(1), values.at(2));
break;
case 4:
glVertexAttrib4d(location, values.at(0), values.at(1), values.at(2), values.at(3));
break;
default:
PrintErrorSize();
return false;
}
error = glGetError();
isNor = PrintError(error);
return isNor;
}
【问题讨论】: