@@ -51,6 +51,9 @@ pub fn build(b: *std.Build) void {
5151 exe.root_module.addImport("raylib", raylib_dep.module("raylib"));
5252 exe.root_module.linkLibrary(raylib_dep.artifact("raylib"));
5353
54+ // Optional: add raygui for GUI widgets
55+ exe.root_module.addImport("raygui", raylib_dep.module("raygui"));
56+
5457 b.installArtifact(exe);
5558
5659 const run_cmd = b.addRunArtifact(exe);
@@ -120,6 +123,52 @@ const shader = try rl.loadShader(null, "shaders/effect.fs");
120123defer rl.unloadShader(shader);
121124```
122125
126+ ## Critical: Common Mistakes (WRONG vs CORRECT)
127+
128+ ``` zig
129+ // WRONG: Importing raymath as a separate module
130+ const raymath = @import("raymath");
131+ // CORRECT: Access raymath through the raylib module
132+ const rl = @import("raylib");
133+ // then use: rl.math.clamp(), rl.math.lerp(), rl.math.matrixMultiply(), etc.
134+
135+ // WRONG: Importing rlgl as a separate module
136+ const rlgl = @import("rlgl");
137+ // CORRECT: Access rlgl through the raylib module
138+ const rlgl = rl.gl; // or use rl.gl.* directly
139+
140+ // WRONG: Calling play as a method on sound
141+ sound.play();
142+ // CORRECT: Use free function for sound playback
143+ rl.playSound(sound);
144+
145+ // WRONG: Calling crossProduct as a method on Vector2
146+ const cross = v1.crossProduct(v2);
147+ // CORRECT: Vector2 crossProduct is a FREE FUNCTION only
148+ const cross = rl.math.vector2CrossProduct(v1, v2);
149+ // NOTE: Vector3 DOES have crossProduct as a method: v1.crossProduct(v2)
150+
151+ // WRONG: Using try on functions that don't return error unions
152+ const s = try rl.loadSoundFromWave(wave);
153+ const a = try rl.loadSoundAlias(sound);
154+ const img = try rl.getClipboardImage();
155+ // CORRECT: These return their types directly (no error union)
156+ const s = rl.loadSoundFromWave(wave);
157+ const a = rl.loadSoundAlias(sound);
158+ const img = rl.getClipboardImage();
159+
160+ // WRONG: Expecting raygui button() to return i32
161+ const result: i32 = rg.button(bounds, "Click");
162+ // CORRECT: raygui button() returns bool
163+ if (rg.button(bounds, "Click")) { ... }
164+
165+ // WRONG: Passing const slice to raygui textBox
166+ rg.textBox(bounds, "text", 64, editMode);
167+ // CORRECT: textBox requires a mutable [:0]u8 slice
168+ var buf: [64:0]u8 = .{0} ** 64;
169+ _ = rg.textBox(bounds, &buf, 64, editMode);
170+ ```
171+
123172## Critical: Resource Management with Defer
124173
125174** Always pair load with unload using defer:**
@@ -405,66 +454,24 @@ if (rl.checkCollisionBoxSphere(box, sphereCenter, sphereRadius)) {
405454}
406455```
407456
408- ## Quick Reference: Named Colors
409-
410- | Color | Usage |
411- | -------| -------|
412- | ` .white ` | White (255, 255, 255) |
413- | ` .black ` | Black (0, 0, 0) |
414- | ` .ray_white ` | Off-white background (245, 245, 245) |
415- | ` .blank ` | Transparent (0, 0, 0, 0) |
416- | ` .red ` | Red |
417- | ` .green ` | Green |
418- | ` .blue ` | Blue |
419- | ` .yellow ` | Yellow |
420- | ` .orange ` | Orange |
421- | ` .pink ` | Pink |
422- | ` .purple ` | Purple |
423- | ` .gray ` | Gray |
424- | ` .dark_gray ` | Dark gray |
425- | ` .light_gray ` | Light gray |
426- | ` .gold ` | Gold |
427- | ` .lime ` | Lime green |
428- | ` .sky_blue ` | Sky blue |
429- | ` .maroon ` | Maroon |
430- | ` .violet ` | Violet |
431- | ` .beige ` | Beige |
432- | ` .brown ` | Brown |
433- | ` .dark_brown ` | Dark brown |
434- | ` .dark_green ` | Dark green |
435- | ` .dark_purple ` | Dark purple |
436- | ` .magenta ` | Magenta |
437-
438- ## Quick Reference: Key Codes
439-
440- | Key | Code | Key | Code |
441- | -----| ------| -----| ------|
442- | Space | ` .space ` | Escape | ` .escape ` |
443- | Enter | ` .enter ` | Tab | ` .tab ` |
444- | Backspace | ` .backspace ` | Delete | ` .delete ` |
445- | Arrow Right | ` .right ` | Arrow Left | ` .left ` |
446- | Arrow Up | ` .up ` | Arrow Down | ` .down ` |
447- | A-Z | ` .a ` to ` .z ` | 0-9 | ` .zero ` to ` .nine ` |
448- | F1-F12 | ` .f1 ` to ` .f12 ` | | |
449-
450- ## Quick Reference: Mouse Buttons
451-
452- | Button | Code |
453- | --------| ------|
454- | Left | ` .left ` |
455- | Right | ` .right ` |
456- | Middle | ` .middle ` |
457- | Side | ` .side ` |
458- | Extra | ` .extra ` |
459- | Forward | ` .forward ` |
460- | Back | ` .back ` |
457+ ## Quick Reference
458+
459+ ** Named Colors:** ` .white ` , ` .black ` , ` .ray_white ` , ` .blank ` , ` .red ` , ` .green ` , ` .blue ` , ` .yellow ` , ` .orange ` , ` .pink ` , ` .purple ` , ` .gray ` , ` .dark_gray ` , ` .light_gray ` , ` .gold ` , ` .lime ` , ` .sky_blue ` , ` .maroon ` , ` .violet ` , ` .beige ` , ` .brown ` , ` .dark_brown ` , ` .dark_green ` , ` .dark_purple ` , ` .magenta ` — or ` rl.Color.init(r, g, b, a) ` for custom.
460+
461+ ** Key Codes:** ` .a ` -` .z ` , ` .zero ` -` .nine ` , ` .f1 ` -` .f12 ` , ` .space ` , ` .enter ` , ` .escape ` , ` .tab ` , ` .backspace ` , ` .delete ` , ` .up ` /` .down ` /` .left ` /` .right ` , ` .left_shift ` , ` .left_control ` , ` .left_alt `
462+
463+ ** Mouse Buttons:** ` .left ` , ` .right ` , ` .middle ` , ` .side ` , ` .extra ` , ` .forward ` , ` .back `
461464
462465## Module Reference
463466
464467### Core
465468- ** [ Core API] ( references/api-core.md ) ** - Window, input, timing, Camera2D
466469- ** [ Drawing API] ( references/api-drawing.md ) ** - 2D shapes, textures, text, collision
467470- ** [ 3D API] ( references/api-3d.md ) ** - Camera3D, models, animation, shaders, PBR
471+ - ** [ Math & GL API] ( references/api-math-gl.md ) ** - raymath (` rl.math.* ` ), rlgl (` rl.gl.* ` )
472+
473+ ### GUI
474+ - ** [ Raygui API] ( references/api-raygui.md ) ** - GUI widgets, styling, dialogs
468475
469476### Resources
470477- ** [ Resources API] ( references/api-resources.md ) ** - Loading/unloading patterns
0 commit comments