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.

Module version: raylib 6.0 (bundled raylib.h and prebuilt static libs). The wrapper exposes every public function in the 6.0 surface, including new arrivals like VR stereo, automation events, file-system utilities, compression / base64, and CRC32 / MD5 / SHA-1 / SHA-256 hashing.

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, structs
import raylib.input     // keyboard/mouse enums and functions
import raylib.shapes    // 2D shape drawing, splines, collision
import raylib.text      // text drawing, fonts, codepoints
import raylib.textures  // texture/image loading, drawing, color utilities
import raylib.colors    // color constants (rl_red, rl_blue, etc.)
import raylib.models    // 3D shapes, model loading, mesh, materials
import raylib.audio     // sound, music streaming, audio streams

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(rl_raywhite())

        DrawText("Hello from GX!", 190, 200, 20, rl_darkgray())
        DrawRectangle(100, 100, 200, 80, rl_red())
        DrawCircle(400, 300, 50.0, rl_blue())
        DrawFPS(10, 10)

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

        EndDrawing()
    }
    CloseWindow()
}

Core (raylib.core)

Structs

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

StructFieldsDescription
Vector2x, y: f322D vector/point
Vector3x, y, z: f323D vector/point
Vector4x, y, z, w: f324D vector/quaternion
Matrixm0..m15: f324x4 transformation matrix
Colorr, g, b, a: u8RGBA color
Rectanglex, y, width, height: f32Rectangle
Imagedata: *void, width, height, mipmaps, formatCPU image data
Textureid: c_uint, width, height, mipmaps, formatGPU texture
RenderTextureid, texture, depthRender target
NPatchInfosource: Rectangle, left, top, right, bottom, layoutN-patch layout
GlyphInfovalue, offsetX, offsetY, advanceX, imageGlyph data
FontbaseSize, glyphCount, glyphPadding, texture, recs, glyphsFont data
Camera2Doffset, target: Vector2, rotation, zoom: f322D camera
Camera3Dposition, target, up: Vector3, fovy: f32, projection3D camera
Shaderid: c_uint, locs: *c_intShader program
MaterialMaptexture, color, valueMaterial texture map
Materialshader, maps, paramsRendering material
MeshvertexCount, triangleCount, vertices, normals, ...Vertex data
Modeltransform, meshes, materials, bones, ...3D model
ModelAnimationboneCount, frameCount, bones, framePoses, nameSkeletal animation
Rayposition, direction: Vector3Ray for raycasting
RayCollisionhit: bool, distance, point, normalRay hit result
BoundingBoxmin, max: Vector3Axis-aligned box
Transformtranslation, rotation, scaleBone transform
BoneInfoname, parentSkeleton bone
WaveframeCount, sampleRate, sampleSize, channels, dataAudio wave data
AudioStreambuffer, processor, sampleRate, sampleSize, channelsAudio stream
Soundstream: AudioStream, frameCountLoaded sound
Musicstream, frameCount, looping, ctxType, ctxDataStreamed music
VrDeviceInfohResolution, vResolution, ...VR HMD parameters (6.0)
VrStereoConfigprojection[2], viewOffset[2], ...Per-eye render config (6.0)
FilePathListcapacity, count, pathsResult of directory / drag-drop scans (6.0)
AutomationEvent / AutomationEventListframe, type, params / capacity, count, eventsRecorded input event stream (6.0)

Construct structs by declaring a variable and setting fields:

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

Window Functions

