在 OSX Big Sur 上使用 OpenGL 4.x 进行开发 [英] Develop using OpenGL 4.x on OSX Big Sur

查看:41
本文介绍了在 OSX Big Sur 上使用 OpenGL 4.x 进行开发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 Apple 的说法,OpenGL 是不再支持.但是,截至 7 月 28 日,似乎许多设备都支持 OpenGL v4.1 ,2020 年.我有一台 2020 年的 Macbook Pro 16"模型,它没有出现在上面提供的列表中.虽然我确信我的设备上存在某种形式的兼容性,但我不确定当现代版本被弃用时如何使用 OpenGL 进行开发.

According to Apple, OpenGL is no longer supported. However, it appears v4.1 of OpenGL was supported on many devices as of July 28, 2020. I have a 2020 Macbook Pro 16" model, which does not show up on the list provided above. While I am sure some form of compatibility exists on my device, I am unsure how I can develop with OpenGL when modern versions are deprecated.

我希望在运行 Big Sur 的 Macbook Pro 和我的 Windows 桌面之间进行开发.出于这个原因,我显然不希望关注特定于设备的库,例如 Direct3D 或 Metal.尽管 Apple 不直接提供支持,但是否可以使用较新版本的 OpenGL(例如 OpenGL 4.6)?我听说 AMD 显卡不能很好地与 OpenGL 配合使用,那么我还有什么选择?

I wish to be developing between my Macbook Pro running Big Sur and my Windows desktop. For this reason, I obviously do not wish to focus on a device-specific library such as Direct3D or Metal. Is it possible to work with newer versions of OpenGL (such as OpenGL 4.6) despite support not being directly provided by Apple? I've heard AMD video cards do not play well with OpenGL, so what options am I left with?

推荐答案

macOS 上的内置 OpenGL 的工作方式与 Windows 或 Linux 等其他平台略有不同.在 Windows 上,系统提供的 opengl32.dll 实际上并没有实现 OpenGL,而是从显卡供应商提供的驱动程序动态加载函数的代理库.显卡供应商提供独立于 Microsoft 的驱动程序,OpenGL 功能无需 Microsoft 批准即可实施.

Built-in OpenGL on macOS works a little bit different from other platforms like Windows or Linux. On Windows, system-provided opengl32.dll doesn't actually implement OpenGL but is rather a proxy-library dynamically loading functions from a driver provided by a graphics card vendor. Graphics card vendors provide drivers independently from Microsoft and OpenGL capabilities can be implemented without Microsoft approval.

相比之下,ma​​cOS 是更加封闭的系统,其中所有图形驱动程序都是系统的一部分,如果不更新系统本身,就无法(通常)更新.Apple 拥有对系统中 OpenGL 功能的完全控制权,并且没有向显卡供应商提供任何方式来向用户提供更多最新的 OpenGL 功能(即使他们的硬件在其他系统上支持这些功能).

In contrast, macOS is much more closed system, where all graphic drivers are part of the system and cannot be (normally) updated without updating system itself. Apple holds the full control over OpenGL functionality in system and doesn't give graphics card vendors any way to deliver users more up-to-date OpenGL features (even when their hardware supports them on other systems).

对于多平台软件的开发人员来说,这是非常不愉快的情况,因为 Apple 稳步推动他们的平台特定 API,例如 Metal 作为唯一选择,这意味着更强大的供应商锁定和/或更昂贵的开发.

This is quite unpleasant situation for a developer of multi-platform software, as Apple steadily pushes to their platform-specific APIs like Metal as the only choice, which implies a stronger vendor-lock and/or a more expensive development.

直接使用特定于平台的 API 的另一种方法是使用代理库在特定于平台的 API 之上实现多平台 API.到目前为止,目前已知的选项:

