Raylib Module

GX includes a raylib module for game and graphics development. Raylib is a simple C library for games — no callbacks, no complex setup, just a polling game loop. The GX module wraps raylib’s C API directly via extern fn and extern struct, keeping the familiar PascalCase naming.

The bindings target raylib 6.0. The bundled header/lib is currently 5.5, so 6.0-only declarations are commented out in each .gx file under a raylib 6.0 ONLY banner. Drop in a raylib 6.0 raylib.h and rebuilt libs, then uncomment those blocks to enable the full 6.0 surface.

Prerequisites

Raylib must be installed separately. You need:

  1. raylib.h — place in modules/raylib/c/
  2. raylib.lib (MSVC) or libraylib.a (GCC) — place in modules/raylib/lib/
  3. Clang or GCC — required for linking

Usage

Import the sub-modules you need:

import raylib.core      // window, timing, drawing, shaders, camera, files, memory, automation, structs
import raylib.input     // keyboard/mouse enums and basic query functions
import raylib.shapes    // 2D shape drawing, splines, collision
import raylib.text      // text drawing, fonts, codepoints, text utilities
import raylib.textures  // texture/image loading, drawing, color utilities
import raylib.colors    // color constants (RED, BLUE, RAYWHITE, ...)
import raylib.models    // 3D shapes, model loading, mesh, materials, animation
import raylib.audio     // sound, music streaming, audio streams + callbacks

Build with -I modules:

gx myapp.gx -I modules -o myapp.exe

Hello World

import raylib.core
import raylib.input
import raylib.shapes
import raylib.text
import raylib.colors

fn main() {
    InitWindow(800, 450, "GX + Raylib")
    SetTargetFPS(60)

    while (!WindowShouldClose()) {
        BeginDrawing()
        ClearBackground(RAYWHITE)

        DrawText("Hello from GX!", 190, 200, 20, DARKGRAY)
        DrawRectangle(100, 100, 200, 80, RED)
        DrawCircle(400, 300, 50.0, BLUE)
        DrawFPS(10, 10)

        if (IsKeyPressed(KEY_ESCAPE)) {
            CloseWindow()
            return
        }

        EndDrawing()
    }
    CloseWindow()
}

Note: Colors are top-level const values, not functions — write RED, not rl_red(). See the Colors section.


Core (raylib.core)

Structs

All raylib types are declared as extern struct and used directly:

StructPurpose
Vector2 / Vector3 / Vector42D/3D/4D vectors (mapped to GX vec2/vec3/vec4 with operator overloading + swizzles)
Matrix4x4 transform matrix (column-major, named fields m0..m15)
Colorr, g, b, a: u8
Rectanglex, y, width, height: f32
ImageCPU image (data: *void, width, height, mipmaps, format)
Texture / Texture2DGPU texture (id, width, height, mipmaps, format)
RenderTextureRender target (id, texture, depth)
NPatchInfoN-patch layout (source, left, top, right, bottom, layout)
GlyphInfoGlyph data (value, offsetX/Y, advanceX, image)
FontFont (baseSize, glyphCount, glyphPadding, texture, recs, glyphs)
Camera2D2D camera (offset, target, rotation, zoom)
Camera3D / Camera3D camera (position, target, up, fovy, projection)
ShaderShader program (id, locs: *c_int)
MaterialMapMaterial slot (texture, color, value)
MaterialRendering material (shader, maps, params: f32[4])
MeshVertex data (positions, normals, tangents, colors, indices, bone weights, VAO/VBO ids)
Model3D model (transform, meshes, materials, meshMaterial, bones, bindPose)
ModelAnimationSkeletal animation (boneCount, frameCount, bones, framePoses, name)
TransformBone transform (translation, rotation, scale)
BoneInfoSkeleton bone (name: c_char[32], parent)
RayRay (position, direction)
RayCollisionHit info (hit, distance, point, normal)
BoundingBoxAABB (min, max)
WaveAudio wave (frameCount, sampleRate, sampleSize, channels, data)
AudioStreamStream (buffer, processor, sampleRate, sampleSize, channels)
SoundLoaded sound (stream, frameCount)
MusicStreamed music (stream, frameCount, looping, ctxType, ctxData)
VrDeviceInfoHMD parameters (resolution, screen size, IPD, lens distortion)
VrStereoConfigVR stereo render config (per-eye projection/view, lens centers)
FilePathListReturned by directory listing (capacity, count, paths)
AutomationEventRecorded input event (opaque on GX side)
AutomationEventListEvent list (capacity, count, events)

Construct structs by declaring a variable and setting fields:

var pos:Vector2
pos.x = 100.0
pos.y = 200.0

Window

