General question about OpenGL versions

Hi,

I would like to ask what version of OpenGL I should use when creating multiplatform renderer working also with software OpenGL implementations. It should run on windows(GDI), mac os x and on linux(MESA) as well.

Is there any subset of commands that will work everywhere? My quess is that OpenGL 1.1 is the way to go as it should work on each OpenGL implementation. But what if I needed some feature available only via GLSL? Is mixing of OpenGL versions possible (I mean OpenGL 1.1 with higher ones)?

I do not want to end up with coding as many renderers as there are OpenGL versions.

Any help or clarification would be much appreciated.

Thanks in advance.

I do not want to end up with coding as many renderers as there are OpenGL versions.

Well if that’s the case, why don’t you settle for a GL3 or GL4 render path? Software implementations are good for two things:

a) you want to be able to use OpenGL on hardware that doesn’t support it (or doesn’t support the version you need)
b) you need sort of a ground-truth reference implementation against which other implementations are measured

However, why would you want to code for hardware that’s not at least GL 3.1 capable? Any Sandy Bridge and later laptop out there and any 2008 and later GPU by NVIDIA and AMD support GL3.

The question you should be asking yourself isn’t how to be as compatible to as much hardware as possible, subsequently and inevitably forcing you to reduce the maximum GL version, or worse, forcing you to implement two paths for programmable and non-programmable hardware - it should be “what is my target audience”. If you write new code there is absolutely no reason not to go modern OpenGL, i.e. core GL 3.1 or higher.

Thank you thokra for the reply.

If I got it right, almost every graphics card/driver should be able to run OpenGL v3.1. No matter what OS.

Knowing this I may end up with two renderers:

OpenGL 3.1 with fallback to OpenGL 1.1 (it is required because of Microsoft GDI does not support higher OpenGL versions).

This approach should minimize my efforts.

If I got it right, almost every graphics card/driver should be able to run OpenGL v3.1

No I didn’t say that. What platforms do you want to support? Who is your target audience? What is the purpose of your application?

OpenGL 3.1 with fallback to OpenGL 1.1

Are you aware what that entails? Are you aware of how incredibly limited a GL 1.1 renderer has to be? Do you realize that you would be forced to throw away most of what the GL 3.1+ render path offers?

I agree, this is a key design question you should sort out before deciding rendering paths.

For OSX, take a quick look at the OpenGL capabilities table across OS versions.
If you decide that you only care about supporting Macs capable of running 10.9 (a wise decision, IMHO) then you only have two baselines to deal with, GL3.3 and GL4.1. But go back to 10.7, and you’ll have to deal with a wider range, including the GMA 950 which only supports GL1.4 (plus an assortment of newer features like GLSL, FBOs, VBOs, geometry shader, etc. But not float textures, MRT, integer formats, etc etc.)

For other platforms, you might check stats collected by other companies, like Valve or Unity. That might give you a feel for the range of hardware your customers have.

Thanks for this! Didn’t know they had stats like that too. Very interesting. What’s actually a bit troubling is the share Windows XP still holds - and that there even has been an increase up until 07/2013.

I would like to support MAC OS X 10.9, Windows since Win XP and Latest linux distributions.

I am aware that having two renderers is not good, but I am affraid I have no other way if I want to support Microsoft GDI (default software OpenGL on Windows). Not sure how about MESA on linux, but I think it is already capable of GL 3.1.

Let me ask another question. There are only OpenGL 1.1 headers on Windows. If I want to use GL of higher versions, how do I do it? Yes, I know about GLEW, but I would rather not use it. What should I do? Download latest headers and use only features available on the platform?

Not sure how about MESA on linux, but I think it is already capable of GL 3.1.

AFAIK, the softpipe is still stuck at GL 2.1 - last I tested with 14.04 it still was. But then again, with Ubuntu 13.10 and later you get at least GL 3.1 compliance across all relevant open-source drivers (nouveau, radeon, intel), depending on the hardware capabilities, of course. If you go bleeding edge, you “even” get GL 3.3 compliance for those. Proprietary drivers are way above that anyway, if the hardware permits. At max, NVIDIA provides a GL 4.4 beta driver and AMD currently offers GL 4.3 compliance.

There are only OpenGL 1.1 headers on Windows.

