A lightweight, modern 2D/3D game framework built on SDL3 and Metal (macOS/iOS) or Vulkan/Direct3D (cross-platform via SDL3 GPU backend).
-
2D Rendering: High-performance batch-based 2D renderer with:
- Texture rendering with rotation, scaling, and tinting
- Custom fragment shader support per-draw-call
- Shape drawing (rectangles, circles, lines, triangles)
- Text rendering with built-in font
- Automatic batching for optimal performance
-
3D Rendering: Basic 3D capabilities including:
- Mesh loading and rendering
- Instanced rendering support
- Perspective camera
-
Asset Management:
- Texture loading (PNG, JPG via stb_image)
- Procedural texture generation (checkerboard, gradients, solid colors)
- Shader loading (SPIR-V, MSL)
- Audio loading and playback
-
Physics: Box2D integration for 2D physics simulation
-
Scene Management: Scene switching and lifecycle management (create, update, render, destroy)
-
Additional Systems:
- Tweening/animation system
- Tilemap loading and rendering (WIP)
- LDTK level editor integration (WIP)
- Input handling (keyboard, mouse, gamepad)
- Camera systems (2D and 3D)
- CMake 3.20+
- C compiler (Clang, GCC, or MSVC)
- SDL3 (automatically fetched by CMake)
- Box2D (automatically fetched by CMake)
mkdir build && cd build
cmake ..
make -j$(nproc)mkdir build && cd build
cmake .. -G "Visual Studio 17 2022"
cmake --build . --config Release#include <moss/moss.h>
void render(MossApp *app) {
begin_2d(app, NULL);
draw_rect(app, RECT(100, 100, 200, 150), RED);
end_2d(app);
}
int main() {
MossApp *app = create_app(&(MossConfig){
.title = "My Game",
.width = 800,
.height = 600,
.target_fps = 60,
});
run(app, &(Scene){ .on_render = render });
destroy_app(app);
return 0;
}TextureHandle player;
void create(MossApp *app) {
player = load_texture(app, "assets/player.png");
}
void render(MossApp *app) {
begin_2d(app, NULL);
draw_texture(app, player, VEC2(100, 100), WHITE);
end_2d(app);
}// Load shaders
ShaderHandle wave = load_shader(app, "shaders/wave.metal");
// Draw with custom shader using draw_texture_opts
draw_texture_opts(app, &(DrawTextureOptions){
.texture = texture,
.position = VEC2(100, 100),
.tint = WHITE,
.shader = wave
});The examples/ directory contains 16 progressive examples:
- 01_hello_window - Basic window creation
- 02_input_scene - Input handling and scene switching
- 03_shapes - Drawing shapes
- 04_sprites - Textures and procedural generation
- 05_objects - Object/component system
- 06_collision - Basic collision detection
- 07_tweens - Animation tweening
- 08_text - Text rendering
- 09_tilemap - Tilemap loading and rendering
- 10_3d_cube - Basic 3D rendering
- 11_mixed_2d_3d - Combining 2D and 3D
- 12_arrows_game - Simple game example
- 13_physics - Box2D physics
- 14_ldtk - LDTK level loading
- 15_scenes - Scene management
- 16_shaders - Custom fragment shaders
Run an example:
./bin/04_sprites├── include/moss/ # Public API headers
├── src/ # Framework implementation
├── examples/ # Example programs
├── deps/ # Third-party code (stb_image, cJSON)
├── docs/ # Documentation
└── build/ # Build artifacts (generated)
create_app()/destroy_app()- Application lifecyclerun()- Main loop with sceneget_dt()- Delta timeget_time()- Application time
begin_2d()/end_2d()- 2D render passdraw_texture()/draw_texture_ex()/draw_texture_opts()- Texture drawingdraw_rect()/draw_circle()/draw_line()- Shape drawingdraw_text()- Text rendering
load_texture()/unload_texture()load_shader()/unload_shader()make_checkerboard()/make_gradient()/make_graphic()- Procedural textures
is_key_down()/is_key_pressed()mouse_position()/is_mouse_button_down()
VEC2(),VEC3(),RECT(),COLOR()- Constructor macros- Vector operations:
vec2_add(),vec2_sub(),vec2_length(), etc. - Matrix operations:
mat4_identity(),mat4_multiply(),mat4_ortho(), etc.
Shaders are written in GLSL 450 and compiled to SPIR-V and MSL:
cd examples/16_shaders
./build_shaders.shThe framework supports custom fragment shaders for 2D texture effects. See examples/16_shaders/shaders/ for examples.
- SDL3 - Windowing, input, GPU abstraction
- Box2D - 2D physics
- stb_image - Image loading
- cJSON - JSON parsing
[Not sure yet - probably MIT]