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 |
Copyright (c) 2024 Georgi Nikolov
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.