Java2D 能像 LWJGL 和 JOGL 一样快吗?
我听说 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
作为使用 LWJGL 共同开发Java 2D 休闲游戏的人,如果您打算使用 LWJGL 或 JOGL,我建议您不要使用 LWJGL 或 JOGL制作一款休闲游戏。
优点:
缺点:
我的建议是使用 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:
Cons:
My recommendation would be to use a Java2D rendering and animation framework like PulpCore to develop your game. I wish we had.
您可以使用一些库将 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.
简短的回答,不。 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.
您可以在 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.