适用于 Windows/C++ 的优秀 2D 图形绘制 API 是什么?

发布于 2024-09-17 19:14:11 字数 244 浏览 4 评论 0原文

我一直在开发一个小型应用程序,并且一直在使用 DirectX/3D 将纹理绘制到屏幕上(所有二维元素)。我发现 API 非常容易使用,并且可以使用 OOP 原则进行整合,但我忍不住觉得在这么小的东西上使用 DirectX 实在是太过分了。

不过,我似乎无法就一个好的替代方案达成共识。有什么建议吗?

编辑: 本机 alpha 混合和 PNG 文件支持是必要的。

带着很多第一次的爱, 詹格勒

I've been working on a small little application, and I've been using DirectX/3D to draw textures to the screen (all 2-dimensional elements). The API, I find, is pretty easy to use and to incorporate using OOP principles, but I can't help but feel that using DirectX on something this small is insanely over-kill.

I can't seem to find consensus on a good alternative, though. Any suggestions?

EDIT: Native alpha-blending and PNG file support is necessary.

With much first-post love,
Jengerer

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

旧街凉风 2024-09-24 19:14:11

如果您需要 alpha 混合,则必须使用图形硬件;唯一的好方法是使用类似于您现在的做法的 3D API(DirectX 或 OpenGL)。任何替代方案(GDI/+ 或 DirectDraw)都不会使用完整的图形硬件来加速混合,并且必须在 CPU 上执行,从而大大降低性能。

如前所述,Direct2D 也是一个选项 - 它在功能上是 Direct3D 之上的一个层,支持更多 2D 特定功能以及出色的文本支持。

If you need alpha blending you have to use the graphics hardware; the only good way to do that is to use a 3D API similar to how you're doing it now (DirectX or OpenGL). Any alternative (GDI/+ or say, DirectDraw) will not use the full graphics hardware for accelerating blending and will have to perform it on the CPU, greatly reducing performance.

As mentioned, Direct2D is an option also--it is functionally a layer on top of Direct3D that supports more 2D specific functionality as well as excellent text support.

£噩梦荏苒 2024-09-24 19:14:11

如果不需要 XP 支持,请使用 Direct2D.
否则,请使用 GDI+

If you don't need XP support, use Direct2D.
Otherwise, use GDI+.

迷路的信 2024-09-24 19:14:11

Windows 包含一个开箱即用的。 (GDI32.DLL)。可以连接到 WM_PAINTWindowProc 调用中的消息并使用 BeginPaint() 开始绘图。 Zetcode 上提供了关于可以做什么的非常好的想法和基本教程。

Windows includes one out of the box. (GDI32.DLL). It's possible to hook into the WM_PAINT message in the WindowProc call and use BeginPaint() to start drawing. A really good idea of what can be done and a basic tutorial is available on Zetcode.

酒儿 2024-09-24 19:14:11

我过去曾使用过 Gosu ,并且使用起来没问题。它被设计为更多地与 Ruby 一起使用,但对于 C++ 来说也不错。我们在一款快速横向卷轴游戏中使用了它,在其中我们搞乱了 z 顺序和 Alpha 通道。也许值得一看。

I have used Gosu in the past, and it has been alright to work with. It was designed to be used more with Ruby, but it is not bad for C++. We used it in a quick side scroller game, where we messed with z-order and the alpha channel. It might be worth checking out.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文