What version of OpenGL to use?

I´ve been fiddeling around a bit with OpenGL/Lwjgl, but nothing much. Just an asteroidclone, an rotating box and some textures, all drawn out with glBegin(). Later I realised that glBegin is reeeeally old and not the way to do stuff anymore.

Anyways. Now I want to learn more OpenGL but I´m not really sure where to start. Some people seem to be using OpenGL2, some OpenGL3 and somethings are deprecated from version OpenGL3.2 (?). There seems to be little support for OpenGL4 and perhaps even OpenGL3. I hope you can understand the confusion when I wonder: What version should I use to get going? :slight_smile: Perhaps it doesn´t even matter? I would really appreciate some clarity…

ps. I should perhaps clarify that I don´t have a “game” in mind. I just want to learn more about all the cool stuff like shaders and… Stuff… :slight_smile:

If you want to use shaders, OpenGL 3.2 is much better choice than fixed pipeline, old OpenGL. It is much, much harder, but much better performance is worth it.

For newbies, the choice generally boils down to “fixed-function” or “programmable” pipeline.

The fixed-function pipeline has been around since the early days of GL. It has utilities like glFog and glLight that help you light a scene. There is only so much you can do with the fixed-function pipeline, and you won’t really learn the “essence” of graphics programming (IMHO). Most of these features are now deprecated, and you are forced to do it yourself through shaders or custom matrix math. If you wanted to learn this, you would read NeHe and other old tutorials.

The programmable pipeline started with the introduction of shaders (GL 2.0). This means that things like fog, lighting, texture splatting, matrix math, and so forth are all handled with shaders and custom attributes. If you wanted to learn this, you would read ArcSynthesis and other modern tutorials.

As for version, it largely depends on your target audience. If you are doing a 2D game, you probably don’t need geometry shaders, transform feedback, instanced drawing, etc. More important would be a wider playability. Minecraft stats give us a rough idea of casual gamers:
[]49% of users support GL 3 or greater
[
]42% of users only support GL 2.x
[*]9% of users only support GL 1.x

Personally, I would recommend learning the “programmable pipeline” – but targeting GL 2.0. This also means that your code and shaders will be more compatible with OpenGL ES (iOS, WebGL, Android). You can generally read tutorials for 3.2+ and the concepts will transfer over well, but in some cases you may need to make some changes. Particularly, GLSL code will look slightly different in GL 2.0 than it will in GL 3.2+. All in all, it’s not going to be an easy road… :stuck_out_tongue:

All of my tutorials are compatible with GL 2.0 and OpenGL ES:

Here are some other modern tutorials that mostly focus on 3.2+ techniques:
http://open.gl/
http://www.arcsynthesis.org/gltut/ (Java ports)
http://www.opengl-tutorial.org/
http://tomdalling.com/blog/category/modern-opengl/

And the LWJGL wiki also includes some tutorials on shaders and the programmable pipeline.

Go for OpenGL 2.1 is my advice, which lets you use modern features and still gives you access to the majority of desktops.

Cas :slight_smile:

Thank you for great advice and links, as always! No time to waste, better get started.

…And if it´s easy it´s no fun, is it? :slight_smile:

It depends on if it’s a casual game or a more “hardcore game”. Most “hardcore” gamers would have upgraded in the last 3-4 years at least and for sure have gotten OpenGL 3.x or above. The only set back might be mobile, but recent Intel GPU also support it with the latest drivers.

http://www.opengl.org/wiki/Core_And_Compatibility_in_Contexts

My Macbook Air has OSX Mountain Lion - Intel HD Graphics 4000

Compatibility Profile

v1.1 (100 % - 7/7)
v1.2 (100 % - 8/8)
v1.3 (100 % - 9/9)
v1.4 (100 % - 15/15)
v1.5 (100 % - 3/3)
v2.0 (100 % - 10/10)
v2.1 (100 % - 3/3)
v3.0 (95 % - 22/23)
v3.1 (25 % - 2/8)
v3.2 (70 % - 7/10)
v3.3 (10 % - 1/10)
v4.0 (0 % - 0/14)
v4.1 (0 % - 0/7)
v4.2 (0 % - 0/12)
v4.3 (0 % - 0/18)

Core Profile

v3.0 (100 % - 23/23)
v3.1 (100 % - 8/8)
v3.2 (100 % - 10/10)
v3.3 (30 % - 3/10)
v4.0 (0 % - 0/14)
v4.1 (0 % - 0/7)
v4.2 (0 % - 0/12)
v4.3 (0 % - 0/18)

So OpenGL 2.1 in compatibility profile or 3.2 in Core profile if you want it to run on OSX 10.8 (I gather this holds for 10.7 too)