About different OpenGL Versions

Started by
11 comments, last by 21st Century Moose 7 years, 10 months ago

I've been working for at least half year in raw OpenGL by making calls to OpenGL32.DLL in windows System32 library. The problem is: I know there are different GPU drivers. Ones support some version of OpenGL, another ones superior versions and I know all support 1.x version...

The problem is: what versions do Windows use in OpenGL32.DLL
I have noticed there are a lot of versions from this library. When I used Windows 7 versions was 5 or 6, now in Windows 10 version is 10.0.

Are there some changes in OpenGL32.DLL versions? Since I program raw code scratch from library calls, can I use later versions (2.0 or 3.x) from this DLL? I mean, how do I know which are the functions OpenGL32.DLL has on each version? Do Windows 10 OpenGL32.DLL version 10.0.1 has OpenGL3 or 4 functions?

What are the disadvantages of using the OS core opengl library?

Why is it not recommended to use OpenGL 1.x? Do GPU companies will stop using it? What will happen to applications maden by calling OpenGL32.DLL?

I understand very good how OpenGL works but not how drivers and extensions work. (I have always used the standard 1.1, not extensions)

I tried searching information about different OpenGL32.DLL versions but all seem to point to old 2.0 which has very old documentation about it's bytecode functions. They're the basic ones from gl.h but... Where is the rest of the new versions code? Are there other OpenGL DLL's to use in extensions? For example, GLU32.dll is another one which offer quadrics and some complex 3D shapes but it also come natively in Windows System32 libraries. Are there other DLL's to enable Opengl 2.x and above use? I readsomething about GLEW. Do GLEW has a GLEW32.DLL file which comes native in Windows? Do this allows me to use different OpenGL versions? Do I have to install more stuff to enable it?

That's what I think is annoying from OpenGL. I don't want my app users to install extra stuff, everything should be already managed by the OS, as OpenGL1.1 does in OpenGL32.DLL on Windows. For example, DirectX natively comes in Windows with different versions (9, 10, 11) so I can directly program to it, but in OpenGL I still can't understand how to use different versions, and it's kind of annoying :c

I'd like to make raw calls to OpenGL but, where or how do I use new OpenGL 2.x, 3.x or 4.x functions?

Advertisement
OpenGL32.dll does not implement OpenGL. It is just the interface between you and whatever the graphics driver offers (or, if no suitable graphics driver is installed the default implementation Windows offers).

Out of the box you will never have anything above OpenGL 1.1 on Windows (unless Microsoft change their policy on this which seems unlikely after all this time). In my personal opinion OpenGL 1.1 is completely useless to do anything interesting. It's missing important features and the only way it allows you to work is horribly inefficient and in a way that is far removed on how you would do anything today (or a decade ago).

So, on Windows you have to query everything above OpenGL 1.1 using the extension mechanism. Obviously you can do that by hand but that is a lot of boring work with a potential for really nasty and annoying errors. There are lots of simple helper libraries for this though, for example GLEW and glbinding immediately come to mind.

OK, some confusion here. Strap in; this could get a bit bumpy.

The opengl32.dll isn't "raw OpenGL"; what it is is a very old version of OpenGL - over 20 years old - that's roughly equivalent in features to Direct3D 3. Using this DLL directly, it's also not hardware-accelerated. It's a software-emulated version of OpenGL that will typically work at something like one frame per second.

This is the first place where things get complicated.

The OpenGL driver model allows your hardware vendor to install another DLL somewhere on your OS. The name and location of this DLL are both vendor-specific, and may change between different driver revisions, so don't rely on it. What then happens is that the opengl32.dll detects if this is present (by reading a registry key) and re-routing all OpenGL calls to it.

So you're not actually calling directly into the opengl32.dll at all. The opengl32.dll is taking your OpenGL calls, checking if the vendor's DLL is present, and calling into the vendor's DLL for you. That's where hardware acceleration comes from.

Different versions of the opengl32.dll - with the disclaimer that this is guesswork, I would suggest that one obvious reason for this is that Windows' underlying driver model changes between different OS revisions. Windows XP and previous used OpenGL on top of GDI, Windows 7 exposed WDDM 1.1, Windows 10 exposes a newer version of WDDM, and the opengl32.dll is obviously updated to support the different driver models.

