What does glUseProgram(0) do?

后端 未结 4 1000
暖寄归人
暖寄归人 2021-02-05 08:51

The OpenGL docs for glUseProgram claim that calling it with an argument of zero will cause the results of shader execution to be undefined.

However

4条回答
  •  广开言路
    2021-02-05 09:12

    glUseProgram means that the given program object is the current program that will be used for things that use programs (glUniform, rendering commands, etc). 0 is a lot like NULL for OpenGL objects. It represents not an object (for most objects). Therefore, glUseProgram(0) means that no program is current, and therefore no program will be used for things that use programs.

    If you attempt to call the glUniform functions when no program is current, they will fail with an error. If you attempt to render when no program is current, one of two things will happen.

    • In OpenGL 3.1+, core profile, you will get a GL_INVALID_OPERATION error, because core OpenGL must render with a program.
    • In compatibility profiles or version 3.0 or less, you will get fixed-function rendering.

提交回复
热议问题