What version of OpenGL should I code for, given compatibility and performance conside

When the OpenGL spec is updated, they only ever add features. So in theory, the latest and greatest hardware with support for the Core and Compatibility profiles should run super old OpenGL1.1 code just fine. This has turned out to be true. I’ve spent 12 months learning OpenGL1.1 and have a fair grasp on it.

I had a read of a few chapters of one of those fancy new OpenGL4.2 books. Almost all of the features that I rely on have been deprecated (like Display Lists), which lets me assume that there are better ways of doing all these things.

Lets consider that 1.1 is likely to be supported, in full, by ALL modern hardware. 1.1 was released in 1992. I’m not coding the hard way just to support 20 year old PCs. :-p I think its reasonable to assume most gamers are running hardware that bottoms out at about 5-year old mid range.

I think the newer methods are designed to universally be either one of two things: better performing, or easier to code. I read somewhere that its never both though! XD

What version of OpenGL is most widely supported by ~5ish year old hardware? What version makes most sense to use, given these considerations?

I’d say GL 3.x is your best bet, it’s what I use.
It’s been around long enough for the majority of entry-level gaming PCs made within the past few years to support it efficiently, and it’s modern enough that you’re not really missing out on much that you’d have with GL 4.x, aside from a bit of “under the hood” sort of stuff.

Most of the performance gains will come from using two features: buffer objects and shaders. Both of those are present in OpenGL 2.0. So if you’re trying to find the optimum balance between compatibility and performance, I’d suggest using 2.0 as a reference point then evaluating more recent features on their merits (i.e. how much does it affect performance and how much compatibility will you lose).

OTOH, there’s very isn’t much hardware which supports OpenGL 2.0 which doesn’t also support 3.0. OpenGL 2.0 was developed during a period of rapid advancement in graphics hardware, and was the first version to incorporate GLSL shaders in the core standard. If you’re willing to trade a small amount of backward compatibility for a significant number of new features along with improved forward compatibility, I’d suggest using 3.0 as the reference point.

OpenGL versions are mostly upwards compatible and practically all new features are available as extensions, so you could use e.g. tesselation shaders, persistent buffer mappings and shader storage buffer objects in OpenGL 1.1, if the required extensions are present. Between OpenGL 3.0 and 3.2 there was a deprecation/removal step, where all the OpenGL functions that didn’t correspond to DirectX functionality have been removed. From 3.2 everything is upwards compatible again.

I usually take the 3.2 core profile as base and use the newer functionality via extensions.

Correct, but let’s not forget that this only is true on Windows and Linux, where you are mostly guaranteed to have GL 3.0 with most modern stuff available through extensions.

On MacOSX, that’s not the case. You either get GL 2.1 or 3.2+ core profile, and the 2.1 profile is intentionally crippled not to have most modern features available. So if for some reason you need some deprecated feature and some modern stuff, bad luck, you are screwed.

I had to discontinue Mac support for one of my applications because I couldn’t take out all immediate mode rendering without hitting a serious bottleneck with buffer updates.