Akil Fernando

Blog

Mar 22, 2025

Learning graphics by writing the renderer yourself

It is easy to put something on screen in a modern engine. Drop in a model, point a camera, press play. I love that convenience. It also always nagged at me, since it hides the exact part I wanted to understand: how a triangle actually becomes a pixel. So I went the slow way and wrote two renderers in C++ by hand, one on OpenGL and one on Vulkan.

OpenGL taught me the pipeline

The first was a flight simulator built straight on OpenGL. No engine. Just the API, some math, and a window.

OpenGL is forgiving enough to learn on, which is what I needed. It carries a lot of state for you, so you can get a spinning, shaded mesh on screen in an afternoon, then spend the next few weeks working out what you actually did. Vertex buffers. The vertex and fragment shader stages. Transformation matrices, the depth buffer. Building a flight sim meant living inside the camera and projection math until, one evening, it stopped being abstract and just made sense. That click is the whole reason I do these projects.

Vulkan taught me how much the driver was doing

Then I rebuilt the idea on Vulkan, and it humbled me.

Vulkan hands you almost nothing for free. You describe everything yourself: the queues, the memory allocations, the synchronization, the entire pipeline state up front. The famous hello triangle runs to hundreds of lines. The first time I typed all of it, I genuinely thought this cannot be the intended way. Then it clicked. Every line Vulkan makes you write is work OpenGL and the driver had been quietly doing on my behalf the whole time. Vulkan just makes you the one holding it.

Why bother

I am not going to argue everyone should write Vulkan by hand. If you want to ship a game, use the engine. I will too. But writing the renderer yourself changes how you think, for good:

  • You stop treating the GPU as magic and start treating it as a machine with a model you can reason about.
  • Performance advice finally lands, because you have felt where the cost lives.
  • Engine abstractions become readable. You know what they are hiding, and why.

The flight sim never became a real game. The Vulkan renderer never drew anything fancy. That was always fine. The point was to remove a layer of mystery, and that part stayed removed.

← All posts