JOGL vs LWJGL and the best way to start learning

Hi, I’m still relatively new to java and game programming, but I’ve noticed a lot of people using openGL for their games, so I thought I would try and learn how to use it. Searching around a bit, I found that the two main java opengl libraries(if that’s the correct term) are JOGL and LWJGL. Most posts I’ve seen on which is best to use says it’s on personal preference, so which do you much more experienced game developers and programmers think is better/most user friendly for someone like me who isn’t very experienced in programming?
Also, where would be the best place to start learning how to use openGL in java, as I couldn’t seem to find many up to date tutorials out there, most were for C/C++.

Also a final question, is there anything other than OpenGL that you would recommend I learn/try due to my programming knowledge/ability?

gouessej will be along in a bit to espouse the virtues of JOGL.

Everyone else uses LWJGL.

Tutorials written in C++ are almost trivial to port to LWJGL as the APIs are very, very similar, apart from the use of Buffers where C/C++ use pointers, types, and length arguments (a Buffer implies all of type, pointer, and length of data already).

Cas :slight_smile:

There are plenty of up to date JOGL tutorials:

http://www3.ntu.edu.sg/home/ehchua/programming/opengl/JOGL2.0.html

Thanks, so if I learn opengl in C++, then I can easily transfer into java. I’m going to start here: http://www.arcsynthesis.org/gltut/

EDIT: is there an easy way to change C++ code to java, or is it just done manually, changing the line of code here and there?

More or less, yes.

Cas :slight_smile:

It’s very possible for you to turn the OpenGL to Java code yourself.
However, since those tutorials get complicated very quickly, it’s best to not waste your time with doing it yourself.
Here are the Java ports of those tutorials.

Wow thankyou, this will save me tonnes of time!

+1

EDIT: decided to not learn opengl right now, it seems a bit too advanced for my Java level. I’m going to keep developing in 2D so I can increase my abilities in java and be more adept for when I choose to move onto 3D/opengl. Thanks all for the help though, I hope others may have somehow found this useful too.

Actually using OpenGL for 2D is rather easy - I’d actually say it was easier than using Java2D.

Cas :slight_smile:

Ooh okay, would I follow different tutorials specifically for 2D or just normal ones and ignore the 3d parts?

There are probably some good 2D-specific tutorials out there for it.

Generally speaking you will need to learn:

  1. How to set up the display for 2D (relevant commands: glMatrixMode, glLoadIdentity, glOrtho)
  2. How to do a “main loop” (read input, do logic, clear screen, render things, sync and update) and close the app when someone closes it (classes: Display, Keyboard, Mouse; API glClear)
  3. How to load a graphic and get it into OpenGL (glTexture2D, glBindTexture)
  4. How to draw a sprite (glEnable, GL_TEXTURE_2D, glBegin/glEnd, GL_QUADS, glVertex2f, glTexCoord2f)
  5. How to draw sprites transparently (glBlendFunc, GL_BLEND, GL_ONE, GL_SRC_ALPHA)
  6. How to draw sprites additively

Come back when you get stuck. Work out those things one at a time.

Cas :slight_smile:

1 Like

Okay, I’ll start searching when I have some time to sit down and properly start learning some stuff. I’m busy with lots of school stuff at the moment though, so I have hardly any spare time :frowning: Thanks for all the help Cas!

EDIT: So far I’ve learnt a bit on both 1 and 2, hopefully should be able to start writing my own basic game using lwjgl soon!

I would just have written that:
"gouessej, xerxes, sven, tons of universities, laboratories, state controlled and private corporations, artists and a very few game studios use JOGL.

Everyone else uses LWJGL."

princec, stop claiming I’m alone to use JOGL, it is simply a lie. The FUD campaigns against JogAmp have to come to an end.

We have a nice wiki with some tutorials.

You can still switch to JOGL. princec gave you some nice advises but it doesn’t mean that you must use our competitor.

The “war” over abunch of trivial JNI wrappers for OpenGL/OpenAL is extremely funny to watch for an outsider.

On topic, the steps Cas told you about are a neat way to get into OpenGL. However, once you mastered them, don’t get to comfortable. Look into the tutorial on modern OpenGL linked to above, it will allow you to target more platforms, e.g. mobile phones/tablets.

I wouldn’t call them trivial, since both have really big windowing systems, I think the JogAmp Windowing codebase is even bigger then LWJGL’s.
Also, I’d really say that both princec and gouessej are pretty agressive in this war :frowning:
But everything is okey right now, so thats nothing to worry about :slight_smile:

I’m not aggressive about it, I just love winding Julien up.

Cas :slight_smile:

Haha, so then everything is normal and as always ;D

Popcorn for $1! Popcorn for $1! Get 'em here!

munches on popcorn

Can I have some thanks?

Votes for LWJGL.

I’m drunk! Where is Julien, I want to mock him.
And what better way than to fork TUER and “port” it to LWJGL, pointlessly!
Fetch me Eclipse and some whisky.

Cas :slight_smile:

JOGL’s improved a lot, and the speed differences are negligible now. JOGL’s got better native window support with multiple windows, and it has some interesting utility classes for things like animation (that probably don’t belong in there). The use of a graphics context object similar to how AWT/Java2D works does allow at least in theory for overrides (it’d probably take a lot of source hacking)

But JOGL’s packaging is rubbish. The release engineering is just bizarre (better now I’m told) and there’s no artifacts on maven central so I can’t easily work it in to any of my projects. So when the functionality I actually care about is otherwise equal, I’m going to go for convenience every time, and right now the winner is LWJGL.