What are some faster alternatives to Java2d?
Asked Answered
G

4

17

I'm looking to do some physics simulations and I need fast rendering in Java.

I've run into performance issues with Java2d in the past, so what are the fast alternatives? Is JOGL significantly faster than Java2d?

Glottic answered 2/3, 2009 at 14:55 Comment(3)
#148978 and https://mcmap.net/q/326653/-java2d-performance-issues might be helpful.Africah
In fact, I think that before the edit, this question might have been a duplicate. I don't think it is now, though.Africah
Have you tried the latest updated of JDK 6?Oudh
P
12

My experience with Java2D is that it can be very fast, if you follow the rules. I had an application that went from 90% CPU to less than 5% CPU just by changing a few simple things. Using large transparent PNG's is a no no, for example.

A very good resource is the Java-Gaming.org forums: a lot of people, including the Sun 2D specialists, hang out there and provide many examples and solutions to performance issues for 2D drawing.

See: http://www.javagaming.org/ and then the topic "Performance Tuning".

Perm answered 2/3, 2009 at 17:58 Comment(0)
M
5

JOGL might be much faster than Java2D even if you use it for doing 2D graphics only: as Clayworth mentioned, it usually depends on what you need to do.

My guess is that for 2D physical simulations, where you have (textured or non-textured) objects rotating and translating with 2 degrees of freedom, JOGL should provide the best performance and also easily allow you to provide a zoomable interface. Here is a tutorial for OpenGL for 2D graphics (C, but easily adapted to JOGL).

JOGL will take a bit more time to learn than Java2D, but achieving good performance will most probably not require specialized optimizations as in Java2D.

Metachromatism answered 14/4, 2009 at 13:26 Comment(1)
+1 for using JOGL for 2D. I do this all the time at work and it really blows Java2D out of the water, especially for dense displays and alpha blending. On top of all of that you get GLSL shaders which are amazingly powerful.Jacquelinejacquelyn
H
3

I don't know - in the past I'd have said yes - especially if you use display lists rather than making lots of calls through the API each time the screen is displayed. But update 10 of the 1.6 JVM added accelerated Java2D graphics, so may have the advantage now. Really the only way to know for sure is to try to render typical scenes in both and measure it.

Helga answered 2/3, 2009 at 17:12 Comment(0)
R
2

Also check out Slick, which is based on LWJGL and is in some ways similar to Java2D. It uses OpenGL and is thus greatly faster.

Roundlet answered 31/5, 2009 at 18:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.