Question

OpenGL is an interface to perform graphical commands. Now, if the library is multi-platform how does it interact with the GPU is it by making system calls and thus making it multi-platform or does it use drivers to perform its operations?

Was it helpful?

Solution

OpenGL is typically implemented as part of the graphics drivers. Each implementation will use implementation-specific interfaces to talk to some kernel-space component and the real HW.

One can see a bit more how these things might be done by looking at the MESA based open-source GL implementation on Linux. They actually use the DRM (direct rendering manager) API of the Linux kernel to talk to the HW. MESA's current implementation is organised such that for each GPU, there is a drm kernel driver and a user-space DRI client. Mesa now uses the gallium API as an abstraction layer to keep the GPU-specifc code small and make it more portable. The OpenGL API is implemented on top of that as a "state tracker:, and is independent of the GPU drivers. (There even has been a D3D10/11 state tracker, but it was more like a test and was later removed because it became unmaintained.)

The fact that OpenGL is defined as a plaform-independent API does not mean that the OpenGL library will be platform-independent at all. This is the same situation as with the C library API is part of the language standard, but the implementation is very platform-specific.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top