PortableGL: A Real Software OpenGL 3.x Core That Fits in a Single Header
I stumbled across something refreshingly old-school the other day. You know how modern graphics programming usually involves massive driver stacks, platform-specific APIs, and linking against system libraries? Well, what if you could just drop a single C99 header into your project and get a working OpenGL 3.x core profile implementation? No GPU required.
That’s exactly what PortableGL is. No hype, just a clean software rasterizer that implements a subset of the OpenGL 3.x core specification, entirely in C99, and it lives in one header file. It’s like writing software rendering back in the 90s, but with modernish shaders and a proper API.
What It Does
PortableGL is a software implementation of OpenGL 3.x. You call glBegin(), glVertex3f(), glDrawArrays(), and all the other familiar OpenGL functions, but instead of talking to a GPU driver, it renders everything in software on your CPU. It supports vertex and fragment shaders (written in a custom GLSL-like language), it handles transformations, clipping, rasterization, and even texture mapping.
The whole thing is a single portablegl.h header file. You include it, link against nothing else, and you get a framebuffer you can dump to a file or blit to the screen using whatever platform-specific code you want.
Why It’s Cool
First, it’s not a toy. It implements enough of the OpenGL 3.x core profile to run real demos. Think textured 3D scenes with lighting, shaders, and depth buffering. The author, rswinkle, has been working on this for years, and it shows.
But the real killer feature is portability. You can compile this on any platform with a C99 compiler. No X11, no Win32, no GLX or EGL dependencies. The rendering is purely math and memory. That means you can run it on embedded systems, in a Docker container without a GPU, or even in a browser via Emscripten. It’s also incredibly educational if you want to understand how OpenGL actually works under the hood — because you’re reading the source code for it, in one file.
Another neat detail: the shader system is compiled to a simple bytecode and executed in a virtual machine. That’s right, it includes a tiny software GPU shader VM. It’s not fast enough for realtime games, but for learning, prototyping, or running on headless servers, it’s fantastic.
How to Try It
You can grab the code from the GitHub repository. The README includes build instructions for Linux, macOS, and Windows. On most systems, it’s as simple as:
git clone https://github.com/rswinkle/PortableGL.git
cd PortableGL
make
./portablegl_demo
That will compile a demo that renders a textured 3D scene to a PPM file (portable pixmap format). You can open that in any image viewer. Alternatively, the repo includes SDL-based examples that render to a window in real time.
The demos are well commented and show you how to set up shaders, buffers, and draw calls. If you’ve used OpenGL before, you’ll feel right at home.
Final Thoughts
PortableGL is one of those projects that makes you smile. It’s not trying to replace your GPU or ship a AAA game engine. It’s a clean, well-documented, single-header implementation of a complex graphics API, written in plain C. For anyone who loves graphics programming, it’s a great resource to study, hack on, or use in niche situations where you want OpenGL compatibility without the overhead of a real driver.
If you’ve ever wanted to do software rendering with a proper API, or you just like well-written C code, give it a spin. It’s refreshing.
Brought to you by @githubprojects
Repository: https://github.com/rswinkle/PortableGL