简体   繁体   English

OpenGL'弃用'功能可能不受支持吗?

[英]Can the OpenGL 'deprecated' functions possibly be unsupported?

I am testing with glDrawPixels to port my simple pixel-drawn 2D game from Windows API to OpenGL with GLFW. 我正在测试glDrawPixels将我的简单像素绘制2D游戏从Windows API移植到带有GLFW的OpenGL。 It runs nicely with FPS over 100, additionally cross-platform. 它运行良好,FPS超过100,另外还有跨平台。

Just one thing that is slightly annoying me is that I'm using a deprecated feature. 只有一点让我烦恼的是我正在使用一个不赞成使用的功能。 I don't see any problems now, but will this possibly be a problem in the future? 我现在没有看到任何问题,但这可能是未来的问题吗? Can glDrawPixels become suddenly removed? glDrawPixels突然被删除吗? All I need is a cross-platform alternative to winapi's CreateWindow and BitBlt . 我所需要的只是winapi的CreateWindowBitBlt的跨平台替代品。

I'd like to extend on the article about deprecation in the OpenGL wiki which was given in the comments already. 我想扩展一下OpenGL wiki中关于弃用文章 ,该文章已在评论中给出。

The current situation is that we can discern 3 "flavours" of OpenGL contexts on desktop platforms: 目前的情况是,我们可以在桌面平台上辨别出OpenGL上下文的3种“风味”:

  1. "Legacy" GL. “遗产”GL。 This means the GL from the old days, before there was any deprecation scheme, and before there were specifically versioned contexts or profiles. 这意味着过去的GL,在有任何弃用方案之前,以及在有特定版本的上下文或配置文件之前。
  2. "Modern" GL in the core profile. “现代”GL的核心简介。
  3. "Modern" GL in the compatibility profile. 兼容性配置文件中的“Modern”GL。

The first case, "legacy" GL, is limited to GL 2.1 and earlier in a cross-platform manner. 第一种情况,“遗留”GL,以跨平台方式限于GL 2.1及更早版本。 All major desktop OS (Windows, Linux, OSX) have support for this on all major GPU brands (Intel, NVidia, AMD). 所有主流桌面操作系统(Windows,Linux,OSX)都支持所有主要GPU品牌(Intel,NVidia,AMD)。 And this is unlikely to go away for a long time, since all of the "old" software that is not even aware of the existence of modern GL relies on it. 这种情况不太可能在很长一段时间内消失,因为所有甚至不知道现代GL存在的“旧”软件都依赖于它。

What I describe as "modern" GL means GL 3.2 and later. 我所说的“现代”GL意味着GL 3.2及更高版本。 And there, profiles have been invented. 在那里,已经发明了配置文件 The crux is that only the core profile is required to be supported, the compatibility profile is optional. 关键是只需要支持核心配置文件, 兼容性配置文件是可选的。 In core profiles, the deprecated functions are actually removed , so your code will not work in a core profile. 在核心配置文件中,实际上已删除了已弃用的函数,因此您的代码将无法在核心配置文件中运行。 In compatibility profiles, the deprecated functions are still available. 在兼容性配置文件中,已弃用的功能仍可用。

So, the only way to mix old legacy features (like fixed-function pipeline, immediate mode, or your glDrawPixels call) with modern GL features, is a compatibility profile. 因此,将旧的旧功能(如固定功能管道,立即模式或glDrawPixels调用)与现代GL功能混合的唯一方法是兼容性配置文件。 However, in practice, compatibility support is not generally available. 但是,实际上,通常不提供兼容性支持。 MacOSX generally does not support compatibility profiles, and neither do the open source Linux drivers based on Mesa. MacOSX通常不支持兼容性配置文件,基于Mesa的开源Linux驱动程序也不支持。 So you can't really do cross-platform development with a compatibility profile. 因此,您无法使用兼容性配置文件进行跨平台开发。

Note that I somehow skipped GL 3.0 and 3.1. 请注意,我以某种方式跳过了GL 3.0和3.1。 They are something in between and I recommend never trying to use them. 它们介于两者之间,我建议永远不要尝试使用它们。 OSX does not support them at all. OSX根本不支持它们。 And actually, any real world GPU which supports GL 3.0 also supports at least GL 3.2 anyway. 实际上,任何支持GL 3.0的真实GPU也至少支持GL 3.2。

I see two options for you: 我看到两个选项:

  1. If the feature set in GL 2.1 is enough for your use case, you can simply stick to legacy GL. 如果GL 2.1中的功能集足以满足您的使用需求,您可以直接使用旧版GL。 Support for it won't go away for a long time. 对它的支持不会消失很长时间。
  2. Switch to modern GL without use of deprecated functions. 切换到现代GL而不使用已弃用的功能。 glDrawPixels has never been efficient. glDrawPixels从未如此高效。 You are probably far better using a textured quad (or maybe even glBlitFramebuffer ) for blitting images to the screen. 使用纹理四边形(或者甚至可能是glBlitFramebuffer )将图像glBlitFramebuffer到屏幕可能要好得多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM