This project is a simple 3D software renderer written in C, using SDL2 for windowing and input. It demonstrates the core concepts of a 3D game engine, including mesh loading, transformations, camera movement, lighting, and rasterization.
- Loads and displays multiple 3D meshes (OBJ format) with PNG textures.
- Supports basic camera controls (move, rotate, follow an object).
- Implements a full 3D graphics pipeline:
- Model, world, view, and projection transformations
- Backface culling and frustum clipping
- Perspective projection and viewport mapping
- Simple directional lighting and shading
- Multiple render modes: wireframe, filled, textured, etc.
- Keyboard controls for switching render modes and moving objects/camera
ESC: Quit1-6: Switch render modes (wireframe, filled, textured, etc.)C/X: Toggle backface culling- Arrow keys: Move camera forward/backward and rotate yaw
W/S: Pitch camera up/downH: Move the F117 mesh forwardI: Toggle F117 mesh auto-move (camera follows)Y/P: Yaw F117 mesh left/rightU/O: Roll F117 mesh right/leftJ/K: Pitch F117 mesh up/down
- Game Loop: The main loop processes input, updates the scene, and renders each frame.
- Meshes: 3D models are loaded from OBJ files, with optional PNG textures.
- Transformations: Each mesh is transformed from model space to world space, then to camera (view) space, and finally projected to 2D screen space.
- Camera: The camera can be moved and rotated, or set to follow a mesh.
- Lighting: Simple directional lighting is applied per triangle.
- Rendering: Triangles are rasterized to the screen using different modes.
- C compiler (C99 or later)
- SDL2 development libraries
- (Optional) Visual Studio for Windows development
- Install SDL2 development libraries for your platform.
- Open the project in Visual Studio, or use your preferred build system.
- Build the project. Make sure the
assets/folder with OBJ and PNG files is present.
src/- Source code filesassets/- 3D models and texturesmain.c- Main entry point and game loopmesh.c/.h- Mesh loading and managementvector.h,matrix.h- Math utilitiestriangle.h- Triangle and rasterization logicclipping.h- Frustum clippingcamera.h- Camera logiclight.h- Lighting logictexture.h- Texture samplingupng.c/.h- PNG loading
- Based on educational material from Pikuma and other open-source 3D software renderers.
- Uses SDL2 and a minimal PNG loader.
This project is for educational purposes. See source files for third-party license information.