OpenGL Shader error 1282

前端 未结 2 1300
野趣味
野趣味 2021-01-01 16:43

I am trying to add lighting to my current scene of a simple cube. After setting up my uniforms I get a 1282 error from glGetError() for this piece of code

GL         


        
相关标签:
2条回答
  • 2021-01-01 17:10

    Error number ´1282` is not very descriptive.

    Possible error codes for glGetUniformLocation are:

    GL_INVALID_VALUE
    GL_INVALID_OPERATION
    

    Which don't have a fixed value. Try to get the error string with gluErrorString() or take a look in the header to which of those 1282 maps.

    Just a shot in the dark: but did you ...

    • check your shader got compiled without error?

    • check your shader got linked without error?

    BTW: return type is GLint not GLuint

    "Shaders compiled and linked without error" Hmm, this looks odd.

    According to spec (see: http://www.opengl.org/sdk/docs/man/xhtml/glGetUniformLocation.xml) GL_INVALID_OPERATION should only be generated if:

    • program is not a program objec

    • program has not been successfully linked

    Other question:

    • are you sure the getHandle()method of the class your program Object belongs to returns the right id. I mean the one that was used in the sucessfully linking.

      you should be able to verify with checking if glIsProgram(program-getHandle()) returns GL_TRUE

    EDIT: Ah - I missed those calls to glUniform4fv in your example.

    Correct return type for glGetUniformLocation is still GLint, but I don't think thats the problem.

    According to spec (see: http://www.opengl.org/sdk/docs/man/xhtml/glUniform.xml) GLUniformXX generates GL_INVALID_OPERATION for a whole bunch of reasons. To me the only one that possibly seems to apply is:

    • there is no current program object

      Did you call glUseProgram (program->getHandle()) prior to trying to calling glUniform()?

    0 讨论(0)
  • 2021-01-01 17:22

    Generally this error number occurs when you are using a different programID from the programID generated by openGL at the time of creating the shader. It means that you are using a different programID at the time of binding vertexShader or fragmentShader or whatever other shader you are using.

    0 讨论(0)
提交回复
热议问题