Either way, you do not get OpenGL 2, 3 or 4 functionality from something as simple as an OS update: OpenGL is not software. As I said above, the actual real DLL that's used is provided by your graphics hardware vendor, and that's where higher versions of OpenGL are exposed.

This is actually not wildly different from the way Direct3D works. Neither OpenGL nor Direct3D are provided by the OS. What the OS does provide is a software layer that allows you, as a programmer, to access the GPU vendor's driver, but the GPU vendor's driver is what actually provides hardware acceleration, and that must be installed by the end user.

It's also the case that OpenGL 1.1 is not the standard. The current standard is OpenGL 4.5; 1.1 just happens to be the only version that is available (software-emulated) on Windows by default, but there's nothing about that that makes it in any way standard, and you shouldn't think otherwise. Different OpenGL versions are broadly analogous to different Direct3D versions (but don't look for a one-to-one mapping because there isn't one).

In order to access higher functionality on Windows, you must use the extension loading mechanism. Don't confuse this with using extensions, because it's not the same thing. What this means is that you continue to #include <gl/gl.h>, you continue to link to opengl32.lib, but then you make a bunch of wglGetProcAddress calls to get function pointers for OpenGL calls from higher versions. You also need to add declarations for these, so the general recommendation is that it's too messy and too error prone and you're better off using something like GLEW instead. (You can statically link to GLEW so that users don't need to install anything).

Like I said, OpenGL 1.1 is a 20+ year-old version and what that means is that it no longer works the way that modern hardware works. And by "modern hardware" I actually mean anything released since about 2001 or so. Since the days of OpenGL 1.1 graphics hardware has evolved significantly, and if you're doing anything moderately complex then OpenGL 1.1 will not give good performance.

Wanting to run on "all hardware" is not a realistic objective. "All hardware" includes really ancient OpenGL 1.0 kit, 3DFX mini-drivers, cripped 1995-era hardware that doesn't expose all the OpenGL 1.1 blend modes properly, etc. You don't want to run on all hardware. What you want instead is to choose a baseline and say that's what you support, but nothing lower. Maybe that baseline is going to be OpenGL 1.1, but in the real world you can rely on OpenGL 2.1 to 3.3 being available on 99%+ of target machines.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

Ohh that's what I was trying to understand @mhagain, I didn't know how OpenGL driver worked, didn't know that OpenGL32.DLL is an invoker of GPU driver.

By performance, I really haven't noticed performance issues an I have achieved a lot of functionalities with 1.1 in modern (2013 - 2015) nVidia - Radeon - Intel APU/GPU's. It's not "one frame per second" as you said and I have done all by hand. Maybe there are some things you can't achieve so easily in 1.1 but I will discover it later.

I haven't tried to call OpenGL in a machine without GPU drivers to see if it's software emulated or if it doesn't work.

By what BitMaster said, I now undertand that the bytecode from the DLL is a common interface for GPU drivers. Thanks, that was really helpful from both of you. That was an interesting doubt I had but didn't find some information about it in google :P Thanks!

So if I really understood, actually what I'm doing when calling opengl32.dll, I'm invoking OpenGL driver from the GPU but not specifically version 1.1, but version my GPU driver support and that version still support some of the old API functions (As wglCreateContext, etc.) but not specifically 1.1 version, but 1.1 API functions over a different OpenGL version?
So that's why there's a lot of people on the net that say "Do not use 1.1 API functions", because now days, recent OpenGL drivers still support old 1.1 fuctions, but they will be removed cause they're deprecated.

So in summary: I'm not actually using OpenGL 1.1, i'm using the X version my GPU support but that X version still support old 1.1 functions and I'm calling them. Is that correct?

As mhagain mentioned, the windows dll is just an interface that is used because microsoft thought over a century of computer technology far from today that it would by great to use OpenGL in there OS and as I remember correctly (I read an articel some years ago) then decided to fiddle on a similar graphics interface on there own that was in the first versions not even as performant as the similar GL implementation was but got better the reason because they had money and didnt let anybody else fiddle on it. On these days there own "super graphics" was born under the name Direct3D.

So the old GL support stayed in there for some reason (I think it is realy complicated to nearly impossible removing such 'Driver' interface from the system so they leaved it in) but and thats the difficulty on it, it does in fact do nothing when you have a newer driver installed from your GPU vendor.