FunctionSignatureDescription
InitWindow(c_int, c_int, cstr)Create window with width, height, title
CloseWindow()Close window and unload OpenGL context
WindowShouldClose→ boolTrue when ESC pressed or close button clicked
IsWindowReady→ boolWindow initialized successfully
IsWindowFullscreen→ boolCurrently fullscreen
IsWindowHidden→ boolCurrently hidden
IsWindowMinimized / IsWindowMaximized→ boolWindow state
IsWindowFocused / IsWindowResized→ boolFocus / resize this frame
IsWindowState(c_uint) → boolTest specific flag
SetWindowState / ClearWindowState(c_uint)Set / clear window flags
ToggleFullscreen / ToggleBorderlessWindowed()Toggle fullscreen modes
MaximizeWindow / MinimizeWindow / RestoreWindow()Window state changes
SetWindowIcon(Image)Single-image icon (RGBA 32-bit)
SetWindowIcons (6.0)(*Image, c_int)Multi-image icon set
SetWindowTitle(cstr)Change title
SetWindowPosition / SetWindowMonitorPlace window
SetWindowMinSize / SetWindowMaxSize / SetWindowSizeDimensions
SetWindowOpacity(f32)0.0–1.0
SetWindowFocused()Bring to front
GetWindowHandle→ *voidNative HWND/NSWindow/X11 handle
GetScreenWidth / GetScreenHeight→ c_intLogical size
GetRenderWidth / GetRenderHeight→ c_intPixel size (HiDPI)
GetMonitorCount / GetCurrentMonitor→ c_intMonitor info
GetMonitorPosition(c_int) → Vector2
GetMonitorWidth / GetMonitorHeight / GetMonitorRefreshRate(c_int) → c_int
GetMonitorPhysicalWidth / GetMonitorPhysicalHeight(c_int) → c_intIn mm
GetMonitorName(c_int) → cstrUTF-8 monitor name
GetWindowPosition / GetWindowScaleDPI→ Vector2
SetClipboardText / GetClipboardTextText clipboard
GetClipboardImage→ ImageImage clipboard
EnableEventWaiting / DisableEventWaiting()Block on events vs poll

Cursor

ShowCursor, HideCursor, IsCursorHidden, EnableCursor, DisableCursor, IsCursorOnScreen.

Drawing Lifecycle

FunctionDescription
BeginDrawing() / EndDrawing()Frame boundary
ClearBackground(color)Clear framebuffer
BeginMode2D(camera) / EndMode2D()2D camera mode
BeginMode3D(camera) / EndMode3D()3D camera mode
BeginTextureMode(target) / EndTextureMode()Render to texture
BeginShaderMode(shader) / EndShaderMode()Custom shader
BeginBlendMode(mode) / EndBlendMode()Blending mode
BeginScissorMode(x,y,w,h) / EndScissorMode()Scissor clipping
BeginVrStereoMode(config) / EndVrStereoMode()VR stereo

VR Stereo

FunctionSignature
LoadVrStereoConfig(VrDeviceInfo) → VrStereoConfig
UnloadVrStereoConfig(VrStereoConfig)

Shaders

FunctionSignature
LoadShader(cstr, cstr) → Shader — vertex + fragment file paths
LoadShaderFromMemory(cstr, cstr) → Shader — source strings
IsShaderValid(Shader) → bool
GetShaderLocation / GetShaderLocationAttrib(Shader, cstr) → c_int
SetShaderValue(Shader, c_int, *void, c_int)
SetShaderValueV(Shader, c_int, *void, c_int, c_int) — vector
SetShaderValueMatrix(Shader, c_int, Matrix)
SetShaderValueTexture(Shader, c_int, Texture)
UnloadShader(Shader)

Screen-Space

FunctionDescription
GetScreenToWorldRay(pos, camera)Screen point to 3D ray
GetScreenToWorldRayEx(pos, camera, w, h)Same, in custom viewport
GetWorldToScreen(pos3d, camera)3D to screen
GetWorldToScreenEx(pos3d, camera, w, h)Same, custom viewport
GetWorldToScreen2D / GetScreenToWorld2D2D camera space conversions
GetCameraMatrix / GetCameraMatrix2DView matrix

Timing

FunctionDescription
SetTargetFPS(fps)Frame rate cap (0 = unlimited)
GetFPS()Current FPS
GetFrameTime()Delta time (seconds)
GetTime()Time since InitWindow (seconds)
SwapScreenBuffer()Manual buffer swap (custom frame control)
PollInputEvents()Manual input pump
WaitTime(seconds)Halt execution

Random

FunctionDescription
SetRandomSeed(seed)Seed RNG
GetRandomValue(min, max)Inclusive integer in range
LoadRandomSequence(count, min, max) → *c_intUnique-value sequence
UnloadRandomSequence(seq)Free sequence

Logging

FunctionDescription
SetTraceLogLevel(level)Min log level
TraceLog(level, text)Log a string (variadic version not exposed — pre-format with string interpolation)

Memory

FunctionDescription
MemAlloc(size) → *voidRaylib’s internal allocator
MemRealloc(ptr, size) → *void
MemFree(ptr)

File I/O — Data & Text

FunctionDescription
LoadFileData(name, *size) → *u8Read binary file
UnloadFileData(data)Free LoadFileData result
SaveFileData(name, data, size) → boolWrite binary file
ExportDataAsCode(data, size, name) → boolDump as .h array
LoadFileText(name) → *c_charRead text file
UnloadFileText(text)Free text
SaveFileText(name, text) → boolWrite text file

File System Management

