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:
raylib.h — place in modules/raylib/c/
raylib.lib (MSVC) or libraylib.a (GCC) — place in modules/raylib/lib/
- 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:
| Struct | Fields | Description |
|---|
Vector2 | x, y: f32 | 2D vector/point |
Vector3 | x, y, z: f32 | 3D vector/point |
Vector4 | x, y, z, w: f32 | 4D vector/quaternion |
Matrix | m0..m15: f32 | 4x4 transformation matrix |
Color | r, g, b, a: u8 | RGBA color |
Rectangle | x, y, width, height: f32 | Rectangle |
Image | data: *void, width, height, mipmaps, format | CPU image data |
Texture | id: c_uint, width, height, mipmaps, format | GPU texture |
RenderTexture | id, texture, depth | Render target |
NPatchInfo | source: Rectangle, left, top, right, bottom, layout | N-patch layout |
GlyphInfo | value, offsetX, offsetY, advanceX, image | Glyph data |
Font | baseSize, glyphCount, glyphPadding, texture, recs, glyphs | Font data |
Camera2D | offset, target: Vector2, rotation, zoom: f32 | 2D camera |
Camera3D | position, target, up: Vector3, fovy: f32, projection | 3D camera |
Shader | id: c_uint, locs: *c_int | Shader program |
MaterialMap | texture, color, value | Material texture map |
Material | shader, maps, params | Rendering material |
Mesh | vertexCount, triangleCount, vertices, normals, ... | Vertex data |
Model | transform, meshes, materials, bones, ... | 3D model |
ModelAnimation | boneCount, frameCount, bones, framePoses, name | Skeletal animation |
Ray | position, direction: Vector3 | Ray for raycasting |
RayCollision | hit: bool, distance, point, normal | Ray hit result |
BoundingBox | min, max: Vector3 | Axis-aligned box |
Transform | translation, rotation, scale | Bone transform |
BoneInfo | name, parent | Skeleton bone |
Wave | frameCount, sampleRate, sampleSize, channels, data | Audio wave data |
AudioStream | buffer, processor, sampleRate, sampleSize, channels | Audio stream |
Sound | stream: AudioStream, frameCount | Loaded sound |
Music | stream, frameCount, looping, ctxType, ctxData | Streamed music |
VrDeviceInfo | hResolution, vResolution, ... | VR HMD parameters (6.0) |
VrStereoConfig | projection[2], viewOffset[2], ... | Per-eye render config (6.0) |
FilePathList | capacity, count, paths | Result of directory / drag-drop scans (6.0) |
AutomationEvent / AutomationEventList | frame, type, params / capacity, count, events | Recorded 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
| Function | Signature | Description |
|---|
InitWindow | (c_int, c_int, cstr) | Create window with width, height, title |
CloseWindow | () | Close window and clean up |
WindowShouldClose | → bool | Check if window should close |
IsWindowReady | → bool | Check if window initialized |
IsWindowFullscreen | → bool | Check fullscreen state |
IsWindowMinimized | → bool | Check if minimized |
IsWindowMaximized | → bool | Check if maximized |
IsWindowFocused | → bool | Check if focused |
IsWindowResized | → bool | Check if resized last frame |
IsWindowState | (c_uint) → bool | Check 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 | → *void | Native OS window handle |
GetScreenWidth | → c_int | Get current width |
GetScreenHeight | → c_int | Get current height |
GetRenderWidth | → c_int | Render width (HiDPI) |
GetRenderHeight | → c_int | Render height (HiDPI) |
GetMonitorCount | → c_int | Number of monitors |
GetCurrentMonitor | → c_int | Index of monitor the window is on |
GetMonitorPosition | (c_int) → Vector2 | Monitor origin |
GetMonitorWidth | (c_int) → c_int | Monitor width |
GetMonitorHeight | (c_int) → c_int | Monitor height |
GetMonitorPhysicalWidth | (c_int) → c_int | Physical width in mm |
GetMonitorPhysicalHeight | (c_int) → c_int | Physical height in mm |
GetMonitorRefreshRate | (c_int) → c_int | Monitor refresh rate |
GetMonitorName | (c_int) → cstr | Human-readable monitor name |
GetWindowPosition | → Vector2 | Window position |
GetWindowScaleDPI | → Vector2 | DPI 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 | → cstr | Get clipboard text |
GetClipboardImage | → Image | Get clipboard image (6.0) |
EnableEventWaiting | () | Block on events instead of polling |
DisableEventWaiting | () | Restore default polling behavior |
Cursor
| Function | Description |
|---|
ShowCursor() / HideCursor() | Show or hide the OS cursor |
IsCursorHidden() → bool | Check cursor visibility |
EnableCursor() / DisableCursor() | Unlock / lock the cursor (FPS-style capture) |
IsCursorOnScreen() → bool | Check if cursor is inside the window |
Drawing Lifecycle
| Function | Description |
|---|
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
| Function | Signature | Description |
|---|
LoadShader | (cstr, cstr) → Shader | Load vertex + fragment shader |
LoadShaderFromMemory | (cstr, cstr) → Shader | Load shader from strings |
IsShaderValid | (Shader) → bool | Check shader validity |
GetShaderLocation | (Shader, cstr) → c_int | Get 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
| Function | Description |
|---|
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
| Function | Signature | Description |
|---|
SetTargetFPS | (c_int) | Set target FPS (0 = unlimited) |
GetFPS | → c_int | Get current FPS |
GetFrameTime | → f32 | Delta time in seconds |
GetTime | → f64 | Time since InitWindow |
Mouse (Core)
| Function | Signature | Description |
|---|
GetMousePosition | → Vector2 | Mouse position |
GetMouseDelta | → Vector2 | Mouse movement since last frame |
GetMouseWheelMove | → f32 | Mouse wheel movement |
GetMouseWheelMoveV | → Vector2 | Mouse wheel XY movement |
GetMouseX | → c_int | Mouse X position |
GetMouseY | → c_int | Mouse Y position |
SetMousePosition | (c_int, c_int) | Set mouse position |
SetMouseCursor | (c_int) | Set mouse cursor icon |
Touch & Gestures
| Function | Description |
|---|
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
| Function | Description |
|---|
UpdateCamera(camera, mode) | Update camera with built-in mode |
UpdateCameraPro(camera, movement, rotation, zoom) | Manual camera update |
Gamepad
| Function | Description |
|---|
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
| Function | Description |
|---|
SetRandomSeed(seed) | Set random seed |
GetRandomValue(min, max) | Random integer in range |
Misc
| Function | Description |
|---|
TakeScreenshot(fileName) | Save screenshot |
OpenURL(url) | Open URL in browser |
File System & Drag-and-Drop (raylib 6.0 surface)
| Function | Description |
|---|
FileExists(path) → bool | Check if a file exists |
DirectoryExists(path) → bool | Check if a directory exists |
IsFileExtension(path, ext) → bool | Compare file extension |
GetFileLength(path) → c_int | File 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) → FilePathList | List directory contents |
LoadDirectoryFilesEx(base, filter, scanSubdirs) → FilePathList | Filtered recursive scan |
UnloadDirectoryFiles(list) | Free a FilePathList |
IsFileDropped() → bool | Check if files were dropped on the window |
LoadDroppedFiles() → FilePathList / UnloadDroppedFiles(list) | Get / free drag-drop result |
GetFileModTime(path) → c_long | Last modification time |
Compression & Base64 (raylib 6.0 surface)
| Function | Description |
|---|
CompressData(data, dataSize, *compSize) → *u8 | DEFLATE-compress bytes |
DecompressData(comp, compSize, *dataSize) → *u8 | Decompress |
EncodeDataBase64(data, dataSize, *outSize) → *c_char | Base64 encode |
DecodeDataBase64(data, *outSize) → *u8 | Base64 decode |
Hashing (raylib 6.0 surface)
| Function | Description |
|---|
ComputeCRC32(data, dataSize) → c_uint | CRC-32 checksum |
ComputeMD5(data, dataSize) → *c_uint | MD5 digest (4 × u32) |
ComputeSHA1(data, dataSize) → *c_uint | SHA-1 digest (5 × u32) |
ComputeSHA256(data, dataSize) → *c_uint | SHA-256 digest (8 × u32) |
VR Stereo (raylib 6.0 surface)
| Function | Description |
|---|
LoadVrStereoConfig(device) → VrStereoConfig | Build 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.
| Function | Description |
|---|
LoadAutomationEventList(fileName) → AutomationEventList | Load recorded events |
UnloadAutomationEventList(list) | Free list |
ExportAutomationEventList(list, fileName) → bool | Save 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 |
Keyboard
if (IsKeyPressed(KEY_SPACE)) { jump() }
if (IsKeyDown(KEY_A)) { move_left() }
| Function | Signature | Description |
|---|
IsKeyPressed | KeyboardKey → bool | Key pressed this frame |
IsKeyPressedRepeat | KeyboardKey → bool | Key pressed (with repeat) |
IsKeyDown | KeyboardKey → bool | Key being held |
IsKeyReleased | KeyboardKey → bool | Key released this frame |
IsKeyUp | KeyboardKey → bool | Key not being held |
GetKeyPressed | → c_int | Get key from queue |
GetCharPressed | → c_int | Get next character from queue (for text input) |
SetExitKey | (c_int) | Override the default exit key (KEY_ESCAPE by default) |
GetKeyName | (c_int) → cstr | Human-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.
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) { shoot() }
| Function | Signature | Description |
|---|
IsMouseButtonPressed | MouseButton → bool | Button pressed this frame |
IsMouseButtonDown | MouseButton → bool | Button being held |
IsMouseButtonReleased | MouseButton → bool | Button released this frame |
IsMouseButtonUp | MouseButton → bool | Button not being held |
Constants: MOUSE_BUTTON_LEFT, MOUSE_BUTTON_RIGHT, MOUSE_BUTTON_MIDDLE.
Shapes (raylib.shapes)
Lines
| Function | Description |
|---|
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
| Function | Description |
|---|
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
| Function | Description |
|---|
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
| Function | Description |
|---|
DrawTriangle(v1, v2, v3, color) | Filled triangle |
DrawTriangleLines(v1, v2, v3, color) | Triangle outline |
DrawPoly(center, sides, radius, rotation, color) | Regular polygon |
Collision Detection
| Function | Description |
|---|
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:
| Family | Draw whole | Draw segment | Sample point |
|---|
| Linear | DrawSplineLinear | DrawSplineSegmentLinear | GetSplinePointLinear |
| B-Spline | DrawSplineBasis | DrawSplineSegmentBasis | GetSplinePointBasis |
| Catmull-Rom | DrawSplineCatmullRom | DrawSplineSegmentCatmullRom | GetSplinePointCatmullRom |
| Quadratic Bézier | DrawSplineBezierQuadratic | DrawSplineSegmentBezierQuadratic | GetSplinePointBezierQuad |
| Cubic Bézier | DrawSplineBezierCubic | DrawSplineSegmentBezierCubic | GetSplinePointBezierCubic |
Text (raylib.text)
| Function | Signature | Description |
|---|
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_int | Get text width in pixels |
MeasureTextEx | (font, cstr, size, spacing) → Vector2 | Width + height |
SetTextLineSpacing | (c_int) | Set vertical spacing for multi-line draws |
LoadFont | (cstr) → Font | Load font from file |
LoadFontEx | (cstr, size, *codepoints, count) → Font | Load with custom glyph set |
LoadFontFromImage | (Image, key, firstChar) → Font | Load font from a sprite-sheet image |
LoadFontFromMemory | (type, data, dataSize, size, *codepoints, count) → Font | Load from buffer |
UnloadFont | (Font) | Free font resources |
IsFontValid | (Font) → bool | Check font validity |
GetFontDefault | → Font | Get built-in default font |
GetGlyphIndex / GetGlyphInfo / GetGlyphAtlasRec | Glyph lookup helpers | |
LoadCodepoints / UnloadCodepoints | UTF-8 ↔ codepoint array | |
GetCodepoint / GetCodepointNext / GetCodepointPrevious | Codepoint cursor walk | |
CodepointToUTF8 / LoadUTF8 / UnloadUTF8 | Encode codepoints to UTF-8 | |
Textures (raylib.textures)
| Function | Signature | Description |
|---|
LoadTexture | (cstr) → Texture | Load from file (PNG, JPG, etc.) |
LoadTextureFromImage | (Image) → Texture | Upload CPU image to GPU |
LoadTextureCubemap | (Image, layout) → Texture | Cubemap from image (6 faces) |
IsTextureValid | (Texture) → bool | Check 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) → RenderTexture | Create render target |
IsRenderTextureValid | (RenderTexture) → bool | Check render target validity |
UnloadRenderTexture | (RenderTexture) | Free render target |
Image Loading & Manipulation (CPU-side)
| Function | Description |
|---|
LoadImage / LoadImageRaw / LoadImageFromMemory / LoadImageFromTexture / LoadImageFromScreen | Load images from various sources |
LoadImageAnim / LoadImageAnimFromMemory | Load 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 / GenImageText | Procedurally generate images |
ImageCopy / ImageFromImage / ImageFromChannel / ImageText / ImageTextEx | Derive new images |
ImageFormat / ImageToPOT / ImageCrop / ImageResize / ImageResizeNN / ImageResizeCanvas / ImageMipmaps / ImageDither | Format / size adjustments |
ImageAlphaCrop / ImageAlphaClear / ImageAlphaMask / ImageAlphaPremultiply | Alpha helpers |
ImageBlurGaussian / ImageKernelConvolution | Filtering |
ImageFlipVertical / ImageFlipHorizontal / ImageRotate / ImageRotateCW / ImageRotateCCW | Geometric transforms |
ImageColorTint / ImageColorInvert / ImageColorGrayscale / ImageColorContrast / ImageColorBrightness / ImageColorReplace | Color filters |
LoadImageColors / LoadImagePalette / UnloadImageColors / UnloadImagePalette | Pixel access |
GetImageAlphaBorder(img, threshold) / GetImageColor(img, x, y) | Pixel queries |
ImageDraw… family | Software-rasterize shapes/lines/text directly into an Image |
Color Helpers
| Function | Description |
|---|
ColorIsEqual(a, b) → bool | Compare two colors (6.0) |
Fade(color, alpha) → Color | Adjust alpha |
ColorToInt(c) → c_int / GetColor(hex) → Color | RGBA ↔ packed int |
ColorNormalize / ColorFromNormalized | RGBA u8 ↔ Vector4 0..1 |
ColorToHSV / ColorFromHSV | RGB ↔ 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 / GetPixelDataSize | Pixel-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
| Function | RGB | Description |
|---|
rl_white() | 255, 255, 255 | White |
rl_black() | 0, 0, 0 | Black |
rl_red() | 230, 41, 55 | Red |
rl_green() | 0, 228, 48 | Green |
rl_blue() | 0, 121, 241 | Blue |
rl_yellow() | 253, 249, 0 | Yellow |
rl_orange() | 255, 161, 0 | Orange |
rl_pink() | 255, 109, 194 | Pink |
rl_purple() | 200, 122, 255 | Purple |
rl_skyblue() | 102, 191, 255 | Sky Blue |
rl_gray() | 130, 130, 130 | Gray |
rl_darkgray() | 80, 80, 80 | Dark Gray |
rl_lightgray() | 200, 200, 200 | Light Gray |
rl_raywhite() | 245, 245, 245 | Raylib White |
rl_blank() | 0, 0, 0, 0 | Transparent |
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)
| Function | Description |
|---|
DrawCube/V | Draw cube (size or Vector3) |
DrawCubeWires/V | Cube wireframe |
DrawSphere/Ex/Wires | Sphere (solid/custom/wireframe) |
DrawCylinder/Ex/Wires/WiresEx | Cylinder variants |
DrawCapsule/Wires | Capsule shape |
DrawPlane | Flat plane |
DrawLine3D | 3D line |
DrawPoint3D | 3D point |
DrawCircle3D | 3D circle |
DrawTriangle3D | 3D triangle |
DrawGrid | Reference grid |
DrawRay | Visualize a ray |
Model Loading & Drawing
| Function | Description |
|---|
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 / DrawModelWiresEx | Wireframe variants |
DrawModelPoints / DrawModelPointsEx | Point-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
| Function | Description |
|---|
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
| Function | Description |
|---|
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
| Function | Description |
|---|
CheckCollisionSpheres | Sphere vs sphere |
CheckCollisionBoxes | AABB vs AABB |
CheckCollisionBoxSphere | AABB vs sphere |
GetRayCollisionSphere/Box/Mesh/Triangle/Quad | Ray 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)
| Function | Description |
|---|
InitAudioDevice/CloseAudioDevice | Init/shutdown audio |
IsAudioDeviceReady | Check audio ready |
SetMasterVolume/GetMasterVolume | Master volume (0.0..1.0) |
LoadSound(fileName) | Load sound from file |
LoadSoundFromWave(wave) | Create sound from wave |
LoadSoundAlias(source) → Sound | Cheap 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/ResumeSound | Playback control |
IsSoundPlaying(sound) | Check if playing |
SetSoundVolume/Pitch/Pan | Sound properties |
Music (streaming)
var music = LoadMusicStream("background.ogg")
PlayMusicStream(music)
// In game loop:
UpdateMusicStream(music)
| Function | Description |
|---|
LoadMusicStream(fileName) | Load music for streaming |
UnloadMusicStream(music) | Free music |
PlayMusicStream/Stop/Pause/Resume | Playback control |
UpdateMusicStream(music) | Call every frame |
IsMusicStreamPlaying(music) | Check if playing |
SeekMusicStream(music, position) | Seek to position |
SetMusicVolume/Pitch/Pan | Music properties |
GetMusicTimeLength/TimePlayed | Duration and position |
Wave Processing
| Function | Description |
|---|
LoadWave(fileName) / LoadWaveFromMemory(type, data, size) | Load wave data |
IsWaveValid(wave) | Check wave validity |
WaveCopy/WaveCrop/WaveFormat | Process wave data |
LoadWaveSamples/UnloadWaveSamples | Access raw float samples |
ExportWave(wave, fileName) / ExportWaveAsCode(wave, fileName) | Save wave to file |
UnloadWave(wave) | Free wave |
Audio Streams (low-level, callback-driven)
| Function | Description |
|---|
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 / StopAudioStream | Playback control |
IsAudioStreamPlaying(s) | Check play state |
SetAudioStreamVolume / Pitch / Pan | Per-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")
| Flag | Description |
|---|
FLAG_VSYNC_HINT | Enable V-Sync |
FLAG_FULLSCREEN_MODE | Start fullscreen |
FLAG_WINDOW_RESIZABLE | Allow resizing |
FLAG_WINDOW_UNDECORATED | No window frame |
FLAG_WINDOW_TRANSPARENT | Transparent framebuffer |
FLAG_WINDOW_HIGHDPI | High-DPI support |
FLAG_MSAA_4X_HINT | 4x MSAA anti-aliasing |
FLAG_WINDOW_ALWAYS_RUN | Keep running when minimized |
- 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