I keep encountering this same issue, no matter what I do within the program, the error is:
Error linking shader program: Fragment info
-------------
0(8) : error C5052: gl_Position is not accessible in this profile
And I saw one other topic here about this issue, but he said he fixed it himself and didn’t explain how.
My shader class code is:
void Shader::add(GLuint ShaderProgram, const char* pShaderText, GLenum ShaderType) {
GLuint ShaderObj = glCreateShader(ShaderType);
if (ShaderObj == 0) {
std::cerr << "Error creating shader type " << ShaderType << std::endl;
exit(0);
}
const GLchar* p[1];
p[0] = pShaderText;
GLint Lengths[1];
Lengths[0]= strlen(pShaderText);
glShaderSource(ShaderObj, 1, p, Lengths);
glCompileShader(ShaderObj);
GLint success;
glGetShaderiv(ShaderObj, GL_COMPILE_STATUS, &success);
if (!success) {
GLchar InfoLog[1024];
glGetShaderInfoLog(ShaderObj, 1024, NULL, InfoLog);
std::cerr << "Error compiling shader type " << ShaderType << ": " << InfoLog << std::endl;
exit(1);
}
glAttachShader(ShaderProgram, ShaderObj);
}
GLuint Shader::compile() {
GLuint ShaderProgram = glCreateProgram();
if (ShaderProgram == 0) {
std::cerr << "Error creating shader program" << std::endl;
exit(1);
}
this->add(ShaderProgram, vs, GL_VERTEX_SHADER);
this->add(ShaderProgram, fs, GL_FRAGMENT_SHADER);
GLint Success = 0;
GLchar ErrorLog[1024] = { 0 };
glLinkProgram(ShaderProgram);
glGetProgramiv(ShaderProgram, GL_LINK_STATUS, &Success);
if (Success == 0) {
glGetProgramInfoLog(ShaderProgram, sizeof(ErrorLog), NULL, ErrorLog);
std::cerr << "Error linking shader program: " << ErrorLog << std::endl;
exit(1);
}
glValidateProgram(ShaderProgram);
glGetProgramiv(ShaderProgram, GL_VALIDATE_STATUS, &Success);
if (!Success) {
glGetProgramInfoLog(ShaderProgram, sizeof(ErrorLog), NULL, ErrorLog);
std::cerr << "Invalid shader program: " << ErrorLog << std::endl;
exit(1);
}
glUseProgram(ShaderProgram);
return ShaderProgram;
}
I have checked to make sure that the shader code (variables vs and fs) contain the correct code, although I haven’t yet checked glGetShaderSource to see if it is correct in the object