A lightweight 3D graphics library written in C++ for rendering wireframe models with lighting and animation support.
- 3D Math Library: Vectors, matrices, transformations
- Rendering Pipeline: Vertex projection, wireframe rendering, depth sorting
- Lighting System: Lambert shading with multiple light sources
- Animation System: Bezier curves, time-based animations
- Canvas System: Floating-point pixel rendering with bilinear filtering
For detailed documentation, see the Tiny3D Graphics Driver PDF.
Detailed Eiffel Tower with extensive lattice structure and cross-bracing, rotating on Y-axis to showcase all features.
Detailed chess king piece with octagonal base, crown with alternating points, and cross on top.
3D sphere with latitude/longitude wireframe structure, smoothly rotating on Y-axis.
- Polyhedra Shapes - Tetrahedron and octahedron
- Run any test program (e.g.,
.\build\bin\test12_eiffel.exe) - Use screen recording software like:
- Windows Game Bar (Win + G)
- OBS Studio (free)
- ShareX (free)
- Save recordings as MP4 files in
libtiny3d/Captures/folder - Videos will display automatically in this README
libtiny3d/
├── include/ # Header files
│ ├── animation.h
│ ├── canvas.h
│ ├── lighting.h
│ ├── math3d.h
│ └── renderer.h
├── src/ # Implementation files
│ ├── animation.cpp
│ ├── canvas.cpp
│ ├── lighting.cpp
│ ├── math3d.cpp
│ └── renderer.cpp
├── demo/ # Demo applications
│ └── main.cpp
├── tests/ # Test files
│ ├── test_animation.cpp
│ └── test_math.cpp
├── build/ # Build output (generated)
│ ├── obj/ # Object files
│ ├── lib/ # Static library
│ └── bin/ # Executables
├── Makefile # Build configuration
└── README.md # This file
- C++17 compatible compiler (g++, clang++)
- Make build system
# Build everything (library, demos, tests)
make
# Build only the static library
make lib
# Build demo applications
make demo
# Build test executables
make tests
# Run all tests
make run-tests
# Run the demo
make run-demo
# Clean build artifacts
make clean
# Show help
make helpAfter building, link your program against build/lib/libtiny3d.a:
g++ -std=c++17 -Iinclude your_program.cpp build/lib/libtiny3d.a -o your_program#include "math3d.h"
#include "renderer.h"
#include "canvas.h"
int main() {
// Create canvas
Canvas canvas(800, 800);
// Define cube vertices
vec3_t vertices[8] = {
{-1,-1,-1}, {1,-1,-1}, {1,1,-1}, {-1,1,-1},
{-1,-1, 1}, {1,-1, 1}, {1,1, 1}, {-1,1, 1}
};
// Define edges
int edges[12][2] = {
{0,1},{1,2},{2,3},{3,0},
{4,5},{5,6},{6,7},{7,4},
{0,4},{1,5},{2,6},{3,7}
};
// Setup matrices
mat4 model = mat4::translation(0, 0, -5);
mat4 view = mat4::identity();
mat4 projection = mat4::frustumAssymetric(-1, 1, -1, 1, 1, 50);
// Render
renderer_wireframe(canvas, vertices, 8, edges, 12,
model, view, projection, 800, 800);
return 0;
}vec3_t: 3D vector with x, y, z componentsmat4: 4x4 transformation matrix- Matrix operations: translation, rotation, scaling, projection
- Vector operations: dot product, cross product, normalization
renderer_wireframe(): Render wireframe models with depth sortingproject_vertex(): Transform vertices through the graphics pipeline- Circular viewport clipping
Canvas: Framebuffer with floating-point pixel valuesset_pixel_f(): Set pixel with bilinear filteringdraw_line_f(): Draw anti-aliased lines
Light: Directional light with intensitylambert_edge(): Calculate edge lightinglambert_edge_multi(): Multi-light edge lighting
bezier(): Cubic Bezier curve evaluationloop_time(): Time loop helper
This project is provided as-is for educational purposes.
Contributions are welcome! Please ensure code follows the existing style and includes appropriate tests.