在LWJGL中更改OpenGL版本 [英] Changing OpenGL Version In LWJGL

查看:177
本文介绍了在LWJGL中更改OpenGL版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我一直想知道如何在lwjgl中更改openGL版本.我知道我可以使用Wiki上所说的PixelFormat和ContextAttribs更改版本. http://lwjgl.org/wiki/index.php?title=Version_selection

So i've been wondering how to change the openGL version in lwjgl.. I know i can change the version with PixelFormat and ContextAttribs as being said on the wiki http://lwjgl.org/wiki/index.php?title=Version_selection

但是那只能把我降低到3.2最低,如果我想降低到更低的水平怎么办?像是2.1甚至1.1?有什么办法吗?

But that only can take me down to 3.2 minimum what if i want to take it even lower? like maybe 2.1 or even 1.1? Is there any way to do this?

推荐答案

好吧,OpenGL上下文版本背后的逻辑可能会有些混乱.但这在历史背景下看确实是有道理的:

Well, the logic behind OpenGL context versions can be a bit confusing. But it does make sense when seeing it in the historical context:

在过去,没有特殊的上下文版本"提示.只有一种创建上下文的方法,并且您将获得在其上运行的特定实现所支持的最高版本.您可以查询版本字符串和扩展字符串,并检查代码实际需要的所有功能是否可用.获得比您真正需要的更高的版本从来都不是问题,因为每个新的GL版本都可以100%向后兼容以前的版本. (至少在理论上是这样).一直保持到OpenGL 2.1.

Back in the day, there were no special "context version" hints. There was just one way to create a context, and you would get the highest version that the particular implementation you run it on does support. You could query the version string and the extension string, and check if all of the features your code actually needs are available. Getting a higher version than you really needed was a never a problem since every new GL version was 100% backward compatible to the previous versions. (Well, in theory, at least). It stayed that way till OpenGL 2.1.

但是,在OpenGL 3.0中,引入了弃用模型".第一次,功能被标记为已弃用",并计划实际删除.并且这在OpenGL历史上尚属首次,不再保证向后兼容.随后,引入了新的上下文创建机制:ARB_create_context功能(请参见 glX版本),其中包括请求上下文版本"的可能性.现在您遇到的情况是,对GL3一无所知的旧应用程序仍应像以前一样运行.因此,旧方法提供的是与GL 2.1 兼容的(或者,如果您的实现确实很旧或有限,则仅提供GL 1.x版本,而更现代的则为GL 1.x版本).不支持GL 2.x功能.

However, with OpenGL 3.0, the "deprecation model" was introduced. For the first time, features were marked "deprecated" and planned to be actually removed. And for the first time in the history of OpenGL, backwards compatibility was not guaranteed any more. Subsequently, a new context creation mechanism was introduced: The ARB_create_context functionality (see the extension specs for the wgl version or the glX version), which includes the possibility to request a "context version". Now you have the situation that old applications, which know nothing about GL3 and the new context creation mechanism should still function as before. So what the old method gives is something which will be compatible to GL 2.1 (or, if you have a really old or limited implementation, it gives you just some GL 1.x version, when the more modern GL 2.x features are not supported).

在OpenGL 3.2中,引入了上下文 profiles .基本上,这是ARB最终想出的解决这些兼容性问题的解决方案.从GL3.2开始,定义了两个配置文件: core compatibility .在核心配置文件中,已弃用的东西被删除,而在兼容性配置文件中,您得到的东西可以支持从1.0开始的GL中的所有内容.

With OpenGL 3.2, context profiles where introduced. This is basically the solution the ARB finally came up with, to deal with these compatibility issues. Beginnning with GL3.2 there are two profiles defined: core and compatibility. In core profiles, deprecated stuff is removed, while in compatibility profiles, you get something which is going back to support everything which ever was in GL from 1.0 on.

事情可能就这么简单,但事实并非如此.实施者仅需支持核心配置文件,兼容性配置文件是可选的.这导致我们现在遇到的情况:取决于实现平台,GL上下文的选项将有所不同:

Things could be that simple, but they aren't. Implementors are only required to support the core profile, the compatibility profile is optional. This lead to the situation we now have: depending on the implementation and the platform, the options for GL context will vary:

  • 所有主要的桌面平台(Windows,Unix/Linux,OSX)都使用旧的上下文创建方法来支持旧版" GL.

  • All major desktop platforms (Windows, Unix/Linux, OSX) support "legacy" GL with the old context creation method.

在Windows上,使用现代GPU和驱动程序,您通常仍会获得最高的兼容性配置文件,当您使用旧版上下文创建/不请求特定版本/要求版本< GL3.因此,当您在那里要求1.0时,最终可以得到4.4.

On windows, using modern GPUs and drivers, you will still typically get the highest compatibility profile which is supported by the GPU when you use the legacy context creation/don't request a specific version/request a version < GL3. So you can end up with 4.4 when you asked for 1.0 there.

在OSX上,有一个尖锐的切口.旧版GL的创建最多将为您提供GL2.1.如果您需要现代GL,则必须要求提供3.2个 core 配置文件.

On OSX, there is a sharp cut. Legacy GL creation will give you at most GL2.1. If you need modern GL, you have to ask for a 3.2 core profile.

在Linux上,它取决于您使用的GPU驱动程序. AMD和NVidia的专有驱动程序的行为类似于Windows机箱.但是,开源mesa3D实现(也由官方intel GPU驱动程序使用)确实像OSX那样处理它:仅支持核心配置文件.

On Linux, it depends on the GPU driver you are using. AMD's and NVidia's proprietary drivers behave similiar to the windows case. However, the open source mesa3D implementation (which is also used by the official intel GPU drivers) does handle it more like OSX does: only core profiles are supported.

对于GL开发人员,需要考虑以下几点:

For a GL developer, there are a few things to consider:

  • 您不能在同一应用程序中可靠地混合使用现代功能(GL> = 3)和不推荐使用的旧功能,因为这并非在所有平台上都可用(并且不是规范所必需的).如果您想走现代"路线,请请求核心配置文件以进行> = GL 3.2.

  • You can not reliably mix modern (GL >= 3) and deprecated legacy features in the same application, since this will not be available on all platforms (and is not required by the spec). If you want to go the "modern" route, request a core profile for somehting >=GL 3.2.

如果要使用旧版" GL,则应限制使用GL2.1功能集.您可能最终仍会获得更高版本的兼容性配置文件,但您永远不能依赖它-至少,如果您不针对特定平台.但是由于GL规范根本不需要实现兼容性配置文件,所以我不建议这样做.这也意味着在实践中,请求兼容性配置文件是毫无用处的.

If you want to use "legacy" GL, you should limit yourself to the GL2.1 feature set. You still might end up with some compatibiity profile of a much higher version, but you can never rely on that - at least, if you don't target a specific platform. But as the GL spec does not require compatibility profiles to be implemented at all, this isn't something I would recommend. This also means that requesting a compatibility profile is quite useless in practice.

您可以依靠的是:如果您请求了特定的GL版本(可能还有配置文件),并且您实际上获得了上下文,则该名称可能与您要求的版本不完全相同,但是它将支持该版本的所有功能.您要求的版本. (但相反的结论在一般情况下无效.)

What you can rely on: if you requested a specific GL version (and maybe profile) and you actually get a context, it might not be exactly the version you asked for, but it will be a version which supports every feature of the version you asked for. (But the reverse conclusion is not valid in the general case.)

这篇关于在LWJGL中更改OpenGL版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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