Advertisement Jump to content
Sign in to follow this  

OpenGL glLinkProgram() - success with error ???

This topic is 4473 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In an OpenGL program I am writing/testing, glLinkProgram() generates an error, but returns success == true when GL_LINK_STATUS is tested. Anyone know why? The following is cut from the code in question. Note that every glGetError() except the one following glLinkProgram() returns zero (no error). Also note, glGetProgramiv (program, GL_LINK_STATUS, &success) immediately following this line returns success = true, so the if (success == 0) block does not execute. The error returned is 0x0502 == GL_INVALID_OPERATION. One GLSL reference sez this means the program object is not valid, but none of the other functions that receive this same program variable in an argument complain - plus the shader clearly is being installed and is running (and works almost perfectly). Anyone understand this? In case you wonder what my function is doing just before glLinkProgram(): 1: specify 5 shader attribute variables in 5 glVertexAttribPointer() calls 2: enables these attributes with 5 glEnableVertexAttribArray() calls 3: make sure #2 worked with 5 glGetVertexAttribPointerv() calls 4: bind names to these locations with 5 glBindAttribLocation() calls 5: consistency check with 5 glGetAttribLocation() calls None of the above generates errors, and it all obviously works. Here is the code that generates error plus success from glLinkProgram(): program = glCreateProgram (); // create "program object" error = glGetError (); glAttachShader (program, vshader); // attach vertex shader to program error = glGetError (); glAttachShader (program, pshader); // attach pixel shader to program error = glGetError (); error = ig_shader_setup (program, vshader, pshader, 0); if (error < 0) { return (error); } // generates 0x000 == no error (my code) glLinkProgram (program); // link program object error = glGetError (); // generates 0x0502 == INVALID_OPERATION glGetProgramiv (program, GL_LINK_STATUS, &success); error = glGetError (); // generates 0x0000 == no error if (success == 0) { // does not execute cuz success == true glGetProgramiv (program, GL_INFO_LOG_LENGTH, &ebytes); // and so forth }

Share this post

Link to post
Share on other sites
Nope, it was me (not OpenGL) who made an "error with success".
At the end of ig_shader_setup() the glGetAttribLocation() function
was called to see whether the just-completed glBindAttribLocation()
calls generated valid locations. As it turns out, locations cannot
be valid until the program is linked. The error was still pending
from those glGetAttribLocation() calls. It didn't matter to my code
because I repeated the glGetAttribLocation() calls further down, well
after glLinkProgram(). So never mind, sorry I scratched your head.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!