Moving to GLSL 1.5 / OpenGL 3.2 Core Profile

Started by lightbringer, November 11, 2009, 11:54:03

Previous topic - Next topic

lightbringer

I recently (as in, yesterday) bid farewell to OpenGL backward compatibility and moved into OpenGL 3.2/GLSL1.5, and I documented some of my efforts on my game's blog. Hopefully that post will do more good than harm. It's all working code, but if you guys see anything glaringly wrong or misguided, do let me know. Since there's not much out there on this stuff, I think that having actual examples of how it can be done in LWJGL won't hurt, even if 70% of it is self-explanatory  ;D.

spasi

Interesting blog, thanks! If you encounter anything missing or stuff that shouldn't be there (from the deprecated features), let me know and I'll do my best to fix any issues asap. I haven't moved to 3.2/core yet so LWJGL is kinda under-tested when it comes to latest OpenGL features.

lightbringer

Will do, though usually it's all an error on my part. Like when I accidentally switched zNear and zFar when refactoring the camera code yesterday, and then spent an hour wondering why closer objects disappear behind ones farther back. ^_^;;;

lightbringer

One thing that should probably go in the forward-compatible context is glLineWidth(). I'm still able to call it even tho spec p329 says it should be unloaded in forward. I didn't test if it actually has any effect on lines since retooling the pipeline to draw a line would be a bit of a pain at this moment.

spasi

LineWidth was not deprecated in OpenGL 3.0, but calling LineWidth with a value greater than 1.0 would result in an error. Anyway, they've changed their mind about that and OpenGL 3.1+ allows wide lines again.

lightbringer

Well, it's not really clear to me. "The following features are deprecated, but still present in the core profile. They may be removed from a future version of OpenGL, and are removed in a forward-compatible context implementing the core profile." This seems to refer to 3.2 since core profile was defined in 3.2. It sounds to me like they're at it again, since it's general knowledge that the ARB can't make up their minds about something as banal as line width ^_^ Not to mention just the other day we found what appear to be some mistakes in the official GLSL spec...

But, well, it does work. Lines are thicker. I forgot that I had a wireframe mode set up, and today when I switched it on it was very apparent.

spasi

Yeah, it's a mess, kinda. Let me try to explain things a bit.

-- OpenGL 3.0 --

The first version that introduced deprecation:

QuoteFunctions which are completely deprecated will generate an INVALID OPERATION error if called in a forward-compatible context. Functions which are partially deprecated (e.g. no longer accept some parameter values) will generate the errors appropriate for any other unrecognized value of that parameter when a deprecated value is passed in a forward-compatible context.

and a bit below:

QuoteWide lines and line stipple - LineWidth is not deprecated, but values greater than 1.0 will generate an INVALID VALUE error

So, under 3.0, you still see glLineWidth exposed, but calling it was either a NO-OP or an error.

-- OpenGL 3.1 --

Removed the deprecated features by default, you needed ARB_compatibility exposed to be able to use them. Except glLineWidth. ;)

QuoteUnlike earlier versions of OpenGL, OpenGL 3.1 is not upward compatible with earlier versions. The commands and interfaces identified as deprecated in OpenGL 3.0 (see appendix F) have been removed from OpenGL 3.1 entirely, with the following exception:

- Wide lines have not been removed, and calling LineWidth with values greater than 1.0 is not an error.

Implementations may restore such removed features using the ARB extension discussed in section G.2.

So, calling glLineWidth with any value >= 1.0 under 3.1+ should work as expected.

-- OpenGL 3.2 --

Under 3.2, we have 2 profiles:

Core = 3.1 + new 3.2 features, no deprecated features present. glLineWidth is still there and working, according to the 3.1 spec.
Compatibility = 3.1 + ARB_compatibility + 3.2 features, deprecated features work.

QuoteSeparate versions of the OpenGL 3.2 Specification exist for the core and compatibility profiles described in appendix E, respectively subtitled the “Core Profile” and the “Compatibility Profile”.
...
The OpenGL 3.2 core profile is upward compatible with OpenGL 3.1, but not with earlier versions (see appendices G and F).
The OpenGL 3.2 compatibility profile is upward compatible with the combination of OpenGL 3.1 and the GL_ARB_compatibility extension, as well as with all earlier versions of OpenGL.

I hope this helps.

lightbringer

What it amounts to is that they cannot keep the new spec straight and without contradictions. I am slowly getting used to that, now :)