The old 1.1 implementation is a software emulation of that what the GPU does. When you call the wingl dll to initialize, they will check if there is an alternative version of gl and load that into the execution space of opengl32.dll, otherwise fallback to the build in functionality.

When writing a dynamic linked library what the name says is, it is dynamic so you didnt have real functions that directly link to the dynamic code but function pointers managed by windows that will be bound during runtime when you initialiy first time call that function from your code. For example you call to opengls wglGetProcAddress function then there is something in your code that calls the dll handler of wglGetProcAddress that might look like this


PROC wglGetProcAddressEndPoint(LPCSTR name)
{
  if(!wglGetProcAddressPtr)
    dllHandler.LoadFunction("opengl32.dll", "wglGetProcAddress");

  return wglGetProcAddressPtr(name);
}

(psoydo code just to get a sight of how things work in the MS world)

So what does it do is to check if something is bound to the function pointer you were calling if if isnt then ask the dll handler to either load and/or return a function pointer to the memory location where the function was loaded to or crash if it wasnt able to load it.

In fact, using dlls take some kind of performance overhead (that is meaningless on any hardware newer than what you got in the 90s) checking every time that the function you were using is bound before calling into it.

This way the opengl32.dll decides if it needs to load the software emulation mode or could redirect anything iinto the GPU driver and let it handle anything else. That is the reason why you will get different results when calling something basic like wglGetProcAddress that is implemented into the dll source but returns results based on the gl implementation you qeury when context is created.

Thats also the reason why you need to call for a function pointer first that is marked as extension for the specific gl version you decide to use. The dll handler dosent know anything about that because it isnt implemented in the runtime code of opengl32.dll and is never called for that function even if some header file offers it to you. You will either get linker error or null pointer exception when directly call into it from your code.

I hope that helps a little understanding the process that goes on "under the hood" of the windows OS. If you work with different versions of GL I would advice to use a wrapper library because they do all the things the dll handler would normaly do but in a way that you dont need to worry about what is implemented into opengl32.dll and what is driver specific.

Ohh that's what I was trying to understand @mhagain, I didn't know how OpenGL driver worked, didn't know that OpenGL32.DLL is an invoker of GPU driver.
By performance, I really haven't noticed performance issues an I have achieved a lot of functionalities with 1.1 in modern (2013 - 2015) nVidia - Radeon - Intel APU/GPU's. It's not "one frame per second" as you said and I have done all by hand. Maybe there are some things you can't achieve so easily in 1.1 but I will discover it later.


I strongly recommend against this. You will not learn much useful by working with OpenGL 1.1. You will learn some bad habits which will hinder you and need to be unlearned.

I strongly recommend against this. You will not learn much useful by working with OpenGL 1.1. You will learn some bad habits which will hinder you and need to be unlearned.


This.
1000x this.

1.1 is dead.
It is gone.
It is the past.

GPUs have moved on and left it in the dust.
Hell, the term 'GPU' didn't even exist back when 1.1 was a thing.

Forget 1.1 and all the bullshit it brings to the table; 4.x is probably where you want to be, 3.x if you've a fondness for history.

But 1.1... god no... just no.

4.x is probably where you want to be

when you want to be a stickler with that then you need to point to Vulkan!

Not really.

Vulkan (and D3D12) is basically graphics development on Hard Mode.
Unless you need features of it, such as lower CPU overhead coupled with the ability to generate things across threads or a couple of GPU features, then sure go for it. However it also comes with a shit load of extra work you have to do and the trust that you know wtf you are doing - you can, and will, crash the GPU and at least to start with produce horribly performing code.

But OpenGL (and D3D11) still have their place and allow you to get a lot done without having to worry about basically writing a graphics driver and all the bullshit that goes with it.

But OpenGL (and D3D11) still have their place and allow you to get a lot done without having to worry about basically writing a graphics driver and all the bullshit that goes with it.

Exactly this. There will always be a need for some kind of API that exists at a relatively high level of abstraction and allows people to just make API calls without having to worry about the finer details or hardware-level ugliness that Vulkan and D3D12 provide. Today that need is filled by OpenGL and D3D11. In the future it might be a software wrapper around Volkan or D3D12, and when that future happens we can cheerfully forget about today's high level APIs. But that future hasn't happened yet.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

This topic is closed to new replies.

Advertisement