FunctionDescription
FileExists(name) → bool
DirectoryExists(path) → bool
IsFileExtension(name, ext) → bool
IsPathFile(path) → bool
IsFileNameValid(name) → bool
GetFileLength(name) → c_intSize in bytes
GetFileModTime(name) → c_longLast write time
GetFileExtension(name) → cstrReturns .png, .gx, …
GetFileName(path) → cstrStrip directory
GetFileNameWithoutExt(path) → cstrStrip directory + extension
GetDirectoryPath(path) → cstrContaining directory
GetPrevDirectoryPath(path) → cstrParent directory
GetWorkingDirectory() → cstrCWD
GetApplicationDirectory() → cstrExecutable’s directory
MakeDirectory(path) → c_intCreate (recursively)
ChangeDirectory(path) → boolchdir
LoadDirectoryFiles(path) → FilePathListList directory
LoadDirectoryFilesEx(base, filter, scanSubdirs) → FilePathListFiltered listing
UnloadDirectoryFiles(list)Free
IsFileDropped() → boolDrag-and-drop detected
LoadDroppedFiles() → FilePathListGet dropped paths
UnloadDroppedFiles(list)Free
6.0 onlyFileRename, FileRemove, FileCopy, FileMove, FileTextReplace, FileTextFindIndex, GetDirectoryFileCount, GetDirectoryFileCountEx

Compression / Encoding / Hashes

FunctionDescription
CompressData(data, size, *outSize) → *u8DEFLATE compress
DecompressData(comp, size, *outSize) → *u8DEFLATE decompress
EncodeDataBase64(data, size, *outSize) → *c_charBase64 encode
DecodeDataBase64(text, *outSize) → *u8Base64 decode
ComputeCRC32(data, size) → c_uint
ComputeMD5(data, size) → *c_uintReturns 4×u32
ComputeSHA1(data, size) → *c_uintReturns 5×u32
ComputeSHA256(data, size) → *c_uint (6.0)Returns 8×u32

All allocate via raylib’s allocator — free with MemFree.

Automation Events

Record and replay input for testing:

var list = LoadAutomationEventList("")    // empty list
SetAutomationEventList(&list)
StartAutomationEventRecording()
// ... gameplay ...
StopAutomationEventRecording()
ExportAutomationEventList(list, "playback.txt")
FunctionDescription
LoadAutomationEventList(name) → AutomationEventList
UnloadAutomationEventList(list)
ExportAutomationEventList(list, name) → bool
SetAutomationEventList(*list)Set recording target
SetAutomationEventBaseFrame(frame)
StartAutomationEventRecording() / StopAutomationEventRecording()
PlayAutomationEvent(event)Replay one event

Misc

FunctionDescription
TakeScreenshot(name)Save screenshot (extension determines format)
OpenURL(url)Open URL in default browser
SetConfigFlags(flags)Init flags (call before InitWindow)

Mouse (Core)

GetMousePosition, GetMouseDelta, GetMouseX/Y, SetMousePosition, SetMouseOffset, SetMouseScale, GetMouseWheelMove, GetMouseWheelMoveV, SetMouseCursor.

Touch & Gestures

GetTouchPosition, GetTouchPointId, GetTouchPointCount, GetTouchX, GetTouchY, SetGesturesEnabled, IsGestureDetected, GetGestureDetected, GetGestureHoldDuration, GetGestureDragVector, GetGestureDragAngle, GetGesturePinchVector, GetGesturePinchAngle.

Camera

UpdateCamera(camera, mode), UpdateCameraPro(camera, movement, rotation, zoom).

Gamepad

FunctionDescription
IsGamepadAvailable(id)
GetGamepadName(id) → cstr
IsGamepadButtonPressed/Down/Released/Up(id, btn)
GetGamepadButtonPressed() → c_int
GetGamepadAxisCount(id) → c_int
GetGamepadAxisMovement(id, axis) → f32
SetGamepadVibration(id, left, right, dur)
SetGamepadMappings(mappings) → c_int (6.0)SDL_GameControllerDB string

Keyboard (Extra)

FunctionDescription
GetCharPressed() → c_intUnicode char queue
SetExitKey(key)Override default ESC quit
GetKeyName(key) → cstr (6.0)Layout-aware key label

Input (raylib.input)

Keyboard

if (IsKeyPressed(KEY_SPACE)) { jump() }
if (IsKeyDown(KEY_A)) { move_left() }
FunctionDescription
IsKeyPressed(key) → boolPressed this frame
IsKeyPressedRepeat(key) → boolPressed (with OS repeat)
IsKeyDown(key) → boolHeld
IsKeyReleased(key) → boolReleased this frame
IsKeyUp(key) → boolNot held
GetKeyPressed() → c_intPop from queue (0 when empty)

Key constants: KEY_A..KEY_Z, KEY_ZERO..KEY_NINE, KEY_SPACE, KEY_ESCAPE, KEY_ENTER, KEY_TAB, KEY_BACKSPACE, KEY_INSERT, KEY_DELETE, arrow keys, KEY_HOME/KEY_END/KEY_PAGE_UP/KEY_PAGE_DOWN, KEY_F1..KEY_F12, modifiers (KEY_LEFT_SHIFT, KEY_LEFT_CONTROL, KEY_LEFT_ALT, KEY_LEFT_SUPER plus RIGHT_*), keypad (KEY_KP_0..KEY_KP_9, KEY_KP_ADD, KEY_KP_SUBTRACT, KEY_KP_MULTIPLY, KEY_KP_DIVIDE, KEY_KP_DECIMAL, KEY_KP_ENTER).

Mouse Buttons

FunctionDescription
IsMouseButtonPressed/Down/Released/Up(button) → bool

Constants: MOUSE_BUTTON_LEFT, MOUSE_BUTTON_RIGHT, MOUSE_BUTTON_MIDDLE, MOUSE_BUTTON_SIDE, MOUSE_BUTTON_EXTRA, MOUSE_BUTTON_FORWARD, MOUSE_BUTTON_BACK.