An alternative to using platform-specific APIs directly could be using a proxy-library implementing a multi-platform API on top of platform-specific API. So far, currently known options:

  • Apple 在 Metal 上的 OpenGL 实现.不幸的是,它一直停留在 OpenGL 4.1 上,并且没有理由期望该版本会长大;该库甚至可以在一些较新的 macOS 中删除.您可能已经注意到,现代 macOS 版本的系统库提供的信息提到了 Metal,因此它已经是其他图形 API 的包装器(尽管 Apple 可能会通过访问某些内部结构来作弊).
  • MoltenVK,一个开源的 Vulkan> 1.1 在 Metal 上的实现.这不是一个 OpenGL 库,但 Vulkan 是另一个多平台图形 API,一些参考资料表明,当前状态下的 MoltenVK 足以在实际项目中使用,并且 Vulkan 1.1 预计将提供比过时的 OpenGL 4.1 更多的功能(尽管,我无法亲自证实这一点,只是我的期望).
  • MoltenGL,一种基于 Metal 的闭源 OpenGL ES 2.0 实现.由于当前的实现仅限于 OpenGL ES 2.0(例如远低于 Apple 的内置 OpenGL/OpenGL ES 库),因此它看起来毫无用处...
  • Google ANGLE,一种开源 OpenGL ES 通过其他 API 实现.到目前为止,ANGLE 仅在 Metal 上实现了 OpenGL ES 2.0,在 Vulkan 上实现了 OpenGL ES 3.1(3.2 正在进行中).因此,如果层不会炸毁,那么像 MoltenVK 这样的更多层理论上可以提供更多;).然而,与 OpenGL 4.1 相比,即使是 OpenGL ES 3.2 看起来也不够好.还有 MetalANGLE - 添加 iOS 支持和一些额外功能的 ANGLE 库分支.
  • Zink,一个开源的 OpenGL 实现火神.Zink 已经在 Linux 上实现了 OpenGL 4.6(支持的 OpenGL 版本取决于公开的 Vulkan 功能和扩展).有一项正在进行的工作使这个 Mesa Gallium 驱动程序 工作 在 macOS 上的 MoltenVK 之上.
  • Apple's OpenGL implementation over Metal. Unfortunately, it has stuck on OpenGL 4.1, and there is no reason to expect the version will ever grow up; the library could be even removed in some newer macOS. You may already notice that information provided by a system library on modern macOS versions mentions Metal, so that it is already a wrapper over other graphics API (although Apple may cheat by accessing some internals).
  • MoltenVK, an open-source Vulkan 1.1 implementation over Metal. This is not an OpenGL library, but Vulkan is another multi-platform graphics API and some references tells that MoltenVK in current state is solid enough for using in real projects, and Vulkan 1.1 is expected to give more features than outdated OpenGL 4.1 (though, I cannot confirm this personally, just my expectations).
  • MoltenGL, a closed-source OpenGL ES 2.0 implementation over Metal. As current implementation is limited to OpenGL ES 2.0 (e.g. much lower than Apple's built-in OpenGL / OpenGL ES libraries), it looks quite useless...
  • Google ANGLE, an open-source OpenGL ES implementation over other APIs. So far, ANGLE implements only OpenGL ES 2.0 over Metal, and OpenGL ES 3.1 (3.2 in progress) over Vulkan. So that with more layers like MoltenVK it could theoretically give more, if layers will not blow up ;). However, even OpenGL ES 3.2 doesn't look good enough compared to OpenGL 4.1. There is also MetalANGLE - an ANGLE library fork adding iOS support and some extra features.
  • Zink, an open-source OpenGL implementation over Vulkan. Zink already implements OpenGL 4.6 on Linux (supported OpenGL version depends on exposed Vulkan features and extensions). There is a work-in-progress making this Mesa Gallium driver working on top of MoltenVK on macOS.

对我来说,如果您的应用程序可能会丢失一些需要更高版本 OpenGL 的功能,那么暂时坚持使用 OpenGL 4.1(由 Apple 提供)是一个不错的选择.尽管 Apple 已经弃用了 SDK 中的 OpenGL,但到目前为止,在较新的 macOS 更新中将在不久的将来实际将其删除似乎是不现实的;甚至 Apple M1 GPU 在 macOS 上获得了 OpenGL 4.1 支持大苏尔.不知道苹果是否有一些策略性的黑名单应用程序使用来自 AppStore 市场的弃用 API(例如系统将支持 OpenGL,但您将无法在 AppStore 上发布应用程序),但这可能会在未来成为一个问题.替代的 OpenGL 4.6 实现(在 Metal 之上或在 Vulkan-on-top-of-Metal 之上)可能会在不久的将来出现.

To me, it looks that sticking to OpenGL 4.1 (provided by Apple) for a while is quite a good option in case if your application may afford losing some features requiring higher version of OpenGL. Although Apple has deprecated OpenGL in SDK, so far it looks non-realistic that it will be actually removed in nearest future within newer macOS updates; even Apple M1 GPU received OpenGL 4.1 support on macOS Big Sur. Don't know if Apple has some strategy black-listing applications using deprecated APIs from AppStore market (e.g. system will support OpenGL, but you will not be able publishing application on AppStore), but this might become an issue in some future. Alternative OpenGL 4.6 implementations (on top of Metal or on top of Vulkan-on-top-of-Metal) might come in some distant future.

依赖 Vulkan-on-top-of-Metal 实现可能是最临时的选择,但肯定需要更多的努力来开发基于 Vulkan 而不是 OpenGL 的图形引擎.但是,无法评论当前的 MoltenVK 实现如何与 Windows 上相同图形硬件的本机 Vulkan 实现相媲美(按功能/性能/限制).当然,使用一些已经在多个图形 API(Vulkan/Metal/Direct3D/OpenGL/OpenGL ES)之上实现的现有图形引擎也会减轻您的维护负担,但这超出了初始问题的范围.

Relying on Vulkan-on-top-of-Metal implementations might be most provisional choice, but it will certainly require more efforts to develop a graphics engine on top of Vulkan instead of OpenGL. Cannot comment, though, how current MoltenVK implementation is comparable to native Vulkan implementations on Windows for the same graphics hardware (by features/performance/limitations). Of course, using some existing graphics engine already implemented on top of several graphics APIs (Vulkan/Metal/Direct3D/OpenGL/OpenGL ES) will also take this maintenance burden from you, but this is out of scope of initial question.

这篇关于在 OSX Big Sur 上使用 OpenGL 4.x 进行开发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