当我为顶点着色器调用glCompileShader()并使用glGetShaderiv获取状态时,它返回false。但是,当我查看日志时,它是空的。我是着色器的新手,所以我确定我做错了什么。这是我的代码:
control
顶点着色器程序:
control-c
我知道它正确加载着色器程序,只是在编译时失败。
编辑:这是调用compileShader的代码
void GLSLProgram::compileShader(const std::string& filePath, GLuint id)
{
/*Shader Program Reading*/
//don't worry about this \/, it just loads my shader program from the file.
std::string shader = gdcUtil::implode(gdcFile::readBlock(filePath, 0, 0, '\n', 0, true), true);
const char* shaderPtr = shader.c_str();
/*Shader Source Refering*/
glShaderSource(id, 1, &shaderPtr, nullptr);
/*Shader Compiling*/
glCompileShader(id);
GLint success = 0;
glGetShaderiv(id, GL_COMPILE_STATUS, &success);
if (success == GL_FALSE) {
//Setup Error Log
GLint maxLength = 0;
glGetShaderiv(id, GL_INFO_LOG_LENGTH, &maxLength);
std::vector<char> errorLog(maxLength);
glGetShaderInfoLog(id, maxLength, &maxLength, &errorLog[0]);
std::string log;
for (int i = 0; i < errorLog.size(); i++) {
log += errorLog[i];
}
gdcUtil::error(log, "GD_GLSL");
glDeleteShader(id);
gdcUtil::quit();
}
}