Examples

Example programs from odin-lang/examples, with the names in their code linked to their documentation.

Examples 128

absolute_beginnersThis program shows the most basic features of Odin.
arena_allocator core:mem/virtual
code_generationThis shows some basic code generation / meta programming.
generate_image_infoThis program generates images.odin by going through the images folder and opening each file.
command_line_arguments core:os
console2 examples
raw_console core:os
read_console_input core:os
dir_infoHow to get information about a directory, including which files and directories it contains. core:os
directx3 examples
d3d11_minimal_sdl2 Windows vendor:directx/d3d11, vendor:directx/d3d_compiler, vendor:directx/dxgi
d3d11_minimal_sdl3 Windows vendor:directx/d3d11, vendor:directx/d3d_compiler, vendor:directx/dxgi
d3d12_triangle_sdl2 WindowsD3D12 single-function triangle sample. vendor:directx/d3d12, vendor:directx/d3d_compiler, vendor:directx/dxgi
dynamic_arrays
glfw1 example
window vendor:glfw
json3 examples
load_json core:encoding/json
load_json_unmarshal core:encoding/json
write_json_marshalDemonstrates how you can turn a struct into JSON and then write that JSON out to a file. core:encoding/json
lua2 examples
global_variables vendor:lua/5.4
hellope_lua vendor:lua/5.4
maps
math2 examples
noise/draw_texture core:math/noise
rand/markov core:math/rand
metal12 examples
learn_metal/00-window macOS core:sys/darwin/Foundation, vendor:darwin/Metal, vendor:darwin/QuartzCore
learn_metal/01-primitive macOS core:sys/darwin/Foundation, vendor:darwin/Metal, vendor:darwin/QuartzCore
learn_metal/02-argbuffers macOS core:sys/darwin/Foundation, vendor:darwin/Metal, vendor:darwin/QuartzCore
learn_metal/02-argbuffers-no-sdl macOS core:sys/darwin/Foundation, vendor:darwin/Metal, vendor:darwin/QuartzCore
learn_metal/03-animation macOS core:sys/darwin/Foundation, vendor:darwin/Metal, vendor:darwin/QuartzCore
learn_metal/04-instancing macOS core:sys/darwin/Foundation, vendor:darwin/Metal, vendor:darwin/QuartzCore
learn_metal/05-perspective macOS core:sys/darwin/Foundation, vendor:darwin/Metal, vendor:darwin/QuartzCore
learn_metal/06-lighting macOS core:sys/darwin/Foundation, vendor:darwin/Metal, vendor:darwin/QuartzCore
learn_metal/07-texturing macOS core:sys/darwin/Foundation, vendor:darwin/Metal, vendor:darwin/QuartzCore
learn_metal/08-compute macOS core:sys/darwin/Foundation, vendor:darwin/Metal, vendor:darwin/QuartzCore
learn_metal/09-compute-to-render macOS core:sys/darwin/Foundation, vendor:darwin/Metal, vendor:darwin/QuartzCore
minimal_sdl2 macOS core:sys/darwin/Foundation, vendor:darwin/Metal, vendor:darwin/QuartzCore
miniaudio1 example
portsThese are ports of the official miniaudio examples found here. vendor:miniaudio
nanovg
example vendor:nanovg, vendor:nanovg/gl
fbo vendor:nanovg, vendor:nanovg/gl
nbio7 examples
context core:nbio
game-loopExample game loop integrated with nbio, using Raylib here. core:nbio
no-callbacksExample shows how you could poll completions instead of being pushed completions through callbacks. core:nbio
sendfileExample that shows the sendfile operation. core:nbio
tcp-echoThis example shows a simple TCP server that echos back anything it receives. core:nbio
udp-echoThis example shows a simple UDP server that echos back anything it receives. core:nbio
workersExample shows how you can execute CPU intensive (or blocking IO), without blocking the event loop thread. core:nbio
net4 examples
tcp_echo_server/client core:net
tcp_echo_server/server core:net
udp_echo_server/client core:net
udp_echo_server/server core:net
opengl8 examples
learn_opengl/1_getting_started/1_hello_window vendor:OpenGL
learn_opengl/1_getting_started/2_hello_triangle vendor:OpenGL
learn_opengl/1_getting_started/3_shaders vendor:OpenGL
learn_opengl/1_getting_started/4_textures vendor:OpenGL
learn_opengl/1_getting_started/5_transformations vendor:OpenGL
learn_opengl/1_getting_started/6_coordinate_systems vendor:OpenGL
learn_opengl/1_getting_started/7_camera vendor:OpenGL
minimal_sdl2 vendor:OpenGL
orca3 examples
breakout Orca core:sys/orca
clock Orca core:sys/orca
ui Orca core:sys/orca
raylib46 examples
box2d vendor:box2d, vendor:raylib
box3d vendor:box3d, vendor:raylib, vendor:raylib/rlgl
game_of_life vendor:raylib
log core:log, vendor:raylib
microui vendor:microui, vendor:raylib
portsThese are ports of the official Raylib examples found here. vendor:raylib
ports/audio
ports/audio/audio_module_playingraylib [audio] example - module playing vendor:raylib
ports/audio/audio_music_streamraylib [audio] example - music stream vendor:raylib
ports/audio/audio_sound_loadingraylib [audio] example - sound loading vendor:raylib
ports/core
ports/core/core_3d_camera_fpsraylib [core] example - 3d camera fps vendor:raylib
ports/core/core_3d_camera_freeraylib [core] example - 3d camera free vendor:raylib
ports/core/core_3d_camera_moderaylib [core] example - 3d camera mode vendor:raylib
ports/core/core_basic_windowraylib [core] example - basic window vendor:raylib
ports/core/core_input_keysraylib [core] example - input keys vendor:raylib
ports/core/core_input_mouseraylib [core] example - input mouse vendor:raylib
ports/core/core_input_mouse_wheelraylib [core] example - input mouse wheel vendor:raylib
ports/core/core_random_valuesraylib [core] example - random values vendor:raylib
ports/core/core_render_textureraylib [core] example - render texture vendor:raylib
ports/core/core_scissor_testraylib [core] example - scissor test vendor:raylib
ports/core/core_window_should_closeraylib [core] example - window should close vendor:raylib
ports/core/core_world_screenraylib [core] example - world screen vendor:raylib
ports/models
ports/models/models_geometric_shapesraylib [models] example - geometric shapes vendor:raylib
ports/models/models_loading_iqmraylib [models] example - loading iqm vendor:raylib
ports/models/models_orthographic_projectionraylib [models] example - orthographic projection vendor:raylib
ports/shaders vendor:raylib
ports/shaders/rlights vendor:raylib
ports/shapes
ports/shapes/shapes_basic_shapes vendor:raylib
ports/shapes/shapes_bouncing_ball vendor:raylib
ports/shapes/shapes_collision_arearaylib [shapes] example - collision area vendor:raylib
ports/shapes/shapes_colors_palette vendor:raylib
ports/shapes/shapes_following_eyesraylib [shapes] example - following eyes vendor:raylib
ports/shapes/shapes_logo_raylibraylib [shapes] example - logo raylib vendor:raylib
ports/shapes/shapes_logo_raylib_anim vendor:raylib
ports/shapes/shapes_rectangle_scalingraylib [shapes] example - rectangle scaling vendor:raylib
ports/text vendor:raylib
ports/textures
ports/textures/textures_background_scrollingraylib [textures] example - background scrolling vendor:raylib
ports/textures/textures_blend_modesraylib [textures] example - blend modes vendor:raylib
ports/textures/textures_bunnymarkraylib [textures] example - bunnymark vendor:raylib
ports/textures/textures_gif_player vendor:raylib
ports/textures/textures_npatch_drawingraylib [textures] example - npatch drawing vendor:raylib
tetroid vendor:raylib
sdl23 examples
chase_in_spaceSimple game about enemies chasing and shooting you in 2D space. vendor:sdl2
hellopeSDL2 example for Odin. vendor:sdl2, vendor:sdl2/image
microui vendor:microui, vendor:sdl2
sdl32 examples
gpu vendor:sdl3
microui vendor:microui, vendor:sdl3
simd3 examples
approaches core:simd
basic-sum core:simd
motion core:simd
slices1 example
prefer_to_pass_slicesThis example shows why one might prefer procedure parameters that are slices whenever possible.
strings core:strings
text_edit core:text/edit
thread3 examples
basicsShows how to start a thread and let it do some calculations while the main thead also does some calculations. core:thread
pool/basic core:thread
sync_mutexDemonstrates how to spawn multiple threads and safely access data from each by using a mutex. core:thread
vulkan1 example
triangle_glfwBy laytan, source: https://gist.github.com/laytan/ba57af3e5a59ab5cb2fca9e25bcfe262 vendor:vulkan
wasm2 examples
js_wasm32 WebThis is an example of how to build an Odin program using the js_wasm32 target.
webgl/webgl_triangle WebShows how to draw a triangle using WASM + WebGL. vendor:wasm/WebGL
wgpu3 examples
glfw-triangle Web vendor:wgpu, vendor:wgpu/glfwglue
microui Web vendor:microui, vendor:wgpu
sdl3-triangle Web vendor:wgpu, vendor:wgpu/sdl3glue
win323 examples
embedded_manifest WindowsWindows executables can contain manifests. core:sys/windows
game_of_life Windows core:sys/windows
open_window Windows core:sys/windows