gpt4 book ai didi

c++ - 如何检测opengl是运行在Desktop还是ES上

转载 作者:搜寻专家 更新时间:2023-10-31 01:06:28 24 4
gpt4 key购买 nike

我正在使用 C++ 和 OpenGL 编写跨平台库。我想知道如何检测我是在 OpenGL Desktop 还是 ES 上运行?

也许可以通过 glGetString(GL_SHADING_LANGUAGE_VERSION) 来实现?

最佳答案

解析版本字符串以告知有关 OpenGL 实现的任何信息一直是禁忌。它们仅用于的眼睛,否则在报告版本号之前,将有一套更严格的规则来管理字符串的格式和合规性保证。


也就是说,GLES 规范在这个问题上比 GL 更严格,因此有可能:

OpenGL ES 2.0 Specification - 6.1.5 字符串查询 - pp. 128

The GL_VERSION string is laid out as follows:

"OpenGL ES N.M vendor-specific information"

在 OpenGL 中,兼容的实现将格式化其 GL_VERSION串成这样:

OpenGL 4.4 Core Specification - 22.2 字符串查询 - 第 488 页

The GL_VERSION and GL_SHADING_LANGUAGE_VERSION strings are laid out as follows:

<version number><space><vendor-specific information>

[...]

The version number is either of the form major number.minor number or major number.minor number.release number, where the numbers all have one or more digits.

这意味着在兼容的 OpenGL ES 实现中,版本字符串将以 OpenGL ES 开头。在 OpenGL 中,它将以数字开头(尽管我不认为“数字”仅限于字符 [0-9],因为所使用的语言含糊不清)。理论上,您可以使用此信息来区分两者。

但是您不应该因为实现报告了某个版本号就推断它实际上实现了合规性所需的功能集 - 这在过去是一个巨大问题OpenGL 2.0 的日子。

关于c++ - 如何检测opengl是运行在Desktop还是ES上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20745609/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com