Shapes (raylib.shapes)

Pixel & Lines

FunctionDescription
DrawPixel(x, y, color) / DrawPixelV(pos, color)Single pixel
DrawLine(x1, y1, x2, y2, color) / DrawLineV(start, end, color)Line
DrawLineEx(start, end, thick, color)Thick line (triangles)
DrawLineStrip(*points, count, color)Connected lines
DrawLineBezier(start, end, thick, color)Cubic bezier in-out
DrawLineDashed(start, end, dashSize, spaceSize, color) (6.0)Dashed

Circles & Ellipses

FunctionDescription
DrawCircle(cx, cy, r, color) / DrawCircleV(c, r, color)Filled
DrawCircleLines(cx, cy, r, color) / DrawCircleLinesV(c, r, color)Outline
DrawCircleGradient(c, r, inner, outer)Gradient fill
DrawCircleSector(c, r, start, end, segments, color)Pie slice
DrawCircleSectorLines(...)Sector outline
DrawEllipse(cx, cy, rh, rv, color)Filled ellipse
DrawEllipseLines(cx, cy, rh, rv, color)Outline
DrawEllipseV(c, rh, rv, color) (6.0)Vector center
DrawEllipseLinesV(c, rh, rv, color) (6.0)Vector outline
DrawRing(c, inner, outer, start, end, segments, color)Annulus sector
DrawRingLines(...)Ring outline

Rectangles

FunctionDescription
DrawRectangle(x, y, w, h, color)Filled
DrawRectangleV(pos, size, color) / DrawRectangleRec(rec, color)Vector / Rectangle forms
DrawRectanglePro(rec, origin, rotation, color)Rotated around origin
DrawRectangleGradientV(x, y, w, h, top, bottom)Vertical gradient
DrawRectangleGradientH(x, y, w, h, left, right)Horizontal gradient
DrawRectangleGradientEx(rec, tl, bl, br, tr)Per-corner colors
DrawRectangleLines(x, y, w, h, color)Outline
DrawRectangleLinesEx(rec, thick, color)Thick outline
DrawRectangleRounded(rec, roundness, segments, color)Rounded fill
DrawRectangleRoundedLines(rec, roundness, segments, color)Rounded outline
DrawRectangleRoundedLinesEx(rec, roundness, segments, thick, color)Thick rounded outline

Triangles & Polygons

FunctionDescription
DrawTriangle(v1, v2, v3, color)CCW filled triangle
DrawTriangleLines(...)Triangle outline
DrawTriangleFan(*points, count, color)Fan from first vertex
DrawTriangleStrip(*points, count, color)Triangle strip
DrawPoly(center, sides, radius, rotation, color)Regular polygon
DrawPolyLines(...)Polygon outline
DrawPolyLinesEx(..., thick, color)Thick polygon outline

Splines

DrawSplineLinear, DrawSplineBasis, DrawSplineCatmullRom, DrawSplineBezierQuadratic, DrawSplineBezierCubic. Per-segment variants: DrawSplineSegmentLinear/Basis/CatmullRom/BezierQuadratic/BezierCubic.

Evaluators: GetSplinePointLinear/Basis/CatmullRom/BezierQuad/BezierCubic — each returns the point on the spline for a parameter t ∈ [0, 1].

Shapes Texture (atlas batching)

SetShapesTexture(myAtlas, sourceRect)    // route shape draws through atlas
FunctionDescription
SetShapesTexture(texture, source)Set atlas
GetShapesTexture() → Texture (6.0)Currently set texture
GetShapesTextureRectangle() → Rectangle (6.0)Currently set source

Collision

FunctionDescription
CheckCollisionRecs(r1, r2)Rectangle vs rectangle
CheckCollisionCircles(c1, r1, c2, r2)Circle vs circle
CheckCollisionCircleRec(c, r, rec)Circle vs rectangle
CheckCollisionCircleLine(c, r, p1, p2)Circle vs segment
CheckCollisionPointRec/Circle/Triangle(point, ...)Point inclusion
CheckCollisionPointLine(point, p1, p2, threshold)Point on segment
CheckCollisionPointPoly(point, *points, count)Point in polygon
CheckCollisionLines(s1, e1, s2, e2, *out)Segment intersection
GetCollisionRec(r1, r2) → RectangleOverlap rect

Text (raylib.text)

Drawing

FunctionDescription
DrawFPS(x, y)FPS counter
DrawText(text, x, y, fontSize, color)Default font
DrawTextEx(font, text, pos, fontSize, spacing, tint)Custom font
DrawTextPro(font, text, pos, origin, rotation, fontSize, spacing, tint)With rotation
DrawTextCodepoint(font, codepoint, pos, fontSize, tint)Single glyph
DrawTextCodepoints(font, *codepoints, count, pos, fontSize, spacing, tint)Glyph array

Font Loading

FunctionDescription
GetFontDefault() → FontBuilt-in font
LoadFont(name) → FontTTF / FNT / etc.
LoadFontEx(name, fontSize, *codepoints, count) → FontWith custom charset
LoadFontFromImage(image, key, firstChar) → FontXNA-style sprite font
LoadFontFromMemory(type, data, size, fontSize, *codepoints, count) → FontFrom buffer
IsFontValid(font) → bool
UnloadFont(font)
ExportFontAsCode(font, name) → boolDump as .h

