Can Java2D be as fast as LWJGL and JOGL?

I heard that Java2D uses OpenGL behind the scenes to render it, and I wondered if I should use JOGL and all its own libraries for my program, which is just a 2D scroller. I heard that there are certain methods that you should use, and scripts that you need to avoid to make sure that hardware acceleration is used, but I don’t know what they are (well, I know a few, but I still don’t find them full list.).

+4
source share
4 answers

As someone who has developed a 2D casual game in Java using LWJGL , I recommend not using LWJGL or JOGL if you are going to make a casual game.

Pros:

  • Simplified engine recording: OpenGL has a high fill rate, which means that you can redraw the screen in every frame.
  • Possibility for cool 3D effects.

Minuses:

  • All users must have a 3D map.
  • All users must have the OpenGL driver installed. Windows 7 doesn’t come with OpenGL drivers installed (see Google’s “ pixel accelerated format ” to see how much fun it leads).
  • 3D cards are battery powered, especially on older laptops. People often play casual games on laptops, so this can be a problem.
  • Applers need additional permissions to be able to use a 3D map. This leads to a scary dialog box that the user must click to play your game unless you want to buy a certificate of $ 500.

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

+5
source

There are libraries that you can use to draw Java2D in OpenGL. GLG2D (my library) does this. This is JOGL dependent and translates all java.awt.Graphics2D calls into OpenGL calls.

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

+4
source

The short answer is no. On Java2D, there are simply too many layers of swelling, as it can be as fast as possible than an LWJGL or JOGL application.

+3
source

You can enable hardware acceleration in Java2D, but even then it is still slower (and sometimes buggy) than any Java binding for OpenGL (JOGL, LWJGL). If you want the best in the world, take a look at GLG2D, as Brandon suggested above. Keep in mind that Java2D is a high-level API, while JOGL is a low-level binding. You can use the high-level APIs by relying on these low-level OpenGL bindings like JGame, Slick, and LibGDX.

0
source

Source: https://habr.com/ru/post/1344506/


All Articles