2D and OpenGL?

I only plan to program 2d games. I will probably never program a 3d game in my entire life.

That said, I’ve noticed that some of my games have slower performance than I would expect for a 2d game. It’s primarily a problem on computers with Intel GMA graphics, but they’re in alot of the computers out there. For this reason, I considered switching from Java2D to Jogl. Now that I’ve skimmed over part of a book that includes information about Jogl, it seems that Jogl is only of any use for 3d games.

Is there any reason for me to explore Jogl or OpenGl at all if I’m only programming 2d games? I admit that I know essentially nothing about the issue, but it seems like I’m best off sticking with Java2d. That way, Java will do all the checking about whether it should use DirectX or OpenGl itself.

might want to consider Slick: http://slick.cokeandcode.com/index.php - 2d library on top of opengl, by kevglass

That’s an option I might consider, but I had been hoping to work with OpenGl directly, rather than through a library.

Then again, I might be better off with Slick, given that I know essentially nothing about OpenGl.

Does Slick typically get better performance than Java2D? And what happens when you use Slick on a computer that doesn’t have OpenGl?

then go with LWJGL

Flethcer, JOGL works just as well for 2D as it does for 3D. And yes, you’ll probably get alot better performance than with Java2D. If you want to work with OpenGL directly, JOGL basically only provides opengl bindings, so you can’t be more direct than that.

Another vote here for Slick. Kev did (does) a great job with it. Plenty of 2D graphics related stuff already built in, and access to OpenGL when you need it.

Cheers,
Brett

Things to note:

a) LWJGL vs JOGL - they’re identical as far as 2D graphics in OpenGL are concerned
b) If you’re interested in learning or doing something crazy between 2D and 3D it’s better to go straight to LWJGL
c) Slick is intentionally designed to let you use whichever bits suit your needs and revert back to OpenGL whenever/wherever you feel the need.

Having seen your previous posts, and guaging your ability based on that, I’m sure you could have yourself up a suitable 2D rendering engine in a few days in OpenGL.

It is worth remembering (I’m sure you know, but for others that might not) that jumping to any sort of native dependency gives you distribution headaches at the moment.

Kev

Why is LWJGL better than JOGL in this case? I have yet to see any significant between them in almost every aspect.

It’s somewhat easier to set up and make something appear. Well, last time I looked it was.

Cas :slight_smile:

Sorry, there is no difference, I meant rather than going to Slick.

Kev

I’m also a 2d man, and yeah the darned intel graphics cards are everywhere.

As far as I know, java2D’s OpenGL pipeline can be used on any computer, even on intel cards (but it may not work since intel cards and their OGL drivers are very bad). You just have to specify the VM flag (-Dsun.java2d.opengl=True).
The D3D pipeline won’t work since it’s disabled for intel cards due to bad drivers.
The software pipeline always works and on modern computers with big processors, it’s very fast.

If you target mobile phones one day, you might be interested in JOGL 2.0; otherwise, LWJGL and JOGL (Sun’s endorsed official OpenGL binding) are almost the same in your case.

It sounds like JOGL is just what I need. It sounds like it should be relatively easy to figure out how to use for 2d graphics. Since I don’t need to do any 3d graphics at this time, there shouldn’t be much of a problem.

Before reading the replies to this thread, I wasn’t sure exactly whether JOGL provided any benefits for 2d games or even if it could be used. The ebook I purchased didn’t include the information I thought it would. It seems to exclusively cover 3d games, while I assumed it would include information about using JOGL for 2d games at the very beginning.

I will try make it possible to switch my program back and forth between using JOGL and Java2D so that I can compare performance. In the worst case scenario, I’ll just switch back to Java2D.

If you are disappointed with the performance, maybe you will try to find what is wrong rather than switching back to Java2D.

However, Slick is more than an OpenGL binding, it might be useful in order to avoid reinventing the wheel, it contains some nice features (fonts, tiles, gradients, SVG…) and a quite good documentation (a wiki translated into my mother tongue, thanks :D). It could be interesting to have an equivalent of Slick that would rely on JOGL for those who want absolutely to use JOGL instead of LWJGL and use such a good library.