LWJGL Beginning

hey guys,

      Even though Im still learning to get better at using just core Java for games, I want to begin messing with LWJGL drawing. I started with the tutorials at NinjaCave, and they were helpful. I really like to learn from the API documentation, but the javadocs for the LWJGL are basically non existant. I looked in the documentation for the GL11 class, and there are no descriptions at all for the fields or methods. The only things I found actual write ups for are the Mouse, Keyboard, Display, etc classes. So Is there somewhere that I can learn what all these methods and fields are?? Some examples: 

GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GL11.glOrtho(0, 800, 600, 0, 1, -1);
GL11.glMatrixMode(GL11.GL_MODELVIEW);

This stuff works… but I have NO IDEA what is what

You should look at the Redbook. It is the programming guide for OpenGL. The commands for LWJGL are pretty much identical to the normal OpenGL calls, so it should be strait forward to use other material. If you dig around on the LWJGL page you can also find some additional information in the documentation section.

…or use the openGL docs.
‘It works’ is good! Working in GL takes a change of headspace!

Wait, so the LWJGL syntax is the same as plain OPENGL? So does LWJGL just add some methods specific to game creation?? Confused now!

LWJGL is mainly an OpenGL binding. With it, you can access low level hardware acceleration : OpenGL, OpenAL, joystic/joypad (with a simplier class than JInput).

LWJGL is not a game engine, it doesn’t add class to deal with texture/sprite loading for example. If you want a game engine, there is quite some that use LWJGL ;).

As you saw before, LWJGL had classes for keyboard and mouse handling. LWJGL also lets you create windows. OpenGL does not control keyboard/mouse input or window creation (it assumes the OS can do that). So LWJGL has a Java binding to OpenGL as well as other classes to manage displays (and interact with them).

All of the GL11.glXYZ calls are Java methods that match the identically named OpenGL functions. The Java OpenGL bindings in LWJGL are organized by OpenGL version or extension. So GL11 contains the functions for OpenGL 1.1, GL20 has OpenGL 2.0, etc. You will not need to worry about extensions for a while.

Ah ok, a game engine is NOT what I wanted so this is good. Im going to pick up a good OpenGL book then or read some docs online. Thanks for the help guys. What Im curious about is, does LWJGL support image loading and all of that stuff or am I going to need to use SLICK2d or some other libraries. My goal is to learn as much of the lower level stuff as possible, without the unnecessarily low level stuff of course. So would I not be able to use the old java classes such as Image and ImageIcon while using LWJGL? Or can I combine them? This is actually pretty confusing

[quote=“jparril1,post:7,topic:36443”]
Not directly. You’ll have to get at the actual Image data and take care of setting up GPU memory and transferring it to OpenGL. I’m sure there are examples of that about.

I’m not actually familiar with LWJGL; FWIW JOGL has some helper classes for loading textures and such… in fact, the JOGL source might not be such a bad place to look for an example of how to load data from a Java Image into an OpenGL texture.

About loading textures, you should have look at the LWJGL Wiki, theres a number of options and help classes there that you can use to load textures with LWJGL including ones that use AWT.

Ok so the latest edition of the RedBook got awful reviews saying that 90% of the code is deprecated… any truth to this? I was thinking of getting the superbible. Some people said to get the older edition, something about OpenGl switching something with functions and pipelining in the newer releases?? Honestly I have no idea what theyre talking about, I just want to get the best book lol.

This is true; a fairly large amount of stuff in the Red Book is out-of-date, but: it teaches the basics, and it all still works, and the 10% that isn’t deprecated is still the way you’re meant to do it.
The NeHe tutorials are supposed to be pretty good.

Cas :slight_smile:

IMO the new opengl stuff (opengl 3.0+) is overrated, its all cool stuff but hardly any low end/mid range cards support it yet. Until that changes the old stuff is still good to use for mass distribution.

Ok, so if I were to get the SuperBible, should I get the 4th edition from 2007 or the 5th from 2010?

LWJGL wiki is already enough I think. For the rest just google it.