Carbon 窗口上的 OpenGL 3.2 上下文(OS Lion、Mono)
我正在尝试将现代 OS X 支持添加到 OpenTK 框架。 Mac OS Lion 支持 OpenGL 3.2 Core 上下文。我可以使用 CGL 成功获取它。但是,我找不到将上下文绑定到 Carbon 窗口的直接方法。
以前的 OpenTK 实现使用 aglSetDrawable
方法。 CGL 没有公开提供替代方案,尽管它有类似的未记录的 CGLSetSurface。任何使用它的尝试都会返回错误代码 1001,我找不到该错误的描述。
在 Carbon 窗户上安装 GL 3.2 有什么帮助吗?
I'm trying to add modern OS X support to OpenTK framework.
Mac OS Lion supports OpenGL 3.2 Core context. I can successfully obtain it by using CGL. However, I can't find a straight way to bind the context to a Carbon window.
Previous OpenTK implementation used aglSetDrawable
method. CGL doesn't publicly have an alternative, even though it has a similar undocumented CGLSetSurface. Any attempts to use it return error code 1001, which I can't find a description for.
Any help of getting GL 3.2 on a Carbon window?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不能说我已经尝试过这个,但您也许可以通过使用包含 NSOpenGLView 的 HICOcoaView (它将采用可以从 CGLContext 创建的 NSOpenGLContext )来使其工作。
AGL 本身已被弃用,并且不太可能从 Apple 收到任何进一步的更新。 CGL 不适用于窗口上下文。从长远来看,使用 Cocoa 是 OS X 上的最佳途径。
I can't say I have tried this, but you might be able to get it to work by using a HICocoaView containing an NSOpenGLView (which will take an NSOpenGLContext that can be created froma CGLContext).
AGL itself is deprecated and unlikely to receive any further updates from Apple. CGL is not intended for windowed contexts. In the long run, using Cocoa is the best route on OS X.
正如其他人所指出的,Apple 不提供任何“官方”API 来将 CGL 上下文绑定到视图,而无需通过 NSOpenGLContext 中介(您甚至不需要创建完整的 NSOpenGLLView,您所需要的只是 NSOpenGLContext,您可以绑定到您选择的任何 NSView)。如果你只是想让事情顺利进行,这是最好的方法。
现在,如果您对未记录的方式感兴趣,请系好安全带:首先,Apple 为您提供的将 FBO 绑定到屏幕的唯一官方方式是通过 CGLSetFullScreenOnDisplay(),正如有人提到的apple.com/forums/thread/53878" rel="nofollow noreferrer">此处。但这还不是故事的结局。正如您所指出的,有一个
CGLSetSurface
,并且 XQuartz 在内部使用它(通过 Apple 提供的 libXplugin 库)将 opengl 上下文直接绑定到 CGWindow,而无需任何 cocoa 机器妨碍。正如邮件列表主题中提到的,我们还可以从 这篇文章。
幸运的是,其他人已经为我们做了一些逆向工程。您可以在 RetroArch 驱动程序中看到它们如下利用它:
另一个人在 https://handmade.network/forums/wip/t/2408-very_minimal_osx_platform_layer_experiments。
但请注意,当你这样做时,你会失去可可层给你带来的很多好处。像 hiDPI 缩放之类的东西不再“正常工作”,如果现代 macOS 上的 OpenGL 还没有得到足够的支持,那么绕过 Cocoa 层肯定会打破苹果对其兼容性层所做的任何假设。
As others have noted, Apple does not provide any "official" API to bind a CGL context to a view without going through the NSOpenGLContext intermediary (you don't even need to create a full NSOpenGLLView, all you need is the NSOpenGLContext which you can bind to any NSView of your choice). If you just want to get things working, that is the best approach.
Now if you're interested in the undocumented way, buckle up: First, the only official way Apple gives you to bind the FBO to a screen is via CGLSetFullScreenOnDisplay(), as someone mentioned here. But that's not the end of the story. As you noted there is a
CGLSetSurface
, and internally XQuartz uses this (via the libXplugin library that Apple provides) to bind an opengl context directly to a CGWindow without any cocoa machinery getting in the way. As mentioned in this mailing list threadWe can also learn more about the parameters it takes from this post.
Luckily others have already done some reverse-engineering for us. You can see in RetroArch drivers that they make use of this as follows:
and another person independently discovered the same in https://handmade.network/forums/wip/t/2408-very_minimal_osx_platform_layer_experiments.
But be aware that when you things like this, you lose a lot of the benefits that the Cocoa layer gives you. Things like hiDPI scaling no longer "just work", and if OpenGL on modern macOS wasn't unsupported enough, bypassing the Cocoa layer is surely going to break whatever assumptions Apple made for their compatibility layer.