3D Go Renderer

From-scratch OpenGL renderer in Go · 2026
Orbit camera demo[opengl 4.1]

A from-scratch 3D renderer in Go — custom .obj/.mtl parsing, ear-clipping triangulation, and an OpenGL 4.1 pipeline with zero steady-state heap allocations.

Allocs/frame
0.06
Parser
Concurrent
UV modes
3

Problem: scop is 42's OpenGL project — render a 3D .obj model with only a math library and raw OpenGL bindings as external dependencies. There's no scene-graph, no asset pipeline, no glTF loader to lean on: the file parser, the vector and matrix math, the triangulation, and the camera all have to be built from first principles.

Solution: The result is a Go renderer on OpenGL 4.1 core with GLFW for windowing. Custom .obj and .mtl parsers handle geometry and material properties (Ka/Kd/Ks/Ns/map_Kd) with graceful degradation when texture files are missing, and three automatic UV-generation modes — planar, cylindrical, spherical — cover models that ship without texture coordinates. An orbit and free-fly camera sit on top of hand-written vec2/3/4 types and column-major mat4 math, including perspective and lookAt transforms, with no external math dependency.

Technical Approach: Two problems needed real solving. Arbitrary polygons — including concave, non-planar, and degenerate ones — get triangulated with ear clipping over each face's Newell-normal plane, so geometry stays correct regardless of how the source .obj was authored. And the render loop is allocation-free at steady state: a single VAO/VBO/EBO per model with vertex deduplication, Gribb–Hartmann frustum culling, and texture-state batching bring it to 0.06 allocs/frame under -debug. Parsing itself is parallelized — worker goroutines pre-parse vertex and face data per line-aligned chunk, the same concurrency discipline behind the ELO Leaderboard's match processing.

Results & Learnings: On the Utah teapot, concurrent parsing cut load time from 9.9ms to 7.0ms, and unit tests cover the parser, triangulation, UV generation, math, camera, and frustum culling. Building a rasterization pipeline by hand — after a SIMD raytracer the semester before — made the tradeoffs between rasterization and ray tracing concrete in a way tutorials never do.

Language
Go
Graphics
OpenGL 4.1 · GLFW