Font Atlas (low-level)

var glyphs = LoadFontData(ttfData, ttfSize, 32, NULL, 0, FONT_DEFAULT)
var atlas  = GenImageFontAtlas(glyphs, &recs, 95, 32, 4, 0)
UnloadFontData(glyphs, 95)
FunctionDescription
LoadFontData(data, size, fontSize, *codepoints, count, fontType) → *GlyphInfo(5.5 form — 6 args; 6.0 adds *glyphCount)
UnloadFontData(*glyphs, count)
GenImageFontAtlas(*glyphs, *recsOut, count, fontSize, padding, packMethod) → Image

Measurement

FunctionDescription
MeasureText(text, fontSize) → c_intWidth with default font
MeasureTextEx(font, text, fontSize, spacing) → Vector2With custom font
MeasureTextCodepoints(font, *codepoints, len, fontSize, spacing) → Vector2 (6.0)
SetTextLineSpacing(spacing)Newline gap
GetGlyphIndex(font, codepoint) → c_intAtlas index
GetGlyphInfo(font, codepoint) → GlyphInfoGlyph metrics
GetGlyphAtlasRec(font, codepoint) → RectangleUV rect

Codepoints / UTF-8

FunctionDescription
LoadUTF8(*codepoints, length) → *c_charEncode
UnloadUTF8(text)Free
LoadCodepoints(text, *count) → *c_intDecode
UnloadCodepoints(*codepoints)Free
GetCodepointCount(text) → c_int
GetCodepoint(text, *size) → c_intNext codepoint
GetCodepointNext/Previous(text, *size) → c_int
CodepointToUTF8(codepoint, *size) → cstr

Text Strings

⚠ Most return either a static buffer (overwritten by next call) or a heap allocation that you must MemFree(). Read each docstring.

FunctionDescription
TextCopy(dst, src) → c_intBytes copied
TextIsEqual(a, b) → bool
TextLength(text) → c_uint\0-terminated
TextFormat(text) → cstrSingle-arg form (variadic version not exposed)
TextSubtext(text, position, length) → cstr
TextReplace(text, search, replacement) → *c_charFree with MemFree
TextInsert(text, insert, position) → *c_charFree with MemFree
TextJoin(textList, count, delimiter) → cstr
TextSplit(text, delimiter, *count) → *voidReturns char**
TextAppend(text, append, *position)In-place
TextFindIndex(text, search) → c_int
TextToUpper/Lower/Pascal/Snake/Camel(text) → cstrCase conversion
TextToInteger(text) → c_int / TextToFloat(text) → f32Parse
6.0 onlyTextRemoveSpaces, GetTextBetween, TextReplaceAlloc, TextReplaceBetween[Alloc], TextInsertAlloc, LoadTextLines, UnloadTextLines

Textures (raylib.textures)

Image Loading (CPU)

FunctionDescription
LoadImage(name) → ImagePNG, JPG, BMP, TGA, GIF, QOI, PSD, DDS, HDR, KTX, ASTC, PKM, PVR
LoadImageRaw(name, w, h, format, headerSize) → ImageRaw pixel data
LoadImageAnim(name, *frames) → ImageAnimated GIF
LoadImageAnimFromMemory(type, data, size, *frames) → ImageFrom buffer
LoadImageFromMemory(type, data, size) → ImageDecoded image from buffer
LoadImageFromTexture(texture) → ImageRead GPU → CPU
LoadImageFromScreen() → ImageScreenshot to Image
IsImageValid(image) → bool
UnloadImage(image)
ExportImage(image, name) → bool
ExportImageToMemory(image, type, *size) → *u8Free with MemFree
ExportImageAsCode(image, name) → boolDump as .h

Image Generation

FunctionDescription
GenImageColor(w, h, color)Solid fill
GenImageGradientLinear(w, h, direction, start, end)Linear gradient (degrees)
GenImageGradientRadial(w, h, density, inner, outer)Radial
GenImageGradientSquare(w, h, density, inner, outer)Square
GenImageChecked(w, h, cx, cy, c1, c2)Checkerboard
GenImageWhiteNoise(w, h, factor)Noise
GenImagePerlinNoise(w, h, ox, oy, scale)Perlin
GenImageCellular(w, h, tileSize)Cellular automaton
GenImageText(w, h, text)Grayscale text

Image Manipulation

ImageCopy, ImageFromImage, ImageFromChannel, ImageText, ImageTextEx, ImageFormat, ImageToPOT, ImageCrop, ImageAlphaCrop/Clear/Mask/Premultiply, ImageBlurGaussian, ImageKernelConvolution, ImageResize, ImageResizeNN, ImageResizeCanvas, ImageMipmaps, ImageDither, ImageFlipVertical, ImageFlipHorizontal, ImageRotate(image, degrees), ImageRotateCW/CCW, ImageColorTint/Invert/Grayscale/Contrast/Brightness/Replace, GetImageAlphaBorder, GetImageColor.

FunctionDescription
LoadImageColors(image) → *ColorPixels as RGBA32 array
LoadImagePalette(image, max, *count) → *ColorDistinct colors
UnloadImageColors(*colors) / UnloadImagePalette(*colors)

Image Drawing (CPU rasterizer)

