In my createShaderProgram method after glLinkProgram(pID) and glValidateProgram(pID) i have some simple error checking.
int errorCheckValue = glGetError();
if(errorCheckValue != GL_NO_ERROR)
{
System.err.println("Could not create shaders " + GLU.gluErrorString(errorCheckValue));
//System.exit(-1);
}
This peace of code fire an error message --> Could not create shaders Invalid operation. Because i commented System.exit(-1) everything works fine but i dont know why this error occurs. Is there any way of code some error handling function that is more specific about the error - something more specific than just Invalid operation?
EDIT: Here is the rest of the code
private static int createShader(String source, int shaderType)
{
int shaderID = 0;
shaderID = glCreateShader(shaderType);
glShaderSource(shaderID, source);
glCompileShader(shaderID);
if(glGetShaderi(shaderID, GL_COMPILE_STATUS) == GL_FALSE)
{
System.err.println("Shader failed to compile!");
System.err.println(glGetShaderInfoLog(shaderID, 2048));
System.exit(-1);
}
return shaderID;
}
public static int[] createShaderProgram(String vertFilename, String fragFilename, Attribute locations[])
{
int pID, vertID, fragID = 0;
pID = glCreateProgram();
vertID = createShader(FileUtils.loadFileAsString(vertFilename), GL_VERTEX_SHADER);
fragID = createShader(FileUtils.loadFileAsString(fragFilename), GL_FRAGMENT_SHADER);
glAttachShader(pID, vertID);
glAttachShader(pID, fragID);
for(int i = 0; i < locations.length; i++){locations[i].bindAttribute(pID);}
glLinkProgram(pID);
glValidateProgram(pID);
int errorCheckValue = glGetError();
if(errorCheckValue != GL_NO_ERROR)
{
System.err.println("Could not create shaders " + GLU.gluErrorString(errorCheckValue));
//System.exit(-1);
}
int[] result = new int[] {pID, vertID, fragID};
return result;
}