OpenGL错误下溢变成溢出?

发布于 2024-10-07 13:56:00 字数 580 浏览 0 评论 0原文

我正在开发一个仅使用 OpenGL 的项目(具体来说,它应该成为一款游戏),现在经过几周的开发,我偶然发现了使用 GL.GetError() 捕获 OpenGL 错误的可能性。代码>. 因为我不喜欢它只说明出了问题,但没有说明问题出在哪里,所以我想修复发生的错误。

所以这就是发生的事情: 启动应用程序时,有几个帧(三或四个)带有 StackUnderflow,它会切换到 StackOverflow 并保持这种状态。

我检查了 Matrix-Push-Pop 一致性,没有发现任何未封闭的矩阵。有趣的是,据我所知,照明不起作用(各个物体的所有面都具有完全相同的亮度)。

还有其他可能的原因吗?

(如果您想查看源代码,可以在:http://galwarcom .svn.sourceforge.net/viewvc/galwarcom/trunk/galwarcom/

I am working on a project which uses OpenGL only (it's supposed to become a game one time to be specific), now after some weeks of development I stumbled across the possibility to catch OpenGL errors with GL.GetError().
Since I dislike that it only says what went wrong but not where, I want to get the error that occurs fixed though.

So here is what happens:
When launching the app there are few frames (three or four) with StackUnderflow, it switches to StackOverflow and stays that way.

I checked my Matrix-Push-Pop consistency and didn't find any unclosed matrices. It might be interesting to know that, from what I see, lighting doesn't work (all faces of the various object have the very same brightness).

Is there any other possbile cause?

(If you want to see source, there is plenty at: http://galwarcom.svn.sourceforge.net/viewvc/galwarcom/trunk/galwarcom/ )

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

满地尘埃落定 2024-10-14 13:56:01

您需要在弹出之前设置矩阵模式,因为每种模式都有一个单独的堆栈。如果你做这样的事情,它会下溢:

glMatrixMode(GL_MODELVIEW)
glPushMatrix(); 
... stuff with model view ...
glMatrixMode(GL_PROJECTION)
glPushMatrix() 
... stuff with project matrix ...
glPopMatrix()  // projection popped
glPopMatrix()  // projection again

你正在drawHUD()中做类似的事情,可能是其他地方。

You need to set the matrix mode before popping since each mode has a separate stack. If you do something like this, it will underflow:

glMatrixMode(GL_MODELVIEW)
glPushMatrix(); 
... stuff with model view ...
glMatrixMode(GL_PROJECTION)
glPushMatrix() 
... stuff with project matrix ...
glPopMatrix()  // projection popped
glPopMatrix()  // projection again

You are doing something like this in drawHUD(), probably other places.

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