glUseProgramObjectARB 无效操作错误
我在尝试使用 glUseProgramObjectARB
时收到“无效操作”错误,但我不知道为什么。
我相当确定着色器程序加载正确。这显示在 glGetInfoLogARB
上:
- 顶点着色器已成功编译以在硬件上运行。
- 片段着色器已成功编译并在此硬件上运行。
此命令之前没有先前的 openGL 错误。所以这个特定命令的某些东西肯定是问题所在。
我正在将glew 与SDL 一起使用。我之前用过GLee,也遇到了同样的问题。
阅读 文档 我认为是这样错误:
如果程序无法成为当前状态的一部分,则会生成 GL_INVALID_OPERATION。
但我不确定到底是什么导致了这样的事情。该命令是在工作的 openGL 上下文中发出的,因为之前的所有着色器命令都可以正常工作。它不在“开始”和“结束”块之间。
真的,我很困惑这可能意味着什么。也许存在一些更具体的情况,无法发出命令。如果有人知道更多的话那就太好了。
编辑:
已解决:哦天哪,这太迟钝了,我在其他地方错过了一个函数调用的返回,因此没有传回我构建的程序。
I'm getting an "invalid operation" error when trying to use glUseProgramObjectARB
and I have no idea why.
The shader programs are loading correctly, I'm fairly sure. This is shown on glGetInfoLogARB
:
- Vertex shader was successfully compiled to run on hardware.
- Fragment shader was successfully compiled to run on this hardware.
There are no previous openGL errors before this command. So something with this specific command definitely appears to be the issue.
I'm using glew with SDL. I was using GLee before, and getting the same problem.
Reading the documentation I assume it is this error:
GL_INVALID_OPERATION is generated if program could not be made part of current state.
but I'm not sure exactly what could cause such a thing. The command is issued in a working openGL context, as all the previous shader commands work fine. It is not between a "begin" and "end" block.
Really I am stumped as to what it could mean. Perhaps there is some more specific case when the command can't be issued. If anyone knows anything more that would be great.
EDIT:
Solved: oh jesus that was retarded, I was missing a return on one of my function calls elsewhere and so wasn't passing back the program I'd constructed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果没有看到您的代码,很难知道,但由于您明确提到了
glCompileShaderARB
的结果(乘以两倍)而不是glLinkProgramARB
我猜您忘记了glLinkProgramARB
(顺便说一下,之后您可以安全地glDeleteObjectARB
这两个着色器对象)。Without seeing your code it's hard to know, but since you explicitly mention the results of
glCompileShaderARB
(times two) but notglLinkProgramARB
I will guess that you forgot toglLinkProgramARB
(after which, by the way, you can safelyglDeleteObjectARB
the two shader objects).