Advertisement

Origins of Open GL libraries

Started by October 24, 2017 05:52 AM
4 comments, last by DividedByZero 7 years, 3 months ago

Hi guys,

With OpenGL not having a dedicated SDK, how were libraries like GLUT and the likes ever written?

Could someone these days write an OpenGL library from scratch? How would you even go about this?

Obviously this question stems from the fact that there is no OpenGL SDK.

DirectX is a bit different as MS has the advantage of having the relationship with the vendors and having full access to OS source code and the entire works.

If I were to attempt to write the most absolute basic lib to access OpenGL on the GPU, how would I go about this?

There hasn't been a DirectX SDK in more than seven years. The requisite files are built into the development environment. Same deal with OpenGL. You don't ask about the SDK any more than you ask about the SDK for iostream. The headers and libraries are there by virtue of having a sensible build environment for your target platform in the first place.

Similarly, there are platform specific calls to fire the whole thing up in the first place. Once the platform implements OpenGL support, the functions are all part of that same environment.

SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Advertisement

Correct, the DX SDK is now part of the platform SDK (as is your iostream example). You can't use any functions without them. The DirectX portion being written by Microsoft.

So this doesn't really answer my question about Open GL though. How did any of these libraries come into existence if the Kronos group didn't write them? Was it just 'some dude on the street'? And if so, how?

4 hours ago, lonewolff said:

So this doesn't really answer my question about Open GL though.

His point was that it does -- when you install the platform SDK you get d3d11.h and you get gl.h (or more importantly Wingdi.h and Opengl32.lib) -- you can't install the Windows "D3D SDK" without also getting the Windows "GL SDK" :)

4 hours ago, lonewolff said:

How did any of these libraries come into existence if the Kronos group didn't write them?

Look at the source of GLUT/etc... GLUT is in no way essential to GL, it's an application framework for people who don't want to write their main loop. It automates more Win32 programming than it does GL programming ;) It will be more interesting to look at the source for something like GLEW.

Khronos writes the API specifications, from the API specification you can automatically generate the full list of enums, structures and function signatures yourself -- many projects do exactly that. e.g. see https://raw.githubusercontent.com/KhronosGroup/OpenGL-Registry/master/xml/gl.xml which could be used to generate your own gl.h file.

On Windows, you don't talk to your GL driver directly, because it could come from NVidia/AMD/etc... so you need a middle-man to load the GL implementation for you and allow you to connect to it. Every OS/platform has their own separate API for doing this step. On windows, it's wgl, and the most important part is wglGetProcAddress. You pass it the name of a GL function, and it returns you a function-pointer to that function in the implementation (NVidia's/AMD's GL driver). You then cast this function pointer to the correct type (using a typedef that you automatically generated from Khronos' specs) and now you're able to call this GL function.

Other platforms are similar, except with their own API's for looking up GL functions, such as glXGetProcAddress, eglGetProcAddress, etc...

See also: 

 

Thanks man. This post was very enlightening and answered my question perfectly. :)

This topic is closed to new replies.

Advertisement