"invalid operation" 关于着色器加载和编译

"invalid operation" on shader loading and compiling

问题

a.vs 中有一个着色器程序为:

#version 330
in vec2 vPosition;
void main() {
    gl_Position = vec4(vPosition, 0.0, 1.0);
}

并给出:

import qualified Graphics.GLUtil as GLU
import qualified Graphics.Rendering.OpenGL as GL

这一行:

vs <- GLU.loadShader GL.VertexShader $ shaderPath </> "a.vs"

原因:

GL: Error InvalidOperation "invalid operation"

在运行时。

详情

我 运行 Mac OS X 10.10.2。 OpenGL 上下文通过 GLFW 设置:

GLFW.windowHint $ GLFW.WindowHint'OpenGLDebugContext True
GLFW.windowHint $ GLFW.WindowHint'ContextVersionMajor 3
GLFW.windowHint $ GLFW.WindowHint'ContextVersionMinor 3
GLFW.windowHint $ GLFW.WindowHint'OpenGLForwardCompat True
GLFW.windowHint $ GLFW.WindowHint'OpenGLProfile GLFW.OpenGLProfile'Core

提供 OpenGL 3.3 上下文。

代码的上下文可以在这个 repository 中找到(link 到特定的提交),特别是在 Main.hs.

问题

如何解决此问题或获取更多调试信息?

我 运行 你的代码在 gDebugger 下,它很清楚:

GL.matrixMode $= GL.Projection
GL.loadIdentity
GL.ortho2D 0 (realToFrac w) (realToFrac h) 0

这段剩余的代码触发了错误状态:

Error-Code: GL_INVALID_OPERATION

Error-Description: The specified operation is not allowed in the current state. The offending function is ignored, having no side effect other than to set the error flag.

附带说明一下,着色器编译永远不会触发 INVALID_OPERATION(除非您尝试使用损坏的管道进行渲染);编译错误可以直接查看编译状态得到。