FunctionSignatureDescription
InitWindow(c_int, c_int, cstr)Create window with width, height, title
CloseWindow()Close window and clean up
WindowShouldClose→ boolCheck if window should close
IsWindowReady→ boolCheck if window initialized
IsWindowFullscreen→ boolCheck fullscreen state
IsWindowMinimized→ boolCheck if minimized
IsWindowMaximized→ boolCheck if maximized
IsWindowFocused→ boolCheck if focused
IsWindowResized→ boolCheck if resized last frame
IsWindowState(c_uint) → boolCheck if a specific config flag is set
SetWindowState(c_uint)Enable config flag(s) at runtime
ClearWindowState(c_uint)Disable config flag(s) at runtime
SetWindowIcon(Image)Set window icon (single image)
SetWindowIcons(*Image, c_int)Set window icon (multiple sizes) (6.0)
SetWindowTitle(cstr)Change window title
SetWindowSize(c_int, c_int)Resize window
SetWindowPosition(c_int, c_int)Set window position
SetWindowMonitor(c_int)Move window to a specific monitor
SetWindowMinSize(c_int, c_int)Set minimum dimensions
SetWindowMaxSize(c_int, c_int)Set maximum dimensions
SetWindowOpacity(f32)Set opacity (0.0..1.0)
SetWindowFocused()Bring window to the foreground
GetWindowHandle→ *voidNative OS window handle
GetScreenWidth→ c_intGet current width
GetScreenHeight→ c_intGet current height
GetRenderWidth→ c_intRender width (HiDPI)
GetRenderHeight→ c_intRender height (HiDPI)
GetMonitorCount→ c_intNumber of monitors
GetCurrentMonitor→ c_intIndex of monitor the window is on
GetMonitorPosition(c_int) → Vector2Monitor origin
GetMonitorWidth(c_int) → c_intMonitor width
GetMonitorHeight(c_int) → c_intMonitor height
GetMonitorPhysicalWidth(c_int) → c_intPhysical width in mm
GetMonitorPhysicalHeight(c_int) → c_intPhysical height in mm
GetMonitorRefreshRate(c_int) → c_intMonitor refresh rate
GetMonitorName(c_int) → cstrHuman-readable monitor name
GetWindowPosition→ Vector2Window position
GetWindowScaleDPI→ Vector2DPI scale factor
ToggleFullscreen()Toggle fullscreen mode
ToggleBorderlessWindowed()Toggle borderless windowed
MaximizeWindow()Maximize window
MinimizeWindow()Minimize window
RestoreWindow()Restore window
SetConfigFlags(c_uint)Set window flags before InitWindow
SetClipboardText(cstr)Set clipboard text
GetClipboardText→ cstrGet clipboard text
GetClipboardImage→ ImageGet clipboard image (6.0)
EnableEventWaiting()Block on events instead of polling
DisableEventWaiting()Restore default polling behavior

Cursor

FunctionDescription
ShowCursor() / HideCursor()Show or hide the OS cursor
IsCursorHidden() → boolCheck cursor visibility
EnableCursor() / DisableCursor()Unlock / lock the cursor (FPS-style capture)
IsCursorOnScreen() → boolCheck if cursor is inside the window

Drawing Lifecycle

FunctionDescription
BeginDrawing()Start frame drawing
EndDrawing()End frame, swap buffers
ClearBackground(color)Clear framebuffer
BeginMode2D(camera)Begin 2D camera mode
EndMode2D()End 2D camera mode
BeginMode3D(camera)Begin 3D camera mode
EndMode3D()End 3D camera mode
BeginTextureMode(target)Draw to render texture
EndTextureMode()Stop drawing to render texture
BeginShaderMode(shader)Begin custom shader
EndShaderMode()End custom shader
BeginBlendMode(mode)Begin blending mode
EndBlendMode()End blending mode
BeginScissorMode(x, y, w, h)Begin scissor clipping
EndScissorMode()End scissor clipping

Shader Functions

FunctionSignatureDescription
LoadShader(cstr, cstr) → ShaderLoad vertex + fragment shader
LoadShaderFromMemory(cstr, cstr) → ShaderLoad shader from strings
IsShaderValid(Shader) → boolCheck shader validity
GetShaderLocation(Shader, cstr) → c_intGet uniform location
SetShaderValue(Shader, c_int, *void, c_int)Set shader uniform
SetShaderValueMatrix(Shader, c_int, Matrix)Set matrix uniform
UnloadShader(Shader)Free shader

Screen-Space

FunctionDescription
GetScreenToWorldRay(pos, camera)Screen point to 3D ray
GetWorldToScreen(pos3d, camera)3D point to screen coords
GetWorldToScreen2D(pos, camera2d)2D world to screen
GetScreenToWorld2D(pos, camera2d)Screen to 2D world
GetCameraMatrix(camera)Get camera transform matrix

