This project is a custom-built 3D renderer written in C, using SDL2 for the GUI interface and developed from scratch. It utilizes a left-handed coordinate system and is designed with a focus on understanding 3D graphics fundamentals. This project follows along with the Pikuma course, while implementing my own coding style and ideas, as the course encourages.
- SDL2 Initialization: Sets up SDL2 for handling graphics output and allocates necessary memory.
- Projection and Drawing:
- Projects 3D points onto a 2D plane for rendering.
- Draws lines, rectangles, and triangles to construct 3D objects on the screen.
- OBJ File Loading: Imports
.obj
3D model files to render complex geometries. - Back-Face Culling: Uses a basic back-face culling algorithm to optimize rendering by skipping faces that are not visible to the camera.
- Triangle Rasterization (done, but currently in tweaking): rasterization to accurately fill in triangles for solid object rendering.
- Pressing “1” displays the wireframe and a small red dot for each triangle vertex
- Pressing “2” displays only the wireframe lines
- Pressing “3” displays filled triangles with a solid color
- Pressing “4” displays both filled triangles and wireframe lines
- Pressing “c” we should enable back-face culling
- Pressing “d” we should disable the back-face culling This might be changed later on for better features.
- Install SDL2 on your system.
- Clone the repository:
git clone https://github.com/your-username/3d-renderer.git
- Navigate to the project directory and build
cd 3dRenderer make
- To run the executable:
make run
- To clean the build files
make clean
To import other .obj
files, call the loadObj function in the src/main.c
file. Please ensure the model uses triangles as faces for compatibility.
After building, run the executable:
bash ./renderer
- Pikuma's course: This project was inspired by and developed following the Pikuma course on 3D graphics, adapted to my own coding style and approaches as encouraged by the course materials.
- SLD: A lightweight, cross-platform library for handling media and graphics, which powers the GUI in this project.