2D Game Dev
Made Simple with Odin
A fun, fast, and beginner-friendly 2D game library for the Odin programming language. Minimal dependencies, cross-platform, and built directly on OS APIs.
package hello_world
import og "odingame"
main :: proc() {
og.init(1280, 720, "Hello OdinGame!")
for og.update() {
og.clear(og.LIGHT_BLUE)
og.draw_text("Hellope!", {}50, 50{}, 100, og.DARK_BLUE)
og.present()
}
og.shutdown()
}
Packed with Features
Everything needed to build 2D games with the Odin programming language, from rendering to input to cross-platform deployment.
Shape & Texture Rendering
Render primitives, textures, and text with automatic batching for optimized draw calls.
Custom Shaders
Write custom shaders for unique visual effects with support for HLSL, GLSL, and MSL.
Camera System
Built-in camera support for managing game viewpoints, zooming, and following targets.
Cross-Platform
Windows (D3D11/OpenGL), macOS (OpenGL), Linux (OpenGL), and Web (WebGL) — all from one codebase.
Input Handling
Comprehensive input APIs for mouse, keyboard, and gamepad with plug-and-play support.
Direct-to-OS Windowing
No GLFW dependency — windowing and events are handled directly through OS APIs for full control.
Automatic Batching
Draw calls are automatically batched for maximum rendering performance without manual optimization.
Web Without Emscripten
Compile directly to WebAssembly using the official Odin JS runtime — no Emscripten needed.
Text & Font Rendering
Built-in text rendering with custom font support, including the default Roboto font.
Modular Architecture
Clean separation between platform layer, rendering backend, and core API for easy extensibility.
Minimal Dependencies
Designed to use as few external dependencies as possible — everything is built from scratch.
Physics Integration
Ready for physics with Box2D integration examples and a clean architecture for custom physics.
Quick Start Guide
Get up and running with OdinGame in just a few minutes. From installation to your first running game.
Install Odin
First, make sure you have the Odin compiler installed on your system.
# Visit https://odin-lang.org/docs/install/ for installation instructions
# Verify installation:
odin versionClone OdinGame
Clone the repository or add it as a dependency to your Odin project.
git clone https://github.com/Hendrin-Mckay/odingame.git
# Or add as a submodule:
git submodule add https://github.com/Hendrin-Mckay/odingame.git odingameCreate Your Game
Write your first game with just a few lines of code.
package my_game
import og "odingame"
main :: proc() {
og.init(1280, 720, "My First Game")
for og.update() {
og.clear(og.DARK_BLUE)
og.draw_text("Hello World!", {50, 50}, 64, og.WHITE)
og.present()
}
og.shutdown()
}Build & Run
Compile and run your game with a single command.
# Build and run for desktop:
odin run .
# Build for web:
odin run path/to/odingame/build_web -- your_game_path
# Output will be in your_game_path/bin/web/Platform Notes
- • Linux: You may need
libudev— install viasystemd-develorsystemd-dev - • Linux/macOS Web Builds: Requires
wasm-ldlinker — install via thelldpackage - • Web: Browser security may block local files — use
python -m http.serverto serve locally
Learn by Example
Explore ready-to-run examples covering everything from basic rendering to complete games.
Hello World
The simplest possible game — a window with text rendering.
Drawing Basics
Shapes, colors, textures, and fundamental rendering concepts.
Camera Control
Camera panning, zooming, and following game objects.
Box2D Physics
Integration with Box2D for realistic physics simulations.
Custom Fonts
Loading and rendering with custom font files.
Gamepad Input
Full gamepad support with button and axis mapping.
Mouse Input
Mouse position tracking, clicks, and cursor handling.
Render Textures
Render-to-texture for post-processing and effects.
Snake Game
A complete snake game demonstrating a real-world use case.
Bunnymark
Classic rendering benchmark — stress test with thousands of sprites.
Modular Architecture
Clean separation between the platform-independent API and platform-specific backends. Each layer can be extended or replaced independently.
Core API
odingame.odinThe user-facing, platform-independent API. Generates vertex lists for render batching and exposes all public procedures.
Platform Layer
platform_*.odinDirect OS API integration for window creation, input events, and system calls. Separate implementations for Windows, macOS, Linux, and Web.
Rendering Backend
render_backend_*.odinAbstracted graphics interface with backends for Direct3D 11, OpenGL, WebGL, and an in-development Vulkan backend.
Audio Backend
audio_backend_*.odinAudio interface with platform-specific implementations: ALSA (Linux), Core Audio (macOS), WaveOut (Windows), and Web Audio.
Tooling
tools/ & build_web/Build scripts for web deployment, API doc generator, example test runner, and project maintenance utilities.
Assets & Defaults
default_fonts/ & default_shaders/Bundled assets including the Roboto font and shader files for each rendering backend (HLSL, GLSL, etc.).
API Reference
A quick overview of the core API. The complete reference is auto-generated from source and available in the repository.
Initialization
og.init(width, height, title)Initialize the window and rendering contextog.shutdown()Clean up all resources and close the windowog.update()Process events and advance the frame (returns false when window closes)Drawing
og.clear(color)Clear the screen with a given colorog.draw_text(text, pos, size, color)Draw text at a position with a given size and colorog.draw_rect(rect, color)Draw a filled rectangleog.draw_texture(texture, pos)Draw a texture at a positionog.present()Present the rendered frame to the screenCamera
og.camera_set_pos(pos)Set the camera positionog.camera_set_zoom(zoom)Set the camera zoom levelInput
og.key_pressed(key)Check if a key was pressed this frameog.key_down(key)Check if a key is currently held downog.mouse_pos()Get current mouse positionog.gamepad_axis(pad, axis)Get the value of a gamepad axisWindow
og.window_size()Get the current window dimensionsog.set_fullscreen(enabled)Toggle fullscreen modeog.dt()Get the delta time since last frameContribute to OdinGame
OdinGame is open-source under the MIT License. Contributions via Pull Requests are welcome — here are the guidelines.
Pull Request Guidelines
Code must be fully functional and tested before submission
Contributions should be complete features, not partial implementations
Changes must be confined to relevant files — no auto-formatters
Regenerate odingame.doc.odin if changing the public API
Match the existing code style: tabs, 100 char max line length
Draft PRs are unrestricted — submit early for feedback
Roadmap to v1.0
Sound
Native audio playback across all platforms
Shader System
Cross-compiling shaders between HLSL/GLSL/MSL
Metal Backend
Modern rendering backend for macOS