Timing

FunctionSignatureDescription
SetTargetFPS(c_int)Set target FPS (0 = unlimited)
GetFPS→ c_intGet current FPS
GetFrameTime→ f32Delta time in seconds
GetTime→ f64Time since InitWindow

Mouse (Core)

FunctionSignatureDescription
GetMousePosition→ Vector2Mouse position
GetMouseDelta→ Vector2Mouse movement since last frame
GetMouseWheelMove→ f32Mouse wheel movement
GetMouseWheelMoveV→ Vector2Mouse wheel XY movement
GetMouseX→ c_intMouse X position
GetMouseY→ c_intMouse Y position
SetMousePosition(c_int, c_int)Set mouse position
SetMouseCursor(c_int)Set mouse cursor icon

Touch & Gestures

FunctionDescription
GetTouchPosition(index)Touch position for finger
GetTouchPointCount()Number of touch points
SetGesturesEnabled(flags)Enable gesture types
IsGestureDetected(gesture)Check gesture detected
GetGestureDragVector()Drag direction
GetGesturePinchVector()Pinch delta

Camera

FunctionDescription
UpdateCamera(camera, mode)Update camera with built-in mode
UpdateCameraPro(camera, movement, rotation, zoom)Manual camera update

Gamepad

FunctionDescription
IsGamepadAvailable(id)Check if gamepad connected
GetGamepadName(id)Get gamepad name
IsGamepadButtonPressed(id, btn)Button pressed this frame
IsGamepadButtonDown(id, btn)Button held
IsGamepadButtonReleased(id, btn)Button released this frame
IsGamepadButtonUp(id, btn)Button not being held
GetGamepadButtonPressed()Get last button from queue
GetGamepadAxisCount(id)Number of axes on the device
GetGamepadAxisMovement(id, axis)Axis value (-1.0..1.0)
SetGamepadMappings(mappings)Load custom SDL-style gamepad mappings (6.0)
SetGamepadVibration(id, left, right, dur)Rumble

Random

FunctionDescription
SetRandomSeed(seed)Set random seed
GetRandomValue(min, max)Random integer in range

Misc

FunctionDescription
TakeScreenshot(fileName)Save screenshot
OpenURL(url)Open URL in browser

File System & Drag-and-Drop (raylib 6.0 surface)

FunctionDescription
FileExists(path) → boolCheck if a file exists
DirectoryExists(path) → boolCheck if a directory exists
IsFileExtension(path, ext) → boolCompare file extension
GetFileLength(path) → c_intFile size in bytes
GetFileExtension(path) / GetFileName(path) / GetFileNameWithoutExt(path)Path component helpers
GetDirectoryPath(path) / GetPrevDirectoryPath(path)Parent / grandparent directory
GetWorkingDirectory() / GetApplicationDirectory()CWD and exe directory
MakeDirectory(path) / ChangeDirectory(path)Create / cd
IsPathFile(path) / IsFileNameValid(name)Path classification
LoadDirectoryFiles(dir) → FilePathListList directory contents
LoadDirectoryFilesEx(base, filter, scanSubdirs) → FilePathListFiltered recursive scan
UnloadDirectoryFiles(list)Free a FilePathList
IsFileDropped() → boolCheck if files were dropped on the window
LoadDroppedFiles() → FilePathList / UnloadDroppedFiles(list)Get / free drag-drop result
GetFileModTime(path) → c_longLast modification time

Compression & Base64 (raylib 6.0 surface)

FunctionDescription
CompressData(data, dataSize, *compSize) → *u8DEFLATE-compress bytes
DecompressData(comp, compSize, *dataSize) → *u8Decompress
EncodeDataBase64(data, dataSize, *outSize) → *c_charBase64 encode
DecodeDataBase64(data, *outSize) → *u8Base64 decode

Hashing (raylib 6.0 surface)

