I've always been curious, how libraries such as DirectX, OpenGL and OpenAL are implemented. Do they use some sort of unified API provided by OS? Talk directly to kernel? Maybe hardware drivers provide unified API? Or vendors provide their own backends to such libraries? Even entire implementations of such libraries? Or such libraries handle different drivers on their own?
OpenGL is normally implemented by the hardware vendor, as part of their driver. On Windows, this is done as an ICD - Installable Client Driver. On Linux, it's often implemented as a backend driver for Mesa (an OpenGL-compatible library), but binary drivers like NVIDIA's usually have a custom-implemented
DirectX is quite different: The software vendor (Microsoft) provides a unified driver API that the hardware vendor is expected to develop against, and a set of standards (WIHL, among others) that are expected to be followed.
OpenAL is an altogether different beast. Since it's only really written to provide hardware support for Creative Labs' own cards, there's really only the one hardware driver - all other sound cards use a software mixer implementation (of which there are a few different ones).
It's very rare for hardware drivers to implement their own unified API below OpenGL or something like OpenAL. The reason for this is that the specification leaves the matter of implementation completely open. DirectX essentially enforces a hardware API by its design, but this API is never exposed to userland software.
(As a side note, Mesa is having its guts replaced with Gallium3D, a unified API for hardware drivers, and Gallium3D is generalized enough that a complete DirectX 10/11 source-compatible library stack has been implemented on top of it. No hardware vendors to my knowledge offer Gallium-compatible drivers, and all of the existing drivers are based on the open source drivers already used by X.org and Mesa.)