Java2D 能像 LWJGL 和 JOGL 一样快吗?

发布于 2024-10-23 17:54:51 字数 151 浏览 3 评论 0原文

我听说 Java2D 在幕后使用 OpenGL 进行渲染,我想知道是否值得为我的程序使用 JOGL 及其所有本机库,而我的程序只是一个 2D 横向滚动条。我听说您必须使用某些技术和需要避免的场景,以确保使用硬件加速,但我不知道它们是什么(嗯,我知道一些,但我还没有找到它们的完整列表。)。

I've heard that Java2D uses OpenGL behind the scenes to do it's rendering, and I've wondered if it's worth it to use JOGL and all it's native libraries for my program which is simply a 2D side scroller. I've heard that there are certain techniques you have to use and scenarios you need to avoid to make sure hardware acceleration is being used but I don't know what they are(well, I know a few, but I've yet to find a comprehensive list of them.).

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

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

发布评论

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

评论(4

终难遇 2024-10-30 17:54:51

作为使用 LWJGL 共同开发Java 2D 休闲游戏的人,如果您打算使用 LWJGL 或 JOGL,我建议您不要使用 LWJGL 或 JOGL制作一款休闲游戏。

优点:

  • 简化引擎编写:OpenGL 具有高填充率,这意味着您可以每帧重绘屏幕。
  • 可以实现炫酷的 3D 效果。

缺点:

  • 所有用户都需要拥有 3D 卡。
  • 所有用户都需要安装 OpenGL 驱动程序。 Windows 7 未安装任何 OpenGL 驱动程序(查找“像素格式不在 Google 上加速”,看看由此带来的乐趣)。
  • 3D 卡会消耗电池,尤其是在旧笔记本电脑上。人们经常在笔记本电脑上玩休闲游戏,因此这可能是一个问题。
  • 小程序需要额外的权限才能使用 3D 卡。这会导致一个可怕的权限对话框,用户必须点击才能玩你的游戏,除非你愿意购买 500 美元的证书。

我的建议是使用 Java2D 渲染和动画框架(例如 PulpCore)来开发游戏。我希望我们有。

As someone who co-developed a 2D casual game in Java using LWJGL, I recommend against using LWJGL or JOGL if you're going to be making a casual game.

Pros:

  • Simplified engine writing: OpenGL has a high fill-rate, meaning you can redraw the screen every frame.
  • Possibility for cool 3D effects.

Cons:

  • All users needs to have a 3D card.
  • All users need to have an OpenGL driver installed. Windows 7 does not come with any OpenGL drivers installed (look up "pixel format not accelerated" on Google to see the kind of fun that results in).
  • 3D cards eat battery, especially on old laptops. People often play casual games on laptops, so this can be a problem.
  • Applets need extra permissions to be able to use the 3D card. This results in an scary permission dialog a user has to click through to play your game, unless you're willing to buy a $500 certificate.

My recommendation would be to use a Java2D rendering and animation framework like PulpCore to develop your game. I wish we had.

め七分饶幸 2024-10-30 17:54:51

您可以使用一些库将 Java2D 绘制到 OpenGL 中。 GLG2D (我的库)就是这样做的。它依赖于 JOGL 并将所有 java.awt.Graphics2D 调用转换为 OpenGL 调用。

在 Java2D 中绘制线条(尤其是曲线)可能非常慢。

There are libraries that you can drop in to draw Java2D into OpenGL. GLG2D (my library) does this. It depends on JOGL and translates all java.awt.Graphics2D calls into OpenGL calls.

Line-drawing, especially curves, can be very slow in Java2D.

送君千里 2024-10-30 17:54:51

简短的回答,不。 Java2D 上的膨胀层太多,它的速度几乎无法与 LWJGL 或 JOGL 应用程序一样快。

Short answer, no. There are simply too many bloat layers on Java2D for it be anywhere near as fast as an LWJGL or JOGL app.

在巴黎塔顶看东京樱花 2024-10-30 17:54:51

您可以在 Java2D 中启用硬件加速,但即使在这种情况下,它仍然比 OpenGL 的任何 Java 绑定(JOGL、LWJGL)慢(有时还存在错误)。如果您想要两全其美,请看看布兰登上面建议的 GLG2D。请记住,Java2D 是高级 API,而 JOGL 是低级绑定。您可以使用依赖于这些低级 OpenGL 绑定的高级 API,例如 JGame、Slick 和 LibGDX。

You can enable hardware acceleration in Java2D but even in this case it is still slower (and sometimes buggy) than any Java binding for OpenGL (JOGL, LWJGL). If you want the best of the both world, have a look at GLG2D as Brandon suggested above. Keep in mind that Java2D is an high level API whereas JOGL is a low level binding. You can use an high level API relying on these low level OpenGL bindings, for example JGame, Slick and LibGDX.

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