LWJGL with OpenGL 3.x++

Started by Morious, May 22, 2011, 09:11:04

Previous topic - Next topic

Morious

Hello,
I recently started reading into OpenGL.
At first I started reading the RedBook, which is pretty interesting and I'm really making progress.
But after some additional reading I noticed that most of the stuff I was learning is now outdated due to the release of OpenGL 3.x etc.
I tried searching for some Material on 3.x and had a very hard time to find anything that helped me. In addition to that, there seems to be nothing on LWJGL with 3.x? As a beginner, I'm have big problems translating 3.x tutorials in C++ to Java and LWJGL.

Can anyone recommend some reading about this topic? Or would you think it's best to go in with the RedBook?
Thank you very much, any information is appreciated :)

spasi

These days it would be best if you read a book on the theory of 3D graphics rendering instead of something specific to OpenGL, especially a book written pre-3.0. It's also best if you avoid anything marked as deprecated in the OpenGL spec, or simply use the core version of the spec. I can imagine that for someone new to OpenGL it can be frustrating and confusing to have to learn about VBOs, vertex shaders and fragment shaders before even drawing a single pixel to the screen, but with OpenGL ES 2.0 and WebGL (which don't have the deprecated functionality) being so popular these days, there are dozens of examples on the web to get you started.

About LWJGL, you should look for code samples (even pre-3.0 stuff) to get familiar with how NIO buffers are used in the API. That's the only real difference between C and Java code and it's very straightforward if you get used to it. Porting any C/C++ code will be easy then (even Direct3D samples when you get familiar with shading languages).

Finally, read this post on JGO, the OpenGL Samples Pack should be helpful.

Morious

Thank you for your answer!
That’s definitely useful information, but at the moment a bit to advanced for me.
It would be great to see some sources with LWJGL showing just the simplest things (like rendering a triangle) in 3.x style.
From there on I could start reading C++ stuff and typ to port it to Java, but without any bit of information how a GL Program should look now, it's hard to do the first step.
This information has to be available somewhere... till now I just didn't manage to find it.

spasi

You could checkout the OpenGL ES branch and have a look at the test code. It's very simple to port those examples to desktop OpenGL (just change the imports at the top).

Kuko

I suggest, you should read the OpenGL Superbible, 5th edition. It’s as readable as the redbook and relies on modern OpenGL only. But there is one critical point, however. The authors introduced their own GL-Wrappers in order to simplify OpenGL programming for beginners. Unfortunately, this makes the porting to LWJGL less easy and hides some of the gl-basics from the reader.
An alternative or addition may be the OpenGL ES 2.0 Programming Guide, which contains a readable introduction to ES 2.0 without any wrappers. OpenGL ES programming is similar to modern OpenGL but lacks some of the more advanced features like geometry- or tessellation shaders.

Morious

Thank you both, I will look into your suggestions :)

AberrantWolf

FWIW, over the next week or so, I plan to put together a tutorial about just this, as I have also had to overcome the hurdle of getting things working with modern opengl. I have the advantage of having worked with older opengl and when I stopped I was essentially at the point where I started learning the things that are standard for modern opengl, though.

I'll post a link and try to upload a copy to the wiki when I get it working. But until then, I have had much success by appending the word "modern" to my google searches. (So, "modern opengl tutorial".)

Hopefully that will lead you to some good places. :)

--edit-----
Also, I totally forgot to check the date on these posts. And here I thought I was being all helpful. XP

Stevie W

I think a tutorial like that whould be extremely useful. There arn't many modern openGL books around. The one i have found (the openGL super bible), is good but the tutorials are in c++ using freeGLUT. and glut seems to use different commands to create the window.
after that it shouldnt be too difficult to use C examples, since the OpenGL commands are mostly the same in C and java.
I whould assume that the problem is just getting started, since the LWJGL wiki tutorials (and others) look like they use quite old versions of OpenGL.

Twinfun

I feel that I am on the same boat as Morious.

I am brand new to OpenGL with minimal DirectX9 experience, and I have absolutely no clue where I should be reading to get a better understanding of how OpenGL is structured.

I have found from another thread that GL11 = GL 1.1, GL21 = GL 2.1, etc, and, with that information, I see that LWJGL supports OpenGL from version 1.1 up to version 4.2. The very basic tutorials provided by the wiki are using GL11, which I assume (like I said, I have no understanding of OpenGL right now ???) is the most outdated OpenGL standard available. From the research I've done thus far, there are so many varying opinions on whether or not NeHe's tutorials are worth reading (I don't even know what version of OpenGL those utilize, but it seems similar enough to the basic LWJGL tutorials on the wiki for them to be a viable starting point in my scenario). Some say that a lot of the functionality (workflow, whatever you want to call it) is deprecated, and that learning OpenGL away from the latest standards is not optimal, but I have no idea if learning the latest OpenGL standards is what I'm aiming for. I also assume that the latest standards require more up-to-date graphics hardware, and I'm definitely not trying to target the latest hardware (unless you consider Android to be "latest hardware"). What confuses me further is that, as mentioned, the basic LWJGL tutorials provided in the wiki utilizes version 1.1 of OpenGL. So are those tutorials really that old, or is it simply OpenGL 1.1 being a viable solution for it's minimal functionality? Is learning OpenGL from the latest specification really that big of a deal?

I'm frustrated at this point that all of the information I find is so volatile and misleading. I'm having an extremely difficult time trying to find a good starting point for me to start writing. I guess my biggest frustration is understanding the relationship between all of the OpenGL specifications.

Don't know if this warrants another thread, but I feel that Morious's issue doesn't stray too far away from mine.

Thanks!
Brandon.

EDIT:

Straight from the Official 4.2 Specification
OpenGL version 3.0, released on August 11, 2008, is the eighth revision since
the original version 1.0. When using a full 3.0 context, OpenGL 3.0 is upward
compatible with earlier versions, meaning that any program that runs with a 2.1 or
earlier GL implementation will also run unchanged with a 3.0 GL implementation.
OpenGL 3.0 context creation is done using a window system binding API, and
on most platforms a new command, defined by extensions introduced along with
OpenGL 3.0, must be called to create a 3.0 context. Calling the older context
creation commands will return an OpenGL 2.1 context. When using a forward
compatible context, many OpenGL 2.1 features are not supported.


So now from my understanding, as long as I write my code using an OpenGL 3.0 context, my code is backwards (AND/OR?) forward compatible depending on seemingly various configurations during context setup. But I have also discovered that NeHe's tutorials are painfully old, and should only be used for the concepts presented, so I highly recommend avoiding them. Rendering through VBO's is not as difficult as I had previously anticipated, either.

Useful Resources:

Official 4.2 Specification -
http://www.opengl.org/registry/doc/glspec42.core.20110808.pdf

Information on Context Creation -
http://www.opengl.org/wiki/Tutorial:_OpenGL_3.0_Context_Creation_%28GLX%29
http://www.opengl.org/wiki/Creating_an_OpenGL_Context
http://www.opengl.org/wiki/Core_And_Compatibility_in_Contexts

Kova

I also had the same problem: finding tutorials on opengl core versions... finally I came across book "OpenGL Superbible 5th edition" which is 800 pages long and covers only core opengl. It has it's problems explaining with clarity, but it explains everything you need to get started.