ImageClearBackground, ImageDrawPixel/V, ImageDrawLine/V/Ex, ImageDrawCircle/V, ImageDrawCircleLines/V, ImageDrawRectangle/V/Rec, ImageDrawRectangleLines, ImageDrawTriangle/Ex/Lines, ImageDrawTriangleFan, ImageDrawTriangleStrip, ImageDraw, ImageDrawText/Ex.

Texture Loading (GPU)

FunctionDescription
LoadTexture(name) → Texture
LoadTextureFromImage(image) → Texture
LoadTextureCubemap(image, layout) → Texture
LoadRenderTexture(w, h) → RenderTextureFBO
IsTextureValid(texture) → bool / IsRenderTextureValid(target) → bool
UnloadTexture(texture) / UnloadRenderTexture(target)
UpdateTexture(texture, *pixels) / UpdateTextureRec(texture, rec, *pixels)
GenTextureMipmaps(*texture)
SetTextureFilter(texture, filter) / SetTextureWrap(texture, wrap)

Texture Drawing

FunctionDescription
DrawTexture(texture, x, y, tint)
DrawTextureV(texture, pos, tint)
DrawTextureEx(texture, pos, rot, scale, tint)
DrawTextureRec(texture, source, pos, tint)Sub-rectangle
DrawTexturePro(texture, source, dest, origin, rotation, tint)Full transform
DrawTextureNPatch(texture, npatchInfo, dest, origin, rotation, tint)9-slice

Color & Pixel Utilities

FunctionDescription
ColorIsEqual(c1, c2) → bool
Fade(color, alpha) → Color
ColorToInt(color) → c_int0xRRGGBBAA
ColorNormalize(color) → Vector40..1 floats
ColorFromNormalized(v) → ColorInverse
ColorToHSV(color) → Vector3Hue 0..360, sat/val 0..1
ColorFromHSV(h, s, v) → Color
ColorTint/Brightness/Contrast/Alpha(color, ...) → ColorAdjustments
ColorAlphaBlend(dst, src, tint) → Color
ColorLerp(c1, c2, factor) → Color
GetColor(hex) → ColorFrom 0xRRGGBBAA
GetPixelColor(srcPtr, format) → ColorDecode pixel
SetPixelColor(dstPtr, color, format)Encode pixel
GetPixelDataSize(w, h, format) → c_intBytes

Models (raylib.models)

3D Shape Drawing

DrawCube(pos, 2.0, 2.0, 2.0, RED)
DrawSphere(pos, 1.0, BLUE)
DrawGrid(10, 1.0)
FunctionDescription
DrawLine3D / DrawPoint3D / DrawCircle3D / DrawTriangle3D / DrawTriangleStrip3DPrimitives
DrawCube / DrawCubeV / DrawCubeWires / DrawCubeWiresVCuboid
DrawSphere / DrawSphereEx / DrawSphereWiresSphere variants
DrawCylinder / DrawCylinderEx / DrawCylinderWires / DrawCylinderWiresExCylinder
DrawCapsule / DrawCapsuleWiresCapsule
DrawPlane(centerPos, size, color)XZ plane
DrawRay(ray, color)
DrawGrid(slices, spacing)Reference grid

Model Management

FunctionDescription
LoadModel(name) → ModelOBJ, glTF, IQM, M3D, VOX
LoadModelFromMesh(mesh) → ModelSingle-mesh model
IsModelValid(model) → bool
UnloadModel(model)
GetModelBoundingBox(model) → BoundingBox
DrawModel(model, pos, scale, tint)
DrawModelEx(model, pos, axis, angle, scale, tint)With rotation
DrawModelWires(...) / DrawModelWiresEx(...)Wireframe
DrawModelPoints(...) / DrawModelPointsEx(...)(5.5 — removed in 6.0)
DrawBoundingBox(box, color)
DrawBillboard(camera, texture, pos, scale, tint)
DrawBillboardRec(camera, texture, source, pos, size, tint)Sub-rect billboard
DrawBillboardPro(camera, texture, source, pos, up, size, origin, rotation, tint)Full control

Mesh

FunctionDescription
UploadMesh(*mesh, dynamic)Push to GPU
UpdateMeshBuffer(mesh, index, *data, size, offset)Update VBO
UnloadMesh(mesh)
DrawMesh(mesh, material, transform)
DrawMeshInstanced(mesh, material, *transforms, instances)
GetMeshBoundingBox(mesh) → BoundingBox
GenMeshTangents(*mesh)
ExportMesh(mesh, name) → bool
ExportMeshAsCode(mesh, name) → boolDump as .h

Mesh Generation

GenMeshPoly, GenMeshPlane, GenMeshCube, GenMeshSphere, GenMeshHemiSphere, GenMeshCylinder, GenMeshCone, GenMeshTorus, GenMeshKnot, GenMeshHeightmap, GenMeshCubicmap.

Material

FunctionDescription
LoadMaterials(name, *count) → *MaterialFrom model file
LoadMaterialDefault() → MaterialDIFFUSE/SPECULAR/NORMAL
IsMaterialValid(material) → bool
UnloadMaterial(material)
SetMaterialTexture(*material, mapType, texture)MATERIAL_MAP_DIFFUSE, etc.
SetModelMeshMaterial(*model, meshId, materialId)

Animation

Signature differs between 5.5 and 6.0:

  • 5.5: UpdateModelAnimation(model, anim, frame: c_int), UpdateModelAnimationBones(model, anim, frame: c_int), UnloadModelAnimation(anim).
  • 6.0: UpdateModelAnimation(..., frame: f32), UpdateModelAnimationEx(model, animA, frameA, animB, frameB, blend) for cross-fading.
