Repository navigation
Examples
Seth Kitchen edited this page Sep 15, 2026
·
15 revisions
examples/. Each example is one program that renders one image or animation into out/. make animation renders them all.
Run one by hand:
mkdir -p out
.venv/bin/mojo run -I . examples/cubes.mojo out/cubes.png| Example | Output | Shows |
|---|---|---|
triangle.mojo |
triangle.png |
One flat triangle. The smallest program that draws. |
spin.mojo |
spin.png |
A turning triangle. The first animation. |
cube.mojo |
cube.png |
A cube through a model matrix, with culling and depth. |
cubes.mojo |
cubes.png |
Two cubes on a scene graph. A small one orbits behind a large one. |
uv.mojo |
uv.png |
Perspective-correct against affine interpolation, two frames. |
textured.mojo |
textured.png |
Two checkerboard cubes, nearest and bilinear. |
glass.mojo |
glass.png |
Three translucent panes over a solid cube, sorted and blended. |
floor.mojo |
floor.png |
A floor to the horizon, mipmapped on one side. |
photo.mojo |
photo.png |
A decoded PNG on a cube, with the camera on an orbiting node. |
lamps.mojo |
lamps.png |
Three colored lights and a point light on a coarse sphere. |
first_scene.mojo |
first_scene.png |
The first tutorial. |
lit_scene.mojo |
lit_scene.png |
The second tutorial. |
photo.mojo takes the image path first: examples/photo.mojo assets/brick.png out/photo.png.
Animated outputs are APNG files. A browser or VS Code plays them. A viewer that does not know APNG shows the first frame.
| Program | Shows |
|---|---|
bench/raster_bench.mojo |
CPU against GPU rasterization across image sizes. |
bench/scene_bench.mojo |
Each stage of the CPU renderer, one worker and every core. |
| Program | Shows |
|---|---|
tools/gpu_status.mojo |
Whether an accelerator is present. |
tools/doc_lint.mojo |
Whether the documentation follows the writing rules. |
Tutorials
How-to
Reference
- Scene graph
- Rotations
- Cameras
- Geometry
- Geometry addons
- Lofts and clipping groups
- Sculptor
- Procedural generators
- Meshes and assets
- Lines
- Points and sprites
- Helpers
- Scene objects
- Animated objects
- Raycasting
- Curves and paths
- Animation
- Skinning
- Materials
- Node materials
- TSL functions
- Lights
- Lighting addons
- Fog
- Textures
- Renderer
- Renderer hooks and material flags
- Rasterization
- GPU backend
- Render target
- Post-processing
- GPU computation
- Compute nodes
- Progressive light map
- Gaussian splats
- Voxel global illumination
- SVG renderer
- Image files
- Image decode queue
- Model files
- More model files
- Exporters
- Scene JSON
- Windowing and controls
- Math
- Norm consumers
- Math addons
- Units
- Coverage tool
- Commands
- Examples
- Benchmarks
- Extensions
- Shared physics
- Physics query snapshots
- Continuous collision
- Tick force restoration
- Water
- Streamline
- Animals
- Buildings
- CARLA
- Femur
- Tibia
- Fibula
- Patella
- Knee
- Muscles
- Vessels
- Lymph
- Nerves
- Integument
- Leg
- Foot
- Pelvis
- Torso
- Arm
- Hand
- Head
- Genome
- Game humanoid
- Humanoid fidelity
- Audio-aligned game faces
- Converted assets
- Mesh quality
- Segment inertia
Explanation
- Software rasterizer
- Scene graph as an array
- Linear color
- Normals are not colors
- Perspective correction
- Fixed-point coverage
- Per-fragment shading
- Mipmaps
- Sorted transparency
- Types and checks
- Render hooks as a trait
- Shared CPU and GPU code
- Bands and threads
- PNG structure
- Extensions beside the port
- CUDA teardown hang
- Mojo compiler hang