FunctionDescription
ComputeCRC32(data, dataSize) → c_uintCRC-32 checksum
ComputeMD5(data, dataSize) → *c_uintMD5 digest (4 × u32)
ComputeSHA1(data, dataSize) → *c_uintSHA-1 digest (5 × u32)
ComputeSHA256(data, dataSize) → *c_uintSHA-256 digest (8 × u32)

VR Stereo (raylib 6.0 surface)

FunctionDescription
LoadVrStereoConfig(device) → VrStereoConfigBuild per-eye config from VrDeviceInfo
UnloadVrStereoConfig(config)Free config
BeginVrStereoMode(config) / EndVrStereoMode()Bracket stereo rendering

Automation Events (raylib 6.0 surface)

Record and replay input streams — useful for tooling, deterministic tests, and demo capture.

FunctionDescription
LoadAutomationEventList(fileName) → AutomationEventListLoad recorded events
UnloadAutomationEventList(list)Free list
ExportAutomationEventList(list, fileName) → boolSave to file
SetAutomationEventList(*list)Bind list for recording
SetAutomationEventBaseFrame(frame)Set base frame for new recordings
StartAutomationEventRecording() / StopAutomationEventRecording()Bracket recording
PlayAutomationEvent(event)Replay a single event

Input (raylib.input)

Keyboard

if (IsKeyPressed(KEY_SPACE)) { jump() }
if (IsKeyDown(KEY_A)) { move_left() }
FunctionSignatureDescription
IsKeyPressedKeyboardKey → boolKey pressed this frame
IsKeyPressedRepeatKeyboardKey → boolKey pressed (with repeat)
IsKeyDownKeyboardKey → boolKey being held
IsKeyReleasedKeyboardKey → boolKey released this frame
IsKeyUpKeyboardKey → boolKey not being held
GetKeyPressed→ c_intGet key from queue
GetCharPressed→ c_intGet next character from queue (for text input)
SetExitKey(c_int)Override the default exit key (KEY_ESCAPE by default)
GetKeyName(c_int) → cstrHuman-readable name for a key code (6.0)

All keyboard keys are available as enum constants: KEY_A through KEY_Z, KEY_ZERO through KEY_NINE, KEY_SPACE, KEY_ESCAPE, KEY_ENTER, KEY_TAB, KEY_F1 through KEY_F12, arrow keys (KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT), modifiers (KEY_LEFT_SHIFT, KEY_LEFT_CONTROL, KEY_LEFT_ALT), and more.

Mouse Buttons

if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) { shoot() }
FunctionSignatureDescription
IsMouseButtonPressedMouseButton → boolButton pressed this frame
IsMouseButtonDownMouseButton → boolButton being held
IsMouseButtonReleasedMouseButton → boolButton released this frame
IsMouseButtonUpMouseButton → boolButton not being held

Constants: MOUSE_BUTTON_LEFT, MOUSE_BUTTON_RIGHT, MOUSE_BUTTON_MIDDLE.

Shapes (raylib.shapes)

Lines

FunctionDescription
DrawLine(x1, y1, x2, y2, color)Draw line (integer coords)
DrawLineV(start, end, color)Draw line (Vector2)
DrawLineEx(start, end, thick, color)Draw thick line

Circles

FunctionDescription
DrawCircle(cx, cy, radius, color)Filled circle
DrawCircleV(center, radius, color)Filled circle (Vector2)
DrawCircleLines(cx, cy, radius, color)Circle outline
DrawCircleGradient(cx, cy, radius, inner, outer)Gradient circle

Rectangles

FunctionDescription
DrawRectangle(x, y, w, h, color)Filled rectangle
DrawRectangleV(pos, size, color)Filled rectangle (Vector2)
DrawRectangleRec(rec, color)Filled rectangle (Rectangle)
DrawRectanglePro(rec, origin, rotation, color)Rotated rectangle
DrawRectangleLines(x, y, w, h, color)Rectangle outline
DrawRectangleLinesEx(rec, thick, color)Thick outline
DrawRectangleRounded(rec, roundness, segments, color)Rounded corners
DrawRectangleGradientV(x, y, w, h, top, bottom)Vertical gradient
DrawRectangleGradientH(x, y, w, h, left, right)Horizontal gradient

