How to get more infos about glError?

Hi all together,

I have a vertex and fragment shader, and both are working fine - but everytime I compile them I get the following OpenGL error: Invalid operation. That means that I am not allowed to do this operation in the current state - right?

Is there a way to get more infos about the OpenGl error? I do not understand that the shader is working but that i get this error…

I hope someone can help me,
greetings Simon

Each of the API calls for GLSL can give a GL_INVALID_OPERATION for different reasons - for example glUniform* can give it if the specified location is invalid, or if you try to load a sampler with something other than glUniform1i, while glUseProgramObjectARB will give a GL_INVALID_OPERATION if the specified object isn’t a valid program object, and so on. Your best bet is to comment out all your API calls except one and see if you’re still getting the error, and do this for each call on its own.

You can then check 3DLabs' API manual pages to find out why that particular function might be giving the error you’re getting.

thank you for your fast reply.

the OpenGL error is caused by the glCompileShaderARB(), for both, vertex and fragment shader. I compiled them in this way:

int installShaders( const GLcharARB *vertCode, const GLcharARB *fragCode) {
GLhandleARB vertexShader = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB); 
GLhandleARB fragmentShader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB); 

glShaderSourceARB(vertexShader, 1, &vertCode, NULL);
glShaderSourceARB(fragmentShader, 1, &fragCode, NULL); 


so I looked at the 3Dlabs site as you proposed an found the following error explanations for void glCompileShaderARB(GLhandleARB shader):

[i]GL_INVALID_OPERATION is generated if param shader is not of type GL_SHADER_OBJECT_ARB.

GL_INVALID_OPERATION is generated if glCompileShaderARB is executed between the execution of glBegin and the corresponding execution of glEnd.[/i]

the second is not the case in my code, but how can I be sure that the GLhandleARBs vertexShader and fragmentShader are of type GL_SHADER_OBJECT_ARB? Isn’t that automatically the case?

Well you could call glGetObjectParameter with parameters GL_OBJECT_TYPE_ARB and your shader objects, but I can’t see how they wouldn’t be valid shader objects since you just created them. Try it with GL_OBJECT_COMPILE_STATUS_ARB too and see if the compile was successful.

Also use glGetInfoLog to get info logs from both objects - that will tell you why they didn’t compile, if that’s the case. Once they’re compiled properly and attached and linked to your program object, you can use glGetInfoLog to check the link status, successful or not.

thank you for your help,

unfortunately I have not found a solution for this problem. My program coveres InfoLog an checks GL_OBJECT_COMPILE_STATUS_ARB, and there is no problem with that…

But if I check GL_OBJECT_TYPE_ARB for my vertex and fragmentShader I get another value than GL_OBJECT_TYPE_ARB, but you are right, I just created them before and therefore I do not understand whats the problem…

Well it should be returning GL_SHADER_OBJECT_ARB for both of those objects

ok, I checked it again and they have the same type, so unfotunately that’s not the problem :confused:

I think I will ignore the error message, because everything else does what it should…

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.