PDA

View Full Version : Link Error - Not Accessible In Profile



Firehazard
01-19-2015, 08:09 PM
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

Firehazard
01-21-2015, 02:45 PM
Nevermind, I found it out myself.

bugmenot
02-24-2015, 03:11 AM
And I saw one other topic here about this issue, but he said he fixed it himself and didn't explain how.

And then you thought to yourself: "Hey, I should do exactly the same thing!!!" because apparently there weren't already enough dead ends for people googling this error message?


edit: Ok, found it. Was looking in all the wrong places :D

The word "profile" in this error message simply seems to mean "shader type" (as in fragment, vertex, etc).

If you're having a hard time figuring out why you're getting this error even though you looked over your shader source a hundred times, then that's probably because the variables referring to the shader source got mixed up somewhere and the program is trying to (i.E.) use your fragment shader source as vertex shader (well, thank you, IDE auto completion... "shaderSourceFrag()" was *almost* what I wanted to write there *sigh*).