A very basic software wireframe renderer – source code

I wrote this a few months ago to consolidate my learning on 3D maths. In the spirit of Handmade Hero, it uses no off-the-shelf maths or graphics libraries. The program reads in an OFF model file, triangulates it, and draws the wireframe as a bitmap to a section of memory which is sent to the screen using the Windows API StretchDIBits function:

screen capture2

It’s very rudimentary and I’m sharing this more for those who are interested in looking at the code than for general consumption! With those warnings in mind, you can download the Visual Studio project here. Build with F7, run with F5, and you should see a beautiful sea shell. You have to change the source code to open different models 😉

UPDATE (28 March 2016): As a SIMD learning exercise, I’ve re-written my maths functions to use Intel SSE intrinsics. The frame time is dominated by the time it takes to draw of lines to the screen, so although the vertex transform stage is about 15% faster, the overall frame rate doesn’t go up noticeably. Download the updated Visual studio project here.