The Big Picture: What Is a Graphics API?
An API (Application Programming Interface) is a menu of requests that a program can make. For graphics, the menu has items like "draw these triangles", "load this texture", "show the finished picture".
Without an API, every game would need different code for every GPU model. With an API, the game writes its requests once. The API and the display driver (Section 2) then turn those requests into commands for whatever GPU is installed. (See Chapter 23 — Windows APIs for APIs in general.)
Analogy: An API is a restaurant menu. You order "pizza" without knowing how the kitchen works. Different kitchens (GPUs) cook it their own way, but you get a pizza either way.
The path of a graphics request:
Application (game, browser, app)
│ "draw these triangles"
▼
Graphics API runtime (Direct3D, OpenGL or Vulkan)
│ checks the request, tidies it up
▼
User-mode driver (UMD) <- from the GPU vendor
│ turns it into command buffers
▼
Windows graphics kernel (dxgkrnl.sys: scheduler)
│ decides when this work runs
▼
Kernel-mode driver (KMD) -> the GPU
A command buffer is simply a list of instructions for the GPU, written into memory. The GPU then reads the list and carries it out, while the CPU gets on with other work.
3.1 DirectX (Direct3D)
What it is: DirectX is Microsoft's family of multimedia APIs for Windows. Its most important member is Direct3D, the one for 3D graphics. People often say "DirectX" when they mean Direct3D.
| Version | What to know |
|---|---|
| Direct3D 11 | Older, easier to use. The driver does a lot of the hard work for the programmer. Still used by many programs |
| Direct3D 12 | Newer, "closer to the hardware". The game does more of the work itself and can use many CPU cores to prepare commands. Faster, but harder to program |
Other pieces of the DirectX family you will hear about:
| Part | Used for |
|---|---|
| Direct2D | Fast 2D shapes and graphics on the GPU |
| DirectWrite | High-quality text drawing |
| DXGI | Plumbing: lists the GPUs and monitors, creates the swap chain (Section 7) |
Direct3D is Windows only (also used on Xbox). Most Windows PC games use it.
Old-style 2D drawing. Plain Windows programs used to draw buttons and text with GDI (Graphics Device Interface), the classic 2D API that has existed since early Windows. It is simple and still works, but it was designed long before GPUs mattered. Modern apps use Direct2D and DirectWrite instead. The DWM (Desktop Window Manager, Chapter 30 — Windows Desktop Internals) then combines all these windows on the GPU.
3.2 OpenGL
What it is: OpenGL is an older, open graphics API (not owned by Microsoft) that works on Windows, Linux and (in the past) macOS. It was the main alternative to DirectX for many years. Many professional 3D and design programs and older games use it.
On Windows, the OpenGL library is a thin layer, and the GPU maker's driver provides the real implementation. OpenGL is mature, but newer APIs have mostly taken over for new games.
3.3 Vulkan
What it is: Vulkan is a modern, open API, designed for the same goals as Direct3D 12: close to the hardware, low CPU overhead, many CPU cores can prepare commands in parallel. It is managed by an industry group called Khronos (the same group behind OpenGL).
Vulkan runs on Windows, Linux and Android. Many modern games offer Vulkan as an option.
What about Apple? Apple computers use Metal, Apple's own API. It does not exist on Windows. It is mentioned here only so you recognise the name.
| API | Owner | Runs on | Style |
|---|---|---|---|
| Direct3D 11 | Microsoft | Windows, Xbox | Easier, driver does more |
| Direct3D 12 | Microsoft | Windows, Xbox | Low-level, fast, harder |
| OpenGL | Khronos (open standard) | Windows, Linux, others | Older, widely supported |
| Vulkan | Khronos (open standard) | Windows, Linux, Android | Low-level, fast, harder |
| Metal | Apple | Apple devices only | Apple's low-level API |
3.4 How an App Chooses and Uses an API
What happens: The programmer decides which API to use when writing the program. At start-up the program asks the API to create a device (a connection to a GPU). If the GPU or driver does not support the needed features, the program may fall back to an older version or show an error such as "your graphics card does not support DirectX 12".
Many games have a setting like "Graphics API: DirectX 11 / DirectX 12 / Vulkan". If a game crashes with one, trying another is a common fix.
What the API actually does (the main requests):
| Request type | Example |
|---|---|
| Create resources | Load a texture (image) or a 3D model into VRAM |
| Set state | "Use this shader program; blend colours like this" |
| Draw | "Draw these 3,000 triangles" (a draw call) |
| Present | "The picture is finished; show it" |
Draw calls cost CPU time. Each draw call needs a little CPU work to prepare. Too many tiny draw calls can make the CPU the bottleneck even when the GPU is idle. This is one of the reasons Direct3D 12 and Vulkan exist.
API versus driver versus hardware. The three must match:
| Layer | Question it answers |
|---|---|
| GPU hardware | What can the chip physically do? |
| Driver | Does the software expose those features to the API? |
| API version | Does the program's chosen API support those features? |
If any layer is too old, the feature is not available. That is why updating the driver can fix a game that "doesn't start".
Where to check: Run dxdiag and open the Display tab. It lists "Feature Levels" and which DirectX features are enabled. The first page, System, shows the DirectX Version (this is the version of the DirectX runtime, not a promise that your GPU supports everything in it).
Summary
| Topic | Remember this |
|---|---|
| API | A menu of graphics requests, so programs need not know each GPU |
| Request path | App → API runtime → user-mode driver → command buffers → kernel scheduler → GPU |
| Command buffer | A list of GPU instructions stored in memory |
| Direct3D | Microsoft's 3D API; 11 is easier, 12 is faster but harder |
| GDI / Direct2D / DirectWrite | Classic 2D drawing, and the modern GPU-based 2D and text APIs |
| OpenGL | Older open API, works on several systems |
| Vulkan | Modern open low-level API (Khronos) |
| Metal | Apple's API, not on Windows |
| App choice | The program picks an API; many games let you switch in their settings |