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.

How to open Introduction to 3D Game Programming With DirectX 9.0c: A Shader Approach sample projects with Visual Studio 2013

Frank Luna’s DirectX 9.0c book is excellent, but it can be a pain trying to build the code samples using the latest versions of Visual Studio. Here’s what I did to get it working with Visual Studio 2013 on Windows 7:

First, ensure you have installed the DirectX SDK (June 2010): https://www.microsoft.com/en-gb/download/details.aspx?id=6812

Then add the following directories to your project in Project Properties:

Add the following to C/C++ > General > Additional Include Directories:
$(DXSDK_DIR)Include;C:\Program Files %28×86%29\Microsoft DirectX SDK %28June 2010%29\Include;%(AdditionalIncludeDirectories)

Add the following to Linker > General > Additional Library Directories:
$(DXSDK_DIR)Lib\x86;%(AdditionalLibraryDirectories)

In Linker > Input > Additional Dependencies, change dxerr9.lib to dxerr.lib.

Finally, in the source code, change dxerr9.h to dxerr.h. The project should now compile.