Headers only describe interfaces and say nothing about what the implementation used by the OS is actually capable of. What is done on Windows is that a driver registers itself (in the registry, what a coincidence), and is automatically loaded by the OS. I’m not aware of any way to suppress redirection to the implementation provided by an IHV like NVIDIA, AMD or Intel (With MESA, for instance, you can set an environment variable to explicitly state that you don’t want the vendor-specific driver to be used, but the softpipe). Then again, it wouldn’t make much sense because if you write a GL3 application and decide that you want everything to be rendered by a software-implementation, on Windows you’re out of luck.

If I want to use GL of higher versions, how do I do it?

To the user, the process is quite simple. As soon as the corresponding DLL (or shared object, or dylib) containing the implementation is loaded, you use the platform specific mechanism to retrieve pointers to functions said module, for instance wglGetProcAddress on Windows or the Linux equivalent, glXGetProcAddress. Essentially, this is what GL functions loaders like GLEW boil down to. They do handle a lot of other stuff but to get to GL functionality, getting a valid function pointer is all you need. Be aware that the above functions will return a nullptr if there is no current GL context in the thread from which they are called.

What you as a programmer need to do is use such a loader or write the loading code by hand (pro tip: use the first variant to preserve your sanity). What you need to expect from the user is that a recent driver for their graphics card be installed. The rest is usually handled by the respective operating system.

Download latest headers and use only features available on the platform?

Ready-to-use loaders liker GLEW either provide an updated header already or some loader generators, like glLoadGen, generate the loading code for you as requested. For instance, GLEW generally provides compatibility and core support for every GL version up until GL 4.4 - glLoadGen lets you generate a header for core, compat, for a specific version and possibly with additional extension interfaces, which is a very neat and powerful solution.

Thanks thokra,

your comments are very helpful to me. I will probably use glLoadGen to generate OpenGL 3.1 headers and start with OpenGL 3.1. OpenGL implementations that do not comply to OpenGL 3.1 will fallback to my OpenGL 1.1 renderer (that already exists).
I think it is the reasonable way.

Thank you very much.

that already exists

You could have mentioned this a little earlier, don’t you think? :smiley: Did I overlook it?

You don’t want to support Microsoft’s software OpenGL.

I’m not sure if you’ve actually benchmarked or even tested your program with this implementation - my feeling is that if you had, you’d be running screaming from it. It’s a very very bad software OpenGL implementation, and I don’t mean in terms of functionality (which is as good as one could expect for GL 1.1) but in terms of performance. This isn’t going to give you, say, 50%, 25% or even 10% performance. It’s going to give you ONE FRAME PER SECOND, even with a program as simple as the original Quake, and even on a modern CPU.

It’s 2014 - it’s perfectly reasonable to say that your program requires hardware-accelerated OpenGL, and if a user doesn’t have it you’re not interested in supporting them.

No, I haven’t mentioned that GL 1.1 renderer already exists, but it is not of big importance as I will have to code new features twice (if possible in OpenGL 1.1).

I have mentioned in my first post that I do not want to end up with coding as many renderers as there are OpenGL versions. Having two rendering paths is reasonable for me.

Thanks again!

[QUOTE=mhagain;1257806]You don’t want to support Microsoft’s software OpenGL.

I’m not sure if you’ve actually benchmarked or even tested your program with this implementation - my feeling is that if you had, you’d be running screaming from it. It’s a very very bad software OpenGL implementation, and I don’t mean in terms of functionality (which is as good as one could expect for GL 1.1) but in terms of performance. This isn’t going to give you, say, 50%, 25% or even 10% performance. It’s going to give you ONE FRAME PER SECOND, even with a program as simple as the original Quake, and even on a modern CPU.

It’s 2014 - it’s perfectly reasonable to say that your program requires hardware-accelerated OpenGL, and if a user doesn’t have it you’re not interested in supporting them.[/QUOTE]

No, I haven’t benchmarked GDI renderer, but I agree it is very very slow. But, still I want to support it. I think it is better to see something (e.g. via remote desktop) than being said sorry. And it is more true for very simple or static scenes.

I haven’t benchmarked GDI renderer, but I agree it is very very slow. But, still I want to support it

We still support GDI - it is a great backup for a lot of views but then the code has existed for years so we are not actually developing in GDI.