Beta 2 — Now Available

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.

Direct-to-OS
Cross-Platform
Gamepad Support
Auto Batching
hello_world.odin
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.

1

Install Odin

First, make sure you have the Odin compiler installed on your system.

terminal
# Visit https://odin-lang.org/docs/install/ for installation instructions
# Verify installation:
odin version
2

Clone OdinGame

Clone the repository or add it as a dependency to your Odin project.

terminal
git clone https://github.com/Hendrin-Mckay/odingame.git

# Or add as a submodule:
git submodule add https://github.com/Hendrin-Mckay/odingame.git odingame
3

Create Your Game

Write your first game with just a few lines of code.

main.odin
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()
}
4

Build & Run

Compile and run your game with a single command.

terminal
# 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 via systemd-devel or systemd-dev
  • Linux/macOS Web Builds: Requires wasm-ld linker — install via the lld package
  • Web: Browser security may block local files — use python -m http.server to 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.

BasicsText

Drawing Basics

Shapes, colors, textures, and fundamental rendering concepts.

RenderingShapes

Camera Control

Camera panning, zooming, and following game objects.

CameraViewport

Box2D Physics

Integration with Box2D for realistic physics simulations.

PhysicsBox2D

Custom Fonts

Loading and rendering with custom font files.

FontsText

Gamepad Input

Full gamepad support with button and axis mapping.

InputGamepad

Mouse Input

Mouse position tracking, clicks, and cursor handling.

InputMouse

Render Textures

Render-to-texture for post-processing and effects.

RenderingAdvanced

Snake Game

A complete snake game demonstrating a real-world use case.

GameComplete

Bunnymark

Classic rendering benchmark — stress test with thousands of sprites.

BenchmarkPerformance

Modular Architecture

Clean separation between the platform-independent API and platform-specific backends. Each layer can be extended or replaced independently.

Core API

odingame.odin

The user-facing, platform-independent API. Generates vertex lists for render batching and exposes all public procedures.

Platform Layer

platform_*.odin

Direct OS API integration for window creation, input events, and system calls. Separate implementations for Windows, macOS, Linux, and Web.

Rendering Backend

render_backend_*.odin

Abstracted graphics interface with backends for Direct3D 11, OpenGL, WebGL, and an in-development Vulkan backend.

Audio Backend

audio_backend_*.odin

Audio 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 context
og.shutdown()Clean up all resources and close the window
og.update()Process events and advance the frame (returns false when window closes)

Drawing

og.clear(color)Clear the screen with a given color
og.draw_text(text, pos, size, color)Draw text at a position with a given size and color
og.draw_rect(rect, color)Draw a filled rectangle
og.draw_texture(texture, pos)Draw a texture at a position
og.present()Present the rendered frame to the screen

Camera

og.camera_set_pos(pos)Set the camera position
og.camera_set_zoom(zoom)Set the camera zoom level

Input

og.key_pressed(key)Check if a key was pressed this frame
og.key_down(key)Check if a key is currently held down
og.mouse_pos()Get current mouse position
og.gamepad_axis(pad, axis)Get the value of a gamepad axis

Window

og.window_size()Get the current window dimensions
og.set_fullscreen(enabled)Toggle fullscreen mode
og.dt()Get the delta time since last frame

Contribute 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