GDI,GDI +和OpenGL是否真的过时/不推荐? [英] Are GDI, GDI+ and OpenGL really obsolete/deprecated?

查看:1222
本文介绍了GDI,GDI +和OpenGL是否真的过时/不推荐?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您打开页面图形和游戏(Windows)在microsoft.com上



最后一类被描述为


传统图形:过时的技术,不应在新的
应用程序中使用。


类别包括(其中包括)以下API:


  • GDI

  • GDI +

  • OpenGL



您的意见是?如果我今天想要推出一款新软件,它必须支持Windows XP(仍然约占所有安装系统的50%)。 Direct2D需要Windows 7 / Vista。还应该使用什么?

我怀疑微软对遗产的定义与任何明智的开发者应该没有什么关系而是基于Windows API的一些重大改写。



从Windows Vista开始,微软一直在重新设计其许多API。我们现在拥有MMDevAPI作为One True Sound API,WIC是One True Image File API等等。从我看到/听说的情况来看,这些新API比旧版API好得多,传统系统都可以工作基于新的。在Windows Vista和更高版本中,DirectSound完全基于MMDevAPI,需要读取图像文件的组件通过WIC进行。



Windows 8将具有ARM版本,它似乎只支持当前Windows API的一个子集。在ARM发布Windows之前,我们不会知道这一点,但是,基于Visual Studio 11中ARM平台的库(参考: http://www.winehq.org/pipermail/wine-devel/2012-March/094559.html ),它看起来像GDI +而OpenGL将不可用。 GDI可用于链接,但这并不一定意味着它是完整的。



这个来自Vista和Vista的新API大致对应于VS11 ARM目标库。我猜测那个列表上的任何内容都是存在的,因为它不是最新和最好的做法,或者在技术上丢弃(现在)就太重要了。因此,遗产是任何不是最新和最好的方法来做至少一件事。



我不确定One True Graphics API是什么。我们已经有Direct2D,Direct3D,DirectComposition(顺便说一句,直到Windows 8才可用),DirectWrite和DXGI。 DXGI似乎是最接近的,但我对图形API的理解还不够深入。我怀疑gdi32在技术上很难摆脱。非遗留应用程序如何查明何时显示窗口的一部分,因此必须在不使用涉及HDC的WM_PAINT的情况下进行绘制,以及图书馆如何代替应用程序执行此操作而不替换其窗口过程?如何在不使用UpdateLayeredWindow的情况下制作半透明窗口,这需要使用HDC?有多少user32依赖于gdi32,并且它们真的可以分开?

从技术的角度来看,Windows可以轻松摆脱GDI +和OpenGL,但我不是坚信即使在不承诺任何向后兼容性的新平台上,摆脱OpenGL也能解决问题。这对开发者来说似乎太有价值。 GDI +不是那么重要,但是第三方提供替代品非常容易。

我会说使用你列出的任何API,最糟糕的是很可能会发生的是,如果要将应用程序移植到ARM上的metro或Windows,则必须重新编写UI。如果您的需求很简单,那么GDI是一个很好的选择,您将直接编码Windows API。我不推荐GDI +作为绘图API来使用OpenGL。 GDI +速度缓慢,有限,只能在Windows上使用。 GDI + API更简单,因为它是2D的,所以如果你需要做一些非常简单的事情,但是使用反锯齿功能,也许值得。


If you open the page "Graphics and Gaming (Windows)" on microsoft.com

the last category is described as

Legacy Graphics: Technologies that are obsolete and should not be used in new applications.

This category includes (among others) the following APIs:

  • GDI
  • GDI+
  • OpenGL

What's your opinion? If i want to roll out a new software today it must support Windows XP (still about 50% of all installed systems). Direct2D requires Windows 7/Vista. What else should be used?

解决方案

I suspect that Microsoft's definition of "legacy" has little to do with what any sensible developer should do, and is instead based on some Grand Rewrite of the Windows API.

Starting at around Windows Vista, Microsoft has been redesigning many of their API's. We now have MMDevAPI as the One True Sound API, WIC is the One True Image File API, etc. From what I've seen/heard, these new API's are much better than the old ones, and the "legacy" systems all work based on the new ones. In Windows Vista and later, DirectSound is entirely based on MMDevAPI, and components that need to read image files do it via WIC.

Windows 8 will have an ARM version, which it appears will support only a subset of the current Windows API. We won't know for sure until Windows on ARM is released, but, based on the libraries included for the ARM platform in Visual Studio 11 (ref: http://www.winehq.org/pipermail/wine-devel/2012-March/094559.html), it's looking like GDI+ and OpenGL will not be available. GDI is available for linking, but that doesn't necessarily mean it's intact.

This new API's from Vista and later roughly correspond to the libraries in the VS11 ARM target. I'm guessing that anything on that list is there because it's either the latest and greatest way to do what it does, or it's too technically important to discard (for now). Thus, "legacy" is anything that's not the latest and greatest way to do at least one thing.

I'm not sure what is the One True Graphics API. Already we have Direct2D, Direct3D, DirectComposition (which, by the way, is not available until Windows 8), DirectWrite, and DXGI. DXGI seems the closest, but I don't have a deep enough understanding of the graphics API's to say. I suspect gdi32 is technically very difficult to get rid of. How are non-legacy applications meant to find out when part of a window has been revealed and therefore must be painted, without using WM_PAINT, which involves an HDC, and how could a library do that on an application's behalf without replacing its window procedure? How are we meant to make semi-transparent windows without using UpdateLayeredWindow, which takes an HDC? How much does user32 depend on gdi32, and can they really be separated?

From a technical standpoint, Windows can easily get rid of GDI+ and OpenGL, but I'm not convinced that getting rid of OpenGL will work out, even on a new platform that doesn't promise any backward compatibility. It seems too valuable to developers. GDI+ isn't so important, but it's very easy for a third party to provide a replacement.

I would say use any of the API's you listed, and the worst that's likely to happen is that you have to rewrite your UI if you want to port your app to metro or Windows on ARM. GDI is a fine choice if your needs are simple and you'll be coding directly for the Windows API. There aren't many situations where I'd recommend GDI+ over OpenGL as a drawing API. GDI+ is slow, limited, and only available on Windows. The GDI+ API is simpler because it's 2D, so maybe it's worthwhile if you need to do something very simple but with anti-aliasing.

这篇关于GDI,GDI +和OpenGL是否真的过时/不推荐?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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