glUseProgramObjectARB 无效操作错误

发布于 2024-11-03 06:39:55 字数 747 浏览 4 评论 0原文

我在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小梨窩很甜 2024-11-10 06:39:55

如果没有看到您的代码,很难知道,但由于您明确提到了 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 not glLinkProgramARB I will guess that you forgot to glLinkProgramARB (after which, by the way, you can safely glDeleteObjectARB the two shader objects).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文