How to learn LWJGL

Started by steamednotfried, July 21, 2012, 17:10:59

Previous topic - Next topic

steamednotfried

Hi, I'm really confused as to how one is expected to learn LWJGL. I've learnt the basics through various unofficial tutorials but cannot see how to increase my understanding and application of the library. For instance, how would I use functions from opengl 1.3? With no official tutorials and only beginner unofficial tutorials, how are people expected to learn this stuff? By just scouring through the documentation? It's a pretty complicated library.

Please help me out here. I'm pulling my hair out at the apparent absurdity of the situation.

Thanks

moci

What do you mean functions of OpenGL 1.3, you mean the specification or the LWJGL class GL13? If you only want to use functions that are available only in a certain specification you'll need to create a context of that version (this will throw errors when you use a feature from a newer version).

LWJGL has different classes GLXX, each version added new features so for each release the new features were included in that GLXX class (features added in OpenGL 1.3 can be accessed in class GL13 etc).

As far as learning LWJGL itself, LWJGL is "just" a layer between the actual libraries and Java. For the majority of library (OpenGL, AL, ...) features you can find it with the same name and parameters. Occasionally there are helper functions that make it a bit easier/different to setup things like buffers.

Also note that LWJGL expects you to use ByteBuffers when passing data to the libraries instead of arrays or other Java collections.

steamednotfried

Quote from: moci on July 21, 2012, 18:02:22
What do you mean functions of OpenGL 1.3, you mean the specification or the LWJGL class GL13? If you only want to use functions that are available only in a certain specification you'll need to create a context of that version (this will throw errors when you use a feature from a newer version).

LWJGL has different classes GLXX, each version added new features so for each release the new features were included in that GLXX class (features added in OpenGL 1.3 can be accessed in class GL13 etc).

As far as learning LWJGL itself, LWJGL is "just" a layer between the actual libraries and Java. For the majority of library (OpenGL, AL, ...) features you can find it with the same name and parameters. Occasionally there are helper functions that make it a bit easier/different to setup things like buffers.

Also note that LWJGL expects you to use ByteBuffers when passing data to the libraries instead of arrays or other Java collections.

Thank you very much for your reply. You say that creating a context for a particular version will limit you to that version. What is the alternative? Is the default for it to allow you to use all versions simultaneously?

When I print glGetString(GL_VERSION) it says, "2.1.0 - Build 8.15.10.2302". I would have thought that I would have a higher version since I have a fairly modern laptop and I can use the vertex, pixel and geometry shaders with Directx. With opengl, aren't the corresponding shaders only available from version 3 and up?

Thanks again.

CaleyM

I read that Mac OS supports up to 2.1 or so and the default for Windows is 1.1 before drivers are installed (maybe it's really 2.1).

steamednotfried

What about multisampling? Apparently you have to do something like pass a pixelformat object with some particular configuration to Display.create(). Where is it explained how this sort of thing works? It is specific to lwjgl and there doesn't seem to be any official explanation. I can't even find an unofficial explanation. How come some people seem to understand this sort of stuff?

I would really appreciate an answer to this because I'm feeling like there's something that I'm missing. I hate that feeling.

Thanks

moci

The default context is probably going to be the most compatible one, meaning with nothing deprecated. In your case a 2.1 context, update your drivers to get the latest version if you think you should be able to get a more recent version. It could be that DirectX has better support, Microsoft doesn't want OpenGL to do better if it can help it, right? Just update your drivers to the latest version and see what happens.

The PixelFormat documentation can be found here: http://lwjgl.org/javadoc/org/lwjgl/opengl/PixelFormat.html .

I usually just open google and type "lwjgl X" where X is the thing I need information on (handy when you need to know what GLXX class has a certain attribute or method). The javadoc can provide some explanation, otherwise it's trial and error to see what it does. PixelFormat has to do with how many bits there are for each color component (and which components there are, do you need an alpha channel or not, ...) I'm not entirely sure on the inner workings but then again the defaults have worked fine for me up until now.

LWJGL has a real problem with documentation, you can find code examples but they are not optimal for learning and don't cover "everything".

basil

reading lwjgl source helps too alot.

Evil-Devil

For the multisampling there is one pretty easy straight forward way of doing it. Recreate the display context till it returns a valid context. Thats what you find with google. Though its even the common way for other native OpenGL applications.

As there is no such thing as "hey operating system, gimme all the boundaries you offer". though that would be great ;)

delt0r

There is really no need to read the lwjgl source. Especially for people starting out. But some opengl docs and things don't go amiss. Basically its just opengl.
If you want a plot read a book and leave Hollywood out of it.