Triangles and Polygons

FunctionDescription
DrawTriangle(v1, v2, v3, color)Filled triangle
DrawTriangleLines(v1, v2, v3, color)Triangle outline
DrawPoly(center, sides, radius, rotation, color)Regular polygon

Collision Detection

FunctionDescription
CheckCollisionRecs(r1, r2)Rectangle vs rectangle
CheckCollisionCircles(c1, r1, c2, r2)Circle vs circle
CheckCollisionCircleRec(center, radius, rec)Circle vs rectangle
CheckCollisionCircleLine(center, radius, p1, p2)Circle vs line segment (6.0)
CheckCollisionPointRec(point, rec)Point vs rectangle
CheckCollisionPointCircle(point, center, radius)Point vs circle
CheckCollisionPointTriangle(point, p1, p2, p3)Point vs triangle
CheckCollisionPointPoly(point, *points, count)Point vs polygon
CheckCollisionPointLine(point, p1, p2, threshold)Point vs line segment
CheckCollisionLines(s1, e1, s2, e2, *out)Line segment intersection (writes hit point)
GetCollisionRec(r1, r2)Get overlap rectangle

Splines

raylib 6.0 ships full-curve helpers for five spline families. Each family has a Draw… (whole curve), DrawSegment… (single section), and GetPoint… (sample at t ∈ [0,1]) variant:

FamilyDraw wholeDraw segmentSample point
LinearDrawSplineLinearDrawSplineSegmentLinearGetSplinePointLinear
B-SplineDrawSplineBasisDrawSplineSegmentBasisGetSplinePointBasis
Catmull-RomDrawSplineCatmullRomDrawSplineSegmentCatmullRomGetSplinePointCatmullRom
Quadratic BézierDrawSplineBezierQuadraticDrawSplineSegmentBezierQuadraticGetSplinePointBezierQuad
Cubic BézierDrawSplineBezierCubicDrawSplineSegmentBezierCubicGetSplinePointBezierCubic

Text (raylib.text)

FunctionSignatureDescription
DrawText(cstr, x, y, fontSize, color)Draw with default font
DrawTextEx(font, cstr, pos, size, spacing, color)Draw with custom font
DrawTextPro(font, cstr, pos, origin, rot, size, spacing, color)Rotatable, anchored draw
DrawTextCodepoint(font, codepoint, pos, size, color)Draw single codepoint
DrawTextCodepoints(font, *codepoints, count, pos, size, spacing, color)Draw codepoint array
DrawFPS(x, y)Draw FPS counter
MeasureText(cstr, fontSize) → c_intGet text width in pixels
MeasureTextEx(font, cstr, size, spacing) → Vector2Width + height
SetTextLineSpacing(c_int)Set vertical spacing for multi-line draws
LoadFont(cstr) → FontLoad font from file
LoadFontEx(cstr, size, *codepoints, count) → FontLoad with custom glyph set
LoadFontFromImage(Image, key, firstChar) → FontLoad font from a sprite-sheet image
LoadFontFromMemory(type, data, dataSize, size, *codepoints, count) → FontLoad from buffer
UnloadFont(Font)Free font resources
IsFontValid(Font) → boolCheck font validity
GetFontDefault→ FontGet built-in default font
GetGlyphIndex / GetGlyphInfo / GetGlyphAtlasRecGlyph lookup helpers
LoadCodepoints / UnloadCodepointsUTF-8 ↔ codepoint array
GetCodepoint / GetCodepointNext / GetCodepointPreviousCodepoint cursor walk
CodepointToUTF8 / LoadUTF8 / UnloadUTF8Encode codepoints to UTF-8

Textures (raylib.textures)

