Types

30 raylib types bound to Iron as objects with exact C struct layout — byte-identical ABI at the FFI boundary.

Types reference

Field order matches raylib's C structs. Pointer-bearing fields such as Image.data, Texture.id, and Font.glyphs are opaque from Iron — load and unload them through the binding and do not dereference them directly.

Math types

Vector2(x: Float32, y: Float32) -> Vector2

Category: Math · raylib: struct Vector2

2D float vector. Used everywhere raylib needs a point, screen position, size, or 2D direction.

val origin: Vector2 = Vector2(Float32(400.0), Float32(300.0))
val v = Vector2.of(1.0, 2.0)  -- constructor sugar (Float32 auto-wrap)

raylib cheatsheet · Iron source · Test usage

Vector3(x: Float32, y: Float32, z: Float32) -> Vector3

Category: Math · raylib: struct Vector3

3D float vector. Camera positions, world coordinates, directions, cube sizes.

val position = Vector3(Float32(10.0), Float32(10.0), Float32(10.0))
val origin = Vector3.of(0.0, 0.0, 0.0)

raylib cheatsheet · Iron source · Test usage

Vector4(x: Float32, y: Float32, z: Float32, w: Float32) -> Vector4

Category: Math · raylib: struct Vector4

4D float vector. Used by color normalization (Color.normalize returns a Vector4 in 0..1 range) and quaternion-compatible math.

val normalized = Color.normalize(RED)  -- Vector4(0.902, 0.161, 0.216, 1.0)

raylib cheatsheet · Iron source · Test usage

Quaternion(x: Float32, y: Float32, z: Float32, w: Float32) -> Quaternion

Category: Math · raylib: typedef Vector4 Quaternion

Rotation quaternion. Quaternion.identity() for no-rotation, Quaternion.from_axis_angle(...) / Quaternion.slerp(...) for interpolation.

val q = Quaternion.identity()
val r = Quaternion.from_axis_angle(Vector3.of(0.0, 1.0, 0.0), Float32(0.5))

raylib cheatsheet · Iron source · Math reference

Matrix(m0..m15: Float32)

Category: Math · raylib: struct Matrix (4x4 column-major)

4x4 transform matrix. Column-major (OpenGL convention). Use Matrix.identity() / Matrix.perspective(...) / Matrix.look_at(...) instead of hand-constructing.

val m = Matrix.identity()
val proj = Matrix.perspective(Float32(45.0), Float32(1.333), Float32(0.1), Float32(1000.0))

raylib cheatsheet · Iron source · Math reference

Rectangle(x: Float32, y: Float32, width: Float32, height: Float32) -> Rectangle

Category: Math · raylib: struct Rectangle

Axis-aligned rectangle. Used for texture regions, collision detection, hit testing.

val paddle = Rectangle(Float32(0), Float32(250), Float32(10), Float32(100))
val r = Rectangle.of(0.0, 0.0, 800.0, -600.0)  -- negative-h for Y-flip

raylib cheatsheet · Iron source · Test usage

Color(r: UInt8, g: UInt8, b: UInt8, a: UInt8) -> Color

Category: Math · raylib: struct Color

4-byte RGBA color. 26 predeclared color constants are available (see palette); Color.rgb / Color.rgba provide constructor sugar.

val c = Color(230, 41, 55, 255)
val red = Color.rgb(UInt8(230), UInt8(41), UInt8(55))

raylib cheatsheet · Iron source · Palette reference

Rendering types

object Image

Category: Rendering · raylib: struct Image

CPU-side pixel buffer. Load from file, manipulate pixels, then image.to_texture() to upload to GPU.

val img = Image.checked(Int32(256), Int32(256), Int32(16), Int32(16), RED, WHITE)
val tex = Image.to_texture(img)
Image.unload(img)

raylib cheatsheet · Iron source · Test usage

object Texture

Category: Rendering · raylib: struct Texture (aka Texture2D)

GPU texture. Loaded via Texture.load(path) or Image.to_texture(img). Drawn with Texture.draw* family.

val tex = Texture.load("sprite.png")
if Texture.is_valid(tex) {
    Texture.draw(tex, Int32(100), Int32(100), WHITE)
}
Texture.unload(tex)

raylib cheatsheet · Iron source · Test usage

object RenderTexture

Category: Rendering · raylib: struct RenderTexture (aka RenderTexture2D)

Offscreen framebuffer. RenderTexture.load(w, h) creates one; Draw.begin_texture_mode(rt) routes draw calls to it. Access the color buffer as rt.texture (OpenGL RT is Y-flipped — use negative-height Rectangle when sampling).

val rt = RenderTexture.load(Int32(800), Int32(600))
Draw.begin_texture_mode(rt)
Draw.clear(RAYWHITE)
Draw.end_texture_mode()

