问题:Mac OS X 10.6 上的 OpenGL 渲染停止

发布于 2024-10-25 03:41:54 字数 642 浏览 1 评论 0原文

我一直遇到问题,在花了一周时间尝试各种解决方案并撕扯我的头发之后,我来到这里看看是否有人可以帮助我。

我正在为 Mac 开发一款 3D 浏览器插件(我有一个可以在 Windows 上运行的插件)。执行此操作的唯一全硬件加速方法是使用 CAOpenGLLayer(或从中继承的东西)。如果创建了 NSWindow 并将图层附加到该窗口的 NSView,那么一切都会正常工作。但是,由于某种原因,当将图层传递到浏览器时,我只能获取特定数量的帧 (16) 进行渲染。

Cocoa 在前 16 帧中调用我的图层的drawInCGLContext。然后,由于某种未知的原因,它停止调用它。 16 似乎是一个非常具体且程序化的帧数,因此我想知道是否有人了解为什么在 16 帧后不会调用drawInCGLContext?

我相当确定这不是因为我将图层传递到浏览器中 - 我创建了一个非常小的示例插件,它使用 CAOpenGLLayer 渲染旋转四边形,并且实际上有效。但完整的插件比这复杂得多,我只是不知道该去哪里寻找。我只是不知道为什么drawInCGLContext 停止被调用。我尝试使用 CATransaction 强制它,它肯定会发送 setNeedsDisplay 消息 - 但drawInCGLContext 从未被调用。 OpenGL 也不报告任何错误(我当前正在检查所有 OpenGL 调用的结果)。我很困惑!帮助?

I've been having problems and, after spending a week trying out all kinds of solutions and tearing my hair out, I've come here to see whether anybody could help me.

I'm working on a 3D browser plugin for the Mac (I have one that works on Windows). The only fully-hardware accelerated way to do this is to use a CAOpenGLLayer (or something that inherits from that). If a NSWindow is created and you attach the layer to that window's NSView then everything works correctly. But, for some reason, I can only get a specific number of frames (16) to render when passing the layer into the browser.

Cocoa calls my layer's drawInCGLContext for the first 16 frames. Then, for some unknown reason, it stops calling it. 16 seems like a very specific - and programmatic - number of frames and so I wondered whether anybody had any insight into why drawInCGLContext would not be called after 16 frames?

I'm reasonably sure it's not because I pass the layer into the browser - I've created a very minimal example plugin that renders a rotating quad using CAOpenGLLayer and that actually works. But the full plugin is a lot more complicated than that and I just don't know where to look anymore. I just don't know why drawInCGLContext stops being called. I've tried forcing it using CATransaction, it definitely gets sent the setNeedsDisplay message - but drawInCGLContext is never called. OpenGL doesn't report any errors either (I'm currently checking the results of all OpenGL calls). I'm confused! Help?

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

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

发布评论

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

评论(1

不顾 2024-11-01 03:41:55

因此,对于将来遇到此问题的任何其他人:您正在尝试使用 drawInCGLContext 之外的 OpenGL 上下文进行绘制。代码中存在一个错误,几乎所有绘图都是从正确的位置(drawInCGLContext)发生的,但一个代码路径导致它在该位置之外渲染。

不会引发任何错误,glGetError 也不会返回任何问题。它只是停止渲染。因此,如果这种情况发生在您身上 - 您几乎肯定会犯我所犯的同样错误!

So, for anybody else who has this problem in future: You're trying to draw using the OpenGL context outside of the drawInCGLContext. There was a bug in the code where nearly all the drawing was happening from the correct place (drawInCGLContext) but one code path led to it rendering outside of there.

No errors are raised nor does glGetError return any problems. It just stops rendering. So if this happens to you - you're almost certainly making the same mistake I made!

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