FunctionSignatureDescription
LoadTexture(cstr) → TextureLoad from file (PNG, JPG, etc.)
LoadTextureFromImage(Image) → TextureUpload CPU image to GPU
LoadTextureCubemap(Image, layout) → TextureCubemap from image (6 faces)
IsTextureValid(Texture) → boolCheck texture validity
UnloadTexture(Texture)Free GPU texture
UpdateTexture(Texture, *pixels)Replace texture pixel data
UpdateTextureRec(Texture, rec, *pixels)Replace sub-region pixels
GenTextureMipmaps(*Texture)Generate mipmap chain
SetTextureFilter / SetTextureWrap(Texture, mode)Sampling parameters
DrawTexture(texture, x, y, tint)Draw at position
DrawTextureV(texture, pos, tint)Draw at Vector2 position
DrawTextureEx(texture, pos, rot, scale, tint)Draw with transforms
DrawTextureRec(texture, source, pos, tint)Draw sub-rectangle
DrawTexturePro(texture, source, dest, origin, rot, tint)Full source/dest blit
DrawTextureNPatch(texture, info, dest, origin, rot, tint)9-slice / 3-patch UI scaling
LoadRenderTexture(w, h) → RenderTextureCreate render target
IsRenderTextureValid(RenderTexture) → boolCheck render target validity
UnloadRenderTexture(RenderTexture)Free render target

Image Loading & Manipulation (CPU-side)

FunctionDescription
LoadImage / LoadImageRaw / LoadImageFromMemory / LoadImageFromTexture / LoadImageFromScreenLoad images from various sources
LoadImageAnim / LoadImageAnimFromMemoryLoad animated GIF / animation strips (6.0)
IsImageValid(img) → bool / UnloadImage(img)Validity / free
ExportImage(img, file) / ExportImageToMemory(img, type, *size) / ExportImageAsCode(img, file)Persist to disk or memory
GenImageColor / GenImageGradientLinear/Radial/Square / GenImageChecked / GenImageWhiteNoise / GenImagePerlinNoise / GenImageCellular / GenImageTextProcedurally generate images
ImageCopy / ImageFromImage / ImageFromChannel / ImageText / ImageTextExDerive new images
ImageFormat / ImageToPOT / ImageCrop / ImageResize / ImageResizeNN / ImageResizeCanvas / ImageMipmaps / ImageDitherFormat / size adjustments
ImageAlphaCrop / ImageAlphaClear / ImageAlphaMask / ImageAlphaPremultiplyAlpha helpers
ImageBlurGaussian / ImageKernelConvolutionFiltering
ImageFlipVertical / ImageFlipHorizontal / ImageRotate / ImageRotateCW / ImageRotateCCWGeometric transforms
ImageColorTint / ImageColorInvert / ImageColorGrayscale / ImageColorContrast / ImageColorBrightness / ImageColorReplaceColor filters
LoadImageColors / LoadImagePalette / UnloadImageColors / UnloadImagePalettePixel access
GetImageAlphaBorder(img, threshold) / GetImageColor(img, x, y)Pixel queries
ImageDraw… familySoftware-rasterize shapes/lines/text directly into an Image

Color Helpers

FunctionDescription
ColorIsEqual(a, b) → boolCompare two colors (6.0)
Fade(color, alpha) → ColorAdjust alpha
ColorToInt(c) → c_int / GetColor(hex) → ColorRGBA ↔ packed int
ColorNormalize / ColorFromNormalizedRGBA u8 ↔ Vector4 0..1
ColorToHSV / ColorFromHSVRGB ↔ HSV
ColorTint(c, tint) → Color (6.0)Multiply two colors
ColorBrightness(c, factor) / ColorContrast(c, factor) (6.0)Tone curves
ColorAlpha(c, a) / ColorAlphaBlend(dst, src, tint) (6.0)Compositing
ColorLerp(a, b, t) (6.0)Linear interpolation between two colors
GetPixelColor / SetPixelColor / GetPixelDataSizePixel-format helpers

Colors (raylib.colors)

Raylib colors are provided as functions prefixed with rl_:

