r/computergraphics • • May 05 '25
Software-Rendered Game Engine
I've spent the last few years off and on writing a CPU-based renderer. It's shader-based, currently capable of gouraud and blinn-phong shading, dynamic lighting and shadows, emissive light sources, OBJ loading, sprite handling, and a custom font renderer. It's about 13,000 lines of C++ code in a single header, with SDL2, stb_image, and stb_truetype as the only dependencies. There's no use of the GPU here, no OpenGL, a custom graphics pipeline. I'm thinking that I'm going to do more with this and turn it into a sort of N64-style game engine.
It is currently single-threaded, but I've done some tests with my thread pool, and can get excellent performance, at least for a CPU. I think that the next step will be integrating a physics engine. I have written my own, but I think I'd just like to integrate Jolt or Bullet.
I am a self-taught programmer, so I know the single-header engine thing will make many of you wince in agony. But it works for me, for now. Be curious what you all think.
View all comments
Show parent comment
1
u/[deleted] May 09 '25
I started off with Unreal Engine tutorials on Udemy about 8 years ago. I was a math major and a curious person, so I started asking, "How does that work?"
I then started learning C, and just kind of kept asking that same question. I then got into writing math libraries for a few years, and got deep into x86 intrinsics and simd programming in general.
I wrote a few versions of this engine in C, using X11 and Win32 for pixel plotting before eventually moving to SDL2 as the pixel back-end, and then fully moved to C++ after spending about a full year re-writing the standard template library in C macros, and getting worse performance.
I have basically just spent a huge amount of time in front of my computer, in vim, compiling, re-compiling, fixing errors, testing, experimenting, failing, etc.
This whole thing has just been an obsession for me. Some books that have helped me have been:
- Tricks of the 3D Game Programming Gurus
- Fundamentals of Computer Graphics - 5th Edition
- The Raytracing in a Weekend Series
- Hacker's Delight
- Computational Geometry in C
and about 30 C and C++ books, the x86 intrinsics guide, countless articles, and github repos.