raylib cheatsheet · Iron source · Test usage

object NPatchInfo

Category: Rendering · raylib: struct NPatchInfo

Nine-patch texture metadata — source rectangle + 4 border offsets + layout. Used by Texture.draw_n_patch for scalable UI panels.

val np = NPatchInfo(source_rec, 8, 8, 8, 8, NPatchLayout.NINE_PATCH)

raylib cheatsheet · Iron source · Textures reference

object GlyphInfo

Category: Rendering · raylib: struct GlyphInfo

Per-glyph metadata inside a loaded Font: codepoint, offset X/Y, advance, image. Access via Font.get_glyph_info(font, codepoint).

val g = Font.get_glyph_info(font, Int32(0x41))  -- 'A'

raylib cheatsheet · Iron source · Text reference

object Font

Category: Rendering · raylib: struct Font

Font atlas + glyph table. Font.default() for the built-in bitmap font, Font.load(path) for TTF/OTF/FNT.

val font = Font.default()
Draw.text("Hello", Int32(10), Int32(10), Int32(20), WHITE)
Font.unload(font)

raylib cheatsheet · Iron source · Test usage

Camera types

object Camera (aka Camera2D)

Category: Camera · raylib: struct Camera2D

2D camera with target / offset / rotation / zoom. Used with Draw.begin_mode_2d(camera) to apply a view transform to 2D draw calls.

val cam2 = Camera(Vector2.of(0.0, 0.0), Vector2.of(0.0, 0.0), Float32(0.0), Float32(1.0))

raylib cheatsheet · Iron source · 2D modes

object Camera3D

Category: Camera · raylib: struct Camera3D

3D camera with position, target, up, FOV, and projection mode. Pass to Draw.begin_mode_3d(camera) to render 3D.

var cam = Camera3D(
    Vector3.of(10.0, 10.0, 10.0),  -- position
    Vector3.of(0.0, 0.0, 0.0),     -- target
    Vector3.of(0.0, 1.0, 0.0),     -- up
    Float32(45.0), Int32(0)            -- fovy, PERSPECTIVE
)

raylib cheatsheet · Iron source · Test usage

Model types

object ModelSkeleton

Category: Models · raylib: struct ModelSkeleton

raylib 6 skeleton header: bone count + bone table + bind-pose pointer. Embedded by Model and used by animation validation/update.

-- Usually inspected through model.skeleton

raylib cheatsheet · Iron source · Animation reference

object Mesh

Category: Models · raylib: struct Mesh

Vertex buffer (positions / texcoords / normals / colors / indices / skinning data / runtime anim buffers). Generate procedurally via Mesh.cube, Mesh.sphere, etc.; upload to GPU via mesh.upload(dynamic).

val cube = Mesh.cube(Float32(2.0), Float32(2.0), Float32(2.0))
val model = Model.from_mesh(cube)

raylib cheatsheet · Iron source · Test usage

object Shader

Category: Models · raylib: struct Shader

GLSL program. Shader.load(vs_path, fs_path) for file-based; Shader.load_from_memory(vs, fs) for inline. Pass an empty VS path to use raylib's built-in.

val fx = Shader.load("", "tests/assets/shaders/grayscale.fs")

raylib cheatsheet · Iron source · Test usage

object MaterialMap

Category: Models · raylib: struct MaterialMap

Texture slot + color tint + float value. One per MaterialMapIndex channel (diffuse, normal, roughness, ...).

-- Set by Material.set_texture; rarely built manually
Material.set_texture(mat, MaterialMapIndex.DIFFUSE, tex)

raylib cheatsheet · Iron source · Model reference

object Model

Category: Models · raylib: struct Model

Meshes + materials + embedded ModelSkeleton + runtime pose/matrix pointers + transform. Load from .obj/.gltf/.glb/.iqm/.vox/.m3d via Model.load(path).

val model = Model.load("tests/assets/models/cube.obj")
if Model.is_valid(model) {
    Model.draw(model, origin, Float32(1.0), WHITE)
}

raylib cheatsheet · Iron source · Test usage

object ModelAnimation

Category: Models · raylib: struct ModelAnimation

Skeletal animation clip — name + bone count + keyframe-pose table. Load via ModelAnimation.load(path); drive via Model.update_animation(m, a, frame) or update_animation_ex(...).

val anims: [ModelAnimation] = ModelAnimation.load("character.iqm")

raylib cheatsheet · Iron source · Animation reference

object Transform

Category: Models · raylib: struct Transform

Translation Vector3 + rotation Quaternion + scale Vector3. Used per-bone in ModelAnimation frame poses.

val t = Transform(translation, rotation, scale)

