3D renderer written as an exercise to learn C and how graphics APIs such as OpenGL are implemented under the hood.
- Software rasterization
- Pure C17 implementation
- Right hand Y-up coordinate system
- Uses SDL for access to graphics hardware, mouse, keyboard, etc.
- Supports native and web via emscripten
- Perspective correct interpolation
- Support for vertex and fragment shaders
- Depth buffer
- Face culling
- Viewport clipping
- Loading and parsing Wavefront .OBJ files and PNG images
- Cube map sampling
Clone the project and run in the terminal:
make build DEMO_NAME=DESIRED_DEMO_NAME
make run DEMO_NAME=DESIRED_DEMO_NAME
Where DESIRED_DEMO_NAME
is the demo you want to build and run.
Here is a full list of the demo names:
GEOMETRY_EXAMPLE
SHADOWMAP_EXAMPLE
PHYSICS2D_EXAMPLE
DEPTHBUFFER_EXAMPLE
ENVIRONMENTMAPPING_EXAMPLE
PLASMA_EXAMPLE
TUNNEL_EXAMPLE
Clone the project and run in the terminal:
make build-emscripten DEMO_NAME=DESIRED_DEMO_NAME
To run the web server to view it in a browser run:
npm i
npm start
This will start a local web server you can open in your browser of choice.
Geometries |
Visualised depth buffer |
Environment mapping |
Plasma |
Tunnel |
2D Physics |