var bg = rl_raywhite()       // Light background
var fg = rl_darkgray()       // Dark text
var highlight = rl_red()     // Bright red
FunctionRGBDescription
rl_white()255, 255, 255White
rl_black()0, 0, 0Black
rl_red()230, 41, 55Red
rl_green()0, 228, 48Green
rl_blue()0, 121, 241Blue
rl_yellow()253, 249, 0Yellow
rl_orange()255, 161, 0Orange
rl_pink()255, 109, 194Pink
rl_purple()200, 122, 255Purple
rl_skyblue()102, 191, 255Sky Blue
rl_gray()130, 130, 130Gray
rl_darkgray()80, 80, 80Dark Gray
rl_lightgray()200, 200, 200Light Gray
rl_raywhite()245, 245, 245Raylib White
rl_blank()0, 0, 0, 0Transparent

Custom colors with rl_color:

var custom = rl_color(128, 64, 200, 255)    // r, g, b, a

Models (raylib.models)

3D Shape Drawing

DrawCube(pos, 2.0, 2.0, 2.0, rl_red())
DrawSphere(pos, 1.0, rl_blue())
DrawGrid(10, 1.0)
FunctionDescription
DrawCube/VDraw cube (size or Vector3)
DrawCubeWires/VCube wireframe
DrawSphere/Ex/WiresSphere (solid/custom/wireframe)
DrawCylinder/Ex/Wires/WiresExCylinder variants
DrawCapsule/WiresCapsule shape
DrawPlaneFlat plane
DrawLine3D3D line
DrawPoint3D3D point
DrawCircle3D3D circle
DrawTriangle3D3D triangle
DrawGridReference grid
DrawRayVisualize a ray

Model Loading & Drawing

FunctionDescription
LoadModel(fileName)Load 3D model from file
LoadModelFromMesh(mesh)Create model from mesh
UnloadModel(model)Free model resources
IsModelValid(model)Check model validity
GetModelBoundingBox(model)AABB of all model meshes
DrawModel(model, pos, scale, tint)Draw model
DrawModelEx(model, pos, axis, angle, scale, tint)Draw with rotation
DrawModelWires / DrawModelWiresExWireframe variants
DrawModelPoints / DrawModelPointsExPoint-cloud variants
DrawBoundingBox(box, color)Draw a BoundingBox
DrawBillboard(cam, tex, pos, scale, tint)Camera-facing quad
DrawBillboardRec(cam, tex, source, pos, size, tint)Billboard from sub-rect
DrawBillboardPro(cam, tex, source, pos, up, size, origin, rot, tint)Full-control billboard

Mesh

FunctionDescription
UploadMesh(*mesh, dynamic)Upload mesh data to GPU
UpdateMeshBuffer(mesh, idx, *data, size, off)Update a vertex buffer
UnloadMesh(mesh)Free mesh resources
DrawMesh(mesh, material, transform)Draw a single mesh
DrawMeshInstanced(mesh, material, *transforms, count)Instanced draw
GetMeshBoundingBox(mesh)Compute AABB
GenMeshTangents(*mesh)Generate tangents in-place
ExportMesh(mesh, file) / ExportMeshAsCode(mesh, file)Persist mesh

Materials & Animations

FunctionDescription
LoadMaterials(file, *count) / LoadMaterialDefault() / IsMaterialValid(m) / UnloadMaterial(m)Material lifecycle
SetMaterialTexture(*mat, mapType, tex)Bind a texture map
SetModelMeshMaterial(*model, meshId, matId)Assign material to mesh
LoadModelAnimations(file, *count)Load skeletal animations
UpdateModelAnimation(model, anim, frame)Apply animation frame
UpdateModelAnimationBones(model, anim, frame)Apply bone-only update (6.0)
UnloadModelAnimation(s)Free animation(s)
IsModelAnimationValid(model, anim)Validity check

Mesh Generation

var cube = GenMeshCube(1.0, 1.0, 1.0)
var sphere = GenMeshSphere(0.5, 16, 16)

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

3D Collision

FunctionDescription
CheckCollisionSpheresSphere vs sphere
CheckCollisionBoxesAABB vs AABB
CheckCollisionBoxSphereAABB vs sphere
GetRayCollisionSphere/Box/Mesh/Triangle/QuadRay intersection tests

Audio (raylib.audio)

Setup

InitAudioDevice()
defer CloseAudioDevice()