raylib cheatsheet · Iron source · Math reference

object BoneInfo

Category: Models · raylib: struct BoneInfo

Bone name (fixed 32-char array) + parent index. Skeleton structure for skinned meshes.

-- BoneInfo is usually populated from loaded ModelAnimation data

raylib cheatsheet · Iron source · Model reference

Geometry types

object Ray

Category: Geometry · raylib: struct Ray

Origin + direction. Core primitive for mouse picking, raycasting collision, camera-world queries.

val ray = Camera3D.screen_to_world_ray(cam, Mouse.get_position())
val hit = Ray.hit_box(ray, bbox)

raylib cheatsheet · Iron source · Collision reference

object RayCollision

Category: Geometry · raylib: struct RayCollision

Result of a ray hit test — hit/distance/point/normal.

val hit = Ray.hit_box(ray, bbox)
if hit.hit { -- inspect hit.distance, hit.point, hit.normal }

raylib cheatsheet · Iron source · Collision reference

object BoundingBox

Category: Geometry · raylib: struct BoundingBox

Axis-aligned min/max Vector3 pair. Compute via Mesh.bounding_box(mesh) / Model.bounding_box(model).

val bbox = Model.bounding_box(model)
Draw.bounding_box(bbox, GREEN)

raylib cheatsheet · Iron source · 3D Drawing reference

Audio types

object Wave

Category: Audio · raylib: struct Wave

CPU-side PCM samples + metadata. Wave.load(path) loads from WAV/OGG/MP3/FLAC/QOA/XM/MOD. Convert to a Sound via Wave.to_sound(w).

val w = Wave.load("tests/assets/bounce.wav")
val s = Wave.to_sound(w)

raylib cheatsheet · Iron source · Test usage

object AudioStream

Category: Audio · raylib: struct AudioStream

Low-level streaming audio — you supply samples per-frame via AudioStream.update(stream, data, count). Used by Music internally; useful for synthesis.

val st = AudioStream.load(UInt32(44100), UInt32(16), UInt32(2))
AudioStream.play(st)

raylib cheatsheet · Iron source · Test usage

object Sound

Category: Audio · raylib: struct Sound

GPU-side short sound effect. Sound.load(path) for one-shots; Sound.alias(source) for independently-playing copies.

val bounce = Sound.load("tests/assets/bounce.wav")
Sound.play(bounce)

raylib cheatsheet · Iron source · Test usage

object Music

Category: Audio · raylib: struct Music

Long streaming audio (BGM). Music.load(path) to open, Music.update(m) every frame to feed the buffer.

val bgm = Music.load("tests/assets/loop.ogg")
Music.play(bgm)

raylib cheatsheet · Iron source · Test usage

File types

object FilePathList

Category: Files · raylib: struct FilePathList

Directory listing — count + path array. Returned by Files.list / Files.list_ex; remember to Files.unload_list(list).

val list = Files.list("tests/assets")
Files.unload_list(list)

raylib cheatsheet · Iron source · Test usage

Float buffer types

Constructor sugar

Iron's raylib.iron ships four ergonomic constructors that auto-wrap primitive literals in their ABI types:

Color.rgb(r: UInt8, g: UInt8, b: UInt8) -> Color

Category: Constructor sugar · shortcut for Color(r, g, b, 255)

3-component color constructor — alpha defaults to 255 (fully opaque).

val c = Color.rgb(UInt8(230), UInt8(41), UInt8(55))

raylib cheatsheet · Iron source · Test usage

Color.rgba(r: UInt8, g: UInt8, b: UInt8, a: UInt8) -> Color

Category: Constructor sugar · shortcut for Color(r, g, b, a)

4-component color constructor with explicit alpha.

val translucent = Color.rgba(UInt8(255), UInt8(0), UInt8(0), UInt8(128))

raylib cheatsheet · Iron source · Test usage

Rectangle.of(x: Float32, y: Float32, width: Float32, height: Float32) -> Rectangle

Category: Constructor sugar · shortcut for Rectangle(Float32(x), Float32(y), Float32(w), Float32(h))

Accepts bare literals.

val r = Rectangle.of(0.0, 0.0, 800.0, -600.0)

raylib cheatsheet · Iron source · Test usage

Design notes

Field order matches raylib

Every Iron object above is a struct with fields in the same order as raylib's C definition. sizeof(Iron_Vector2) equals sizeof(Vector2); memcpy at the FFI boundary is safe in both directions.

Opaque pointer fields

Fields like Image.data (void *), Texture.id (unsigned int), Font.glyphs (GlyphInfo *) are present in the Iron struct for ABI-identity but are opaque to Iron code — do not dereference. Use the binding's accessor methods instead (e.g., Image.load_colors(img) instead of poking img.data).

See also