FunctionDescription
LoadModelAnimations(name, *count) → *ModelAnimationLoad all anims
UpdateModelAnimation(model, anim, frame)Vertex CPU pose
UpdateModelAnimationBones(model, anim, frame) (5.5 — replaced in 6.0)GPU skinning
UpdateModelAnimationEx(model, a, fa, b, fb, blend) (6.0)Blended pose
UnloadModelAnimation(anim) (5.5 — removed in 6.0)
UnloadModelAnimations(*animations, count)Free array
IsModelAnimationValid(model, anim) → boolSkeleton compatible

3D Collision

FunctionDescription
CheckCollisionSpheres(c1, r1, c2, r2)
CheckCollisionBoxes(b1, b2)
CheckCollisionBoxSphere(box, c, r)
GetRayCollisionSphere(ray, c, r) → RayCollision
GetRayCollisionBox(ray, box) → RayCollision
GetRayCollisionMesh(ray, mesh, transform) → RayCollision
GetRayCollisionTriangle(ray, p1, p2, p3) → RayCollision
GetRayCollisionQuad(ray, p1, p2, p3, p4) → RayCollision

Audio (raylib.audio)

Device

InitAudioDevice()
defer CloseAudioDevice()
FunctionDescription
InitAudioDevice() / CloseAudioDevice()
IsAudioDeviceReady() → bool
SetMasterVolume(volume) / GetMasterVolume() → f320.0..1.0

Wave

FunctionDescription
LoadWave(name) → WaveWAV, OGG, MP3, FLAC, QOA, XM, MOD
LoadWaveFromMemory(type, data, size) → Wave
IsWaveValid(wave) → bool
UnloadWave(wave)
ExportWave(wave, name) → bool
WaveCopy(wave) → Wave
WaveCrop(*wave, init, final)Trim
WaveFormat(*wave, sampleRate, sampleSize, channels)Convert
LoadWaveSamples(wave) → *f32f32 stereo samples
UnloadWaveSamples(*samples)

Sound

var sfx = LoadSound("explosion.wav")
defer UnloadSound(sfx)
PlaySound(sfx)
SetSoundVolume(sfx, 0.8)
FunctionDescription
LoadSound(name) → Sound
LoadSoundFromWave(wave) → Sound
LoadSoundAlias(source) → SoundShares sample data; use to play multiple instances
IsSoundValid(sound) → bool
UpdateSound(sound, data, sampleCount)f32 stereo
UnloadSound(sound) / UnloadSoundAlias(alias)
PlaySound/StopSound/PauseSound/ResumeSound(sound)
IsSoundPlaying(sound) → bool
SetSoundVolume/Pitch/Pan(sound, value)

Music (Streaming)

var music = LoadMusicStream("background.ogg")
PlayMusicStream(music)
while (!WindowShouldClose()) {
    UpdateMusicStream(music)    // call every frame
    // ...
}
FunctionDescription
LoadMusicStream(name) → Music
LoadMusicStreamFromMemory(type, data, size) → Music
IsMusicValid(music) → bool
UnloadMusicStream(music)
PlayMusicStream/Stop/Pause/Resume(music)
UpdateMusicStream(music)Call every frame
IsMusicStreamPlaying(music) → bool
SeekMusicStream(music, seconds)
SetMusicVolume/Pitch/Pan(music, value)
GetMusicTimeLength(music) → f32 / GetMusicTimePlayed(music) → f32Seconds

AudioStream (Raw PCM)

FunctionDescription
LoadAudioStream(sampleRate, sampleSize, channels) → AudioStream
IsAudioStreamValid(stream) → bool
UnloadAudioStream(stream)
UpdateAudioStream(stream, data, frameCount)Push frames
IsAudioStreamProcessed(stream) → boolBuffer needs refill
PlayAudioStream/Pause/Resume/Stop(stream)
IsAudioStreamPlaying(stream) → bool
SetAudioStreamVolume/Pitch/Pan(stream, value)
SetAudioStreamBufferSizeDefault(size)New-stream default

Audio Callbacks (raylib 6.0)

AudioCallback signature: fn(*void, c_uint) — (bufferData, frameCount), each frame = 2 floats (stereo).

FunctionDescription
SetAudioStreamCallback(stream, callback)Audio thread requests new data
AttachAudioStreamProcessor(stream, processor)Pre-mix per-stream effect
DetachAudioStreamProcessor(stream, processor)
AttachAudioMixedProcessor(processor)Post-mix master effect
DetachAudioMixedProcessor(processor)

Colors (raylib.colors)

Colors are top-level const values — zero overhead, used directly:

var bg = RAYWHITE
var fg = DARKGRAY
var highlight = RED
ClearBackground(BLACK)
DrawText("Hi", 10, 10, 20, GREEN)
ConstantRGBAConstantRGBA
LIGHTGRAY200,200,200,255DARKBLUE0,82,172,255
GRAY130,130,130,255PURPLE200,122,255,255
DARKGRAY80,80,80,255VIOLET135,60,190,255
YELLOW253,249,0,255DARKPURPLE112,31,126,255
GOLD255,203,0,255BEIGE211,176,131,255
ORANGE255,161,0,255BROWN127,106,79,255
PINK255,109,194,255DARKBROWN76,63,47,255
RED230,41,55,255WHITE255,255,255,255
MAROON190,33,55,255BLACK0,0,0,255
GREEN0,228,48,255BLANK0,0,0,0
LIME0,158,47,255MAGENTA255,0,255,255
DARKGREEN0,117,44,255RAYWHITE245,245,245,255
SKYBLUE102,191,255,255
BLUE0,121,241,255