Sound (short samples)

var sfx = LoadSound("explosion.wav")
PlaySound(sfx)
SetSoundVolume(sfx, 0.8)
// ...
UnloadSound(sfx)
FunctionDescription
InitAudioDevice/CloseAudioDeviceInit/shutdown audio
IsAudioDeviceReadyCheck audio ready
SetMasterVolume/GetMasterVolumeMaster volume (0.0..1.0)
LoadSound(fileName)Load sound from file
LoadSoundFromWave(wave)Create sound from wave
LoadSoundAlias(source) → SoundCheap copy that shares wave data (6.0)
IsSoundValid(sound)Check sound validity
UpdateSound(sound, *data, count)Replace sample data
UnloadSound(sound) / UnloadSoundAlias(alias)Free sound / alias
PlaySound/StopSound/PauseSound/ResumeSoundPlayback control
IsSoundPlaying(sound)Check if playing
SetSoundVolume/Pitch/PanSound properties

Music (streaming)

var music = LoadMusicStream("background.ogg")
PlayMusicStream(music)
// In game loop:
UpdateMusicStream(music)
FunctionDescription
LoadMusicStream(fileName)Load music for streaming
UnloadMusicStream(music)Free music
PlayMusicStream/Stop/Pause/ResumePlayback control
UpdateMusicStream(music)Call every frame
IsMusicStreamPlaying(music)Check if playing
SeekMusicStream(music, position)Seek to position
SetMusicVolume/Pitch/PanMusic properties
GetMusicTimeLength/TimePlayedDuration and position

Wave Processing

FunctionDescription
LoadWave(fileName) / LoadWaveFromMemory(type, data, size)Load wave data
IsWaveValid(wave)Check wave validity
WaveCopy/WaveCrop/WaveFormatProcess wave data
LoadWaveSamples/UnloadWaveSamplesAccess raw float samples
ExportWave(wave, fileName) / ExportWaveAsCode(wave, fileName)Save wave to file
UnloadWave(wave)Free wave

Audio Streams (low-level, callback-driven)

FunctionDescription
LoadAudioStream(sampleRate, sampleSize, channels)Allocate a streamable audio source
IsAudioStreamValid(s) / UnloadAudioStream(s)Validity / free
UpdateAudioStream(s, *data, frames)Push samples
IsAudioStreamProcessed(s)Check if buffers are consumed
PlayAudioStream / PauseAudioStream / ResumeAudioStream / StopAudioStreamPlayback control
IsAudioStreamPlaying(s)Check play state
SetAudioStreamVolume / Pitch / PanPer-stream properties
SetAudioStreamBufferSizeDefault(size)Tune internal buffer size
SetAudioStreamCallback(s, cb)Pull-based generation callback
AttachAudioStreamProcessor / DetachAudioStreamProcessor(s, cb)Per-stream DSP processor
AttachAudioMixedProcessor / DetachAudioMixedProcessor(cb)Global mix processor

Config Flags

Set before InitWindow with SetConfigFlags:

SetConfigFlags(FLAG_WINDOW_RESIZABLE)
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_TRANSPARENTTransparent framebuffer
FLAG_WINDOW_HIGHDPIHigh-DPI support
FLAG_MSAA_4X_HINT4x MSAA anti-aliasing
FLAG_WINDOW_ALWAYS_RUNKeep running when minimized

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.
  • 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 (v6.0)
    lib/
      raylib.lib       Prebuilt static library (MSVC/Windows)
      libraylib.a      Prebuilt static library (GCC/Linux/macOS)
    gx/
      core.gx          Build directives, 29 structs, window, timing, camera, shaders
      input.gx         Keyboard/mouse enums and query functions
      shapes.gx        2D shapes, splines, 2D collision
      text.gx          Text drawing, fonts, codepoints, text utilities
      textures.gx      Image/texture loading, manipulation, color utilities
      colors.gx        Color constants (rl_red, rl_blue, etc.)
      models.gx        3D shapes, model/mesh/material, animations, 3D collision
      audio.gx         Sound, music streaming, wave processing, audio streams