An Experiment: OpenGL Class Targets

According to the documentation, SDL_GL_CONTEXT_MAJOR_VERSION was primarily used to tell SDL which method to use to construct the Window on desktop Open. OpenGL 3.x introduces a new way of context creation, so this would have been used to suggest which way to create (old way or new way). Of course, Mobile needed a way to handle ES 1.1 vs ES 2.0 (and sort-of ES 3.0 too, but so far the ES 3.0 devices are 2.0 compatible).

Rather than just repeat what everyone seems to say and quote, I’m going to try doing just this.

I call this a “Class 2” OpenGL target, referring to an OpenGL 2.x or OpenGL ES 2.0 target (i.e. GL with Shaders).

No #ifdefs. Same code across Desktop SDL and Mobile SDL. Hypothetically speaking it should just work, and if not, I’m not sure why SDL_GL_CONTEXT_PROFILE_MASK is being anal about its mask bit when there really is only one choice (ES on Mobile, OpenGL on desktop).

The other options would be a “Class 3” OpenGL target, i.e. OpenGL 3.x and OpenGL ES 3.0, as well as “Class 1” (OpenGL 1.x and OpenGL ES 1.1).

First I need to see if “Class 2” works safely across PC and mobile devices (FYI I’m only testing Windows, Linux and Android). Then I’m curious if I can set my class to “Class 3”, and whether that safely Inits on “Class 2” devices.

The point: I’d like to just do this, and have it work everywhere.

Two lines. It’s my responsibility to determine if devices even support 3.x features (like it always has been). As far as I know, no hardware optionally goes in to 2.0 mode if 3.0 is available. On desktop GL, you always get the highest version of GL. It’s on mobile GL that we see a distinct ES 1.1 versus ES 2.0 switch.

If I come across any issues, I’ll update the post.

Results: Class 3 will not work on non ES 3.0 mobile devices

Well this was quick. Tried both 2 and 3 on a 2.0 tablet (Galaxy Tab 3), and the 3 setting failed.

Alright then. So the experiment continues with “2” always set.

Results: Class 2

Platforms tested so far:

Untested: Tegra 2 Development Board, Google G1 (no ES 2.0), Netbooks with Intel GMA (no GL 2.x), PocketTV (MALI 400 MP), Workstation PC with NVidia GPUs (broken), GameStick (MALI 400 MP), AMD Netbook, Zotac w/ NVidia ION, AMD PC, IvyBridge Ultrabook.