Custom colors: just construct a Color:

var custom = Color{128, 64, 200, 255}    // r, g, b, a

Config Flags

Set before InitWindow with SetConfigFlags:

SetConfigFlags(FLAG_WINDOW_RESIZABLE | FLAG_VSYNC_HINT)
InitWindow(800, 600, "Resizable Window")
FlagDescription
FLAG_VSYNC_HINTEnable V-Sync
FLAG_FULLSCREEN_MODEStart fullscreen
FLAG_WINDOW_RESIZABLEAllow resizing
FLAG_WINDOW_UNDECORATEDNo window frame
FLAG_WINDOW_HIDDENStart hidden
FLAG_WINDOW_MINIMIZED / FLAG_WINDOW_MAXIMIZEDStart minimized/maximized
FLAG_WINDOW_UNFOCUSEDStart unfocused
FLAG_WINDOW_TOPMOSTAlways on top
FLAG_WINDOW_ALWAYS_RUNKeep running when minimized
FLAG_WINDOW_TRANSPARENTTransparent framebuffer
FLAG_WINDOW_HIGHDPIHigh-DPI support
FLAG_MSAA_4X_HINT4x MSAA anti-aliasing

Platform Notes

  • Windows: Auto-switches to Clang for linking. The -DNOGDI -DNOUSER flags are automatically applied to prevent windows.h from conflicting with raylib’s Rectangle, CloseWindow, and ShowCursor definitions.
  • Linux: Links against libraylib.a with -lGL -lm -lpthread -ldl -lrt -lX11.
  • macOS: Links against libraylib.a with CoreVideo, IOKit, Cocoa, OpenGL frameworks.
  • Web (--target web): Uses libraylib_web.a (Emscripten build) with GLFW3, ASYNCIFY, 256 MB initial heap, 16 MB stack. Some extern struct patterns crash the compiler — see the GX compiler gotchas doc.
  • TCC: Not supported for raylib (can’t link static libraries). Clang is used automatically.

Why Not Source Compilation?

Unlike Sokol (which uses a single @cfile bridge), raylib cannot be compiled in a single translation unit. Its internal headers (rlgl.h, glad.h) define global variables that cause redefinition errors when multiple .c files are included together. Additionally, TCC lacks the Windows SDK headers that raylib’s GLFW backend requires. The prebuilt library approach is the most reliable path.

Module Layout

modules/
  raylib/
    c/
      raylib.h         Raylib header (currently 5.5; replace with 6.0 to enable 6.0-only bindings)
      gx_raylib_types.h  Type bridge (vec2/3/4 → Vector2/3/4, color macro undefs)
    lib/
      raylib.lib       Prebuilt static library (MSVC/Windows)
      libraylib.a      Prebuilt static library (GCC/Linux/macOS)
      libraylib_web.a  Prebuilt static library (Emscripten/web)
    gx/
      core.gx          Build directives, structs, window, timing, camera, shaders, files, memory, automation
      input.gx         Keyboard/mouse enums + basic IsKey*/IsMouseButton* queries
      shapes.gx        2D shapes, splines, 2D collision
      text.gx          Text drawing, fonts, codepoints, text utilities
      textures.gx      Image/texture loading, manipulation, color/pixel utilities
      colors.gx        Color constants (RED, BLUE, RAYWHITE, ...)
      models.gx        3D shapes, model/mesh/material, animations, 3D collision
      audio.gx         Sound, music streaming, wave, audio streams + 6.0 callbacks

Migrating From raylib 5.5 to 6.0

When you swap modules/raylib/c/raylib.h and the lib/*.lib/*.a files for raylib 6.0 builds, perform these .gx file edits:

core.gx — uncomment the raylib 6.0 ONLY block at the bottom (adds SetWindowIcons, GetKeyName, SetGamepadMappings, FileRename/Remove/Copy/Move, FileTextReplace/FindIndex, GetDirectoryFileCount[Ex], ComputeSHA256).

shapes.gx — uncomment the raylib 6.0 ONLY block (adds DrawLineDashed, DrawEllipseV, DrawEllipseLinesV, GetShapesTexture, GetShapesTextureRectangle).

text.gx — uncomment the raylib 6.0 ONLY block (adds TextRemoveSpaces, GetTextBetween, TextReplaceAlloc, TextReplaceBetween[Alloc], TextInsertAlloc, LoadTextLines, UnloadTextLines, MeasureTextCodepoints). Also widen LoadFontData to add a 7th param glyphCount: *c_int.

models.gx — three breaking changes:

  1. Change UpdateModelAnimation frame param from c_int to f32.
  2. Remove UpdateModelAnimationBones and UnloadModelAnimation (singular); uncomment UpdateModelAnimationEx from the 6.0 block.
  3. Remove DrawModelPoints and DrawModelPointsEx (gone in 6.0).

audio.gx — no edits needed (6.0 callbacks already declared and present in 5.5 too).

After these edits, all examples in examples/raylib/ continue to compile — the breaking changes are localized to model animation, which no current example exercises.