I have a problem validating my shader program in LWJGL/OpenGL 3.
I read the documentation, but I can't seem to find a reason why a VAO is needed when calling glValidateProgram.
int program = glCreateProgram();
int vertexShader = glCreateShader(...);
int fragmentShader = glCreateShader(...);
// ... vertex and fragment shader loading, compiling, errorchecking ...
glAttachShader(program, vertexShader);
glAttachShader(program, fragmentShader);
glBindAttribLocation(program, 0, "position");
glBindAttribLocation(program, 1, "color");
glLinkProgram(program);
glDetachShader(program, shader);
glDetachShader(program, shader);
glValidateProgram(program);
if (glGetProgrami(program, GL_VALIDATE_STATUS) != GL_TRUE)
System.exit(-1);
This exits the program without any error message.
GL_LINK_STATUS is OK and GL.getErrors() also has nothing to report.
But when creating a VAO around glValidateProgram it works just fine.
I can also just ignore the fact that glGetProgrami returns GL_FALSE and just run the shader program.
What i mean with creating a VAO around glValidateProgram():
int vao = glGenVertexArrays();
glBindVertexArray(vao);
glValidateProgram(program);
if (glGetProgrami(program, GL_VALIDATE_STATUS) != GL_TRUE)
System.exit(-1);
glDeleteVertexArrays(vao);
When I do this, GL_VALIDATE_STATUS is true and I can draw my stuff.
The used shaders are simple passthrough shaders.
The vertex shader returns the position and the fragment shader returns the color.
So, why do I have to bind an VAO even though I can immediately delete it after the validation?
This behavior matches the OpenGL spec. I'm using the OpenGL 3.3 spec as reference.
In appendix E.2.2 "Removed Features" on page 344, it says:
The spec for
glValidateProgram()
on page 82 says:So because issuing a draw command without a VAO bound will given a
GL_INVALID_OPERATION
error, andglValidateProgram()
checks if a draw command would give aGL_INVALID_OPERATION
error, what you're seeing is exactly as expected.