I want to use LWJGL, but I don't know OpenGL.

As topic says, I want to program using LWJGL. I know Java, but I don’t know OpenGL. What is THE best way to learn so I can start programming using LWJGL?

My concerns for each method I’ve come up with so far:

1) If I read the LWJGL javadocs, will I be able to determine which is the starting point, then step 2, then step 3, etc, or will all of the information be given in alphabetical order like all other programming documentation, meaning I can’t actually learn by reading the docs, serving as a reference only?

2) If I read the LWJGL and happen to be able to determine the proper order in which it should be read, will I be taught OpenGL using the methods of LWJGL well enough that I’d actually LEARN OpenGL in the process?

3) If I can’t learn LWJGL from the documentation, which book is THE best and most current (in regards to the current release of LWJGL) that I can use to learn OpenGL?
3b) Will I have twice as much work to do if I learn OpenGL first, and then have to go back and learn all of the function calls for LWJGL afterwords?

Disclaimer: This is a serious topic which can hopefully bring in some detailed answers. If the quality of replies is good enough, we can probably turn this into an FAQ, so it can serve as a good reference to the people who visit JavaGaming.org.

Thanks everyone

One nice place to start with learning OpenGL is Nehe. They have some good examples for getting started, and some (all?) have been ported to Java.

Not sure if they use JOGL or LWJGL, but I don’t believe that should really matter. It’s about learning OpenGL not a specific binding.

I can recommend the book “OpengGL SuperBible”. I got the fourth edition which is really a good introduction to OpenGL in my opinion. The fifth edition is more focused on OpenGL 3.0 which is more shader-centered. If you are more interested in writing OpenGL applications for newer, shader-enabled hardware I would recommend the fifth edition, otherwise I would go for the fourth instead.

I was in the same position and started with understanding the applet sample on the lwjgl homepage. From there I mainly googled what I wanted to do next and I indeed often ended up on the NeHe tutorials.

Mike

In that case, I should be able to follow along with the tutorials, and then any time I learn a new GL command, I should just go to the LWJGL docs and find the equivalent?

They are usually called exactly the same and take the same kind of parameters :slight_smile:

Mike

Ok thanks, I’ve got my IDE setup (eclipse) with LWJGL libraries ready to go as well. One problem, the NeHe tutorials ported for LWJGL are lessonX.jar files. How can I possibly open that up to view code? lol. I want to see .java files :frowning:

I can open them with Winrar and extract the .java files and readme.txt :]

Hi, I am having trouble importing the jar from the topic title. I googled and found out it is in lwjgl_util.jar in LWJGL 2.6, so I added that external jar like I did for lwjgl.jar, but it can’t seem to find that particular path.

Can you help me out? The only tutorials for LWJGL are not even tutorials, they are code files from NeHe ports, and those aren’t the best for learning :frowning:

EDIT: Got the solution. GLU is no longer a part of org.lwjgl.opengl.glu, but belongs to org.lwjgl.util.glu

I’m gonna be upset if Markus Persson (Notch) didn’t use these NeHe LWJGL code files to learn, because this is my only resource and I feel like it won’t be good enough when I get to the end, but maybe it will be so I’ll be determined to keep at it!!!

Once you’ve got the basics of the LWJGL Display system theirs not much more to it and the reset is pretty much just raw OpenGL.

Start with this page http://lwjgl.org/demos.php it contains basic single class examples that’ll get you started quickly.

Then just grab the OpenGL Redbook, Nehe Tutorials or some other OpenGL guide and work your way through them.

If you just want to start making games quickly without learning OpenGL go for a library that sits on top of LWJGL like Slick2D, jMonkeyEngine, Ardor3d, etc.

The idea is to follow the actual NeHe C tutorials and only use the LWJGL ports for reference in case you don’t succeed in converting single C calls to their java LWJGL equivalent. DON’T learn from the ports!

Yep! I have a window up now and can draw my first triangle and quad (and use glColor3F to color the points!) Yay!!!
But I noticed all of the NeHe tutorials have calls that look like glSomething() but LWJGL uses GL11.glSomething().

Will I always just add GL11. to get the equivalent call?

Even simpler, do a


import static org.lwjgl.opengl.GL11.*

and you are freed from the GL11 prefix…

How come GL_COLOR_BUFFER_BIT and GL_DEPTH_BUFFER_BIT didn’t fix until I added “static” to import static org.lwjgl.opengl.GL11.*

?

Never heard of static imports? There were added in Java5. Just google it, and you’ll see how they work.

For a quick introduction:
[import] imports classes
[import static] imports static fields and methods from classes