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.).
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.
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.
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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.