如何向 OpenGL 询问图形设备功能(texture2DArray、支持的抗锯齿模式)
我们使用 OpenTK、C# 和 Visual Studio 2010。我们需要询问图形设备是否支持texture2DArray,以及它可能支持哪些抗锯齿模式。任何帮助将不胜感激。
We are using OpenTK, C# and visual studio 2010. We need to ask the graphics device if it supports texture2DArray's, and what anti-aliasing modes it may support. Any help will be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对纹理数组的原始支持是 GL_EXT_texture_array 的一部分。这已作为 3.0 版本的一部分纳入 OpenGL Core。
因此,您可以检查您的 OpenGL 版本是否大于或等于 3.0,或者扩展字符串是否包含
GL_EXT_TEXTURE_ARRAY
。为了完成,您需要进行 2 个测试,因为可以通过任一方式提供支持(或者您可以决定仅在支持 OpenGL 3.0 的设备上运行)。对于多重采样问题,这是相当棘手的。多重采样历来是在平台级别完成的,因为它与帧缓冲区属性相关。我假设您的目标是 Windows 上的 GL,但我不知道这在 C# 中是如何完成的。
查看 http://www.opengl.org/wiki/Multisampling 了解相当复杂的方法在 C 中为初始帧缓冲区执行此操作
。现在...由于引入了帧缓冲区对象,核心 GL 还具有分配帧缓冲区的能力,包括多重采样表面(Core 3.0 中的第 4.4 节)。如果您使用此功能,则通过
glRenderbufferStorageMultisample
完成分配,并通过glGetIntegerv(GL_MAX_SAMPLES)
返回支持的最大样本数The original support for texture arrays is part of GL_EXT_texture_array. This has been rolled in to OpenGL Core as part of version 3.0.
So you can check that your OpenGL version is greater or equal to 3.0, or that the extension string contains
GL_EXT_TEXTURE_ARRAY
. To be complete, you need to do the 2 tests, as support could be exposed through either means (or you can decide to run only on OpenGL 3.0 capable devices).For the multi-sampling question, it's rather trickier. multi-sampling has historically been done at the platform level, since it was associated with the framebuffer properties. I'm assuming you're targeting GL on windows, but I'm not aware of exactly how this is done in c#.
Check out http://www.opengl.org/wiki/Multisampling for the rather convoluted ways of doing this for the initial framebuffer in C.
Now... Since framebuffer objects were introduced, the core GL also has the capability to allocate framebuffers, including multi-sampled surfaces (section 4.4 in the Core 3.0). If you use this functionality, then the allocation is done with
glRenderbufferStorageMultisample
, and the maximum number of samples that is supported is returned throughglGetIntegerv(GL_MAX_SAMPLES)