├── .gitignore ├── LICENSE ├── README.md ├── build.bat ├── build.sh ├── lib └── libraylib.a ├── run_server.bat └── src ├── main.c ├── main.odin └── raylib └── raylib.odin /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | *.sublime-project 3 | *.sublime-workspace -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Experiment with using Raylib + Odin on web. 2 | 3 | # How does that work 4 | 5 | This method abuses emscripten compiler and its toolchain by using small C program, that calls Odin code: 6 | ```c 7 | #include 8 | 9 | extern void _main(); 10 | extern void step(); 11 | 12 | int main() { 13 | _main(); 14 | 15 | emscripten_set_main_loop(step, 0, 1); 16 | return 0; 17 | } 18 | ``` 19 | 20 | This way we can use Odin compiler to create object files that will be used by emcc. Check `build.bat` for calls and flags. 21 | 22 | ## The Issues 23 | 24 | The default bindings from Vendor libarary won't work, since they use `core:c` package, which doesn't compile when targeting wasm. Thankfully the only thing neede from that package were types, like `c.int`, which can be easily copied and pasted to binding file, removing need for that import. (with the exception of `va_list`, but that's just one function which maybe will not be needed) 25 | 26 | The second issue with bindings is that the Odin's Foreign System doesn't really mesh well with what I want to do here. From what I understand, when giving a name to a foreing lib, wasm expects it to be in a module of the same name. Since that's not what I do here, I had to remove lib name from foreign block. 27 | 28 | That also means that the same bindings can't be used for development on other platforms, probably. 29 | 30 | Another issue is using `freestanding_wasm32` target. It's not an issue per se, but it means that I can't use some part of the standard library, mainly `core:fmt`. Usin `js_wasm` would be possible if there was a way to insert "odin_env" from odin's runtime.js into generated index.js file, but as for now I don't know if there is a way to do that (help appreciated!). 31 | 32 | ## Other approach 33 | 34 | The ideal way would be to completely ditch Emscriptem and use only Odin compiler, but with how much Raylib depends on Emscripten I would have to reimplement OpenGL, GLFW and other dependencies the same way Emscripten does. While it might not be feasible to do with Raylib, other libraries with lower amount of dependencies could be used this way. 35 | 36 | The one issue with that is the Foreign System, for some reason, doesn't pass libraries paths to the linker when compiling to wasm. The easiest workaround I found (without modyfing the compiler) is to once again compile to object file and call wasm-ld manually. 37 | -------------------------------------------------------------------------------- /build.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set STACK_SIZE=1048576 4 | set HEAP_SIZE=67108864 5 | 6 | call emsdk activate latest 7 | 8 | if not exist build mkdir build 9 | pushd build 10 | 11 | 12 | call odin build ../src -target=freestanding_wasm32 -out:odin -build-mode:obj -debug -show-system-calls 13 | call emcc -o index.html ../src/main.c odin.wasm.o ../lib/libraylib.a -s USE_GLFW=3 -s GL_ENABLE_GET_PROC_ADDRESS -DWEB_BUILD -sSTACK_SIZE=%STACK_SIZE% -s TOTAL_MEMORY=%HEAP_SIZE% -sERROR_ON_UNDEFINED_SYMBOLS=0 14 | 15 | popd -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | STACK_SIZE=1048576 4 | HEAP_SIZE=67108864 5 | 6 | emsdk activate latest 7 | 8 | if [ ! -d "build" ]; then 9 | mkdir build 10 | fi 11 | 12 | pushd build 13 | 14 | odin build ../src -target=freestanding_wasm32 -out:odin -build-mode:obj -debug -show-system-calls 15 | emcc -o index.html ../src/main.c odin.wasm.o ../lib/libraylib.a -s USE_GLFW=3 -s GL_ENABLE_GET_PROC_ADDRESS -DWEB_BUILD -sSTACK_SIZE=$STACK_SIZE -s TOTAL_MEMORY=$HEAP_SIZE -sERROR_ON_UNDEFINED_SYMBOLS=0 16 | 17 | popd 18 | -------------------------------------------------------------------------------- /lib/libraylib.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Caedo/raylib_wasm_odin/d4078d7c50aac13ca907bbb8bc4da655516e3bee/lib/libraylib.a -------------------------------------------------------------------------------- /run_server.bat: -------------------------------------------------------------------------------- 1 | pushd build 2 | call python -m http.server 3 | popd -------------------------------------------------------------------------------- /src/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern void _main(); 4 | extern void step(); 5 | 6 | int main() { 7 | _main(); 8 | 9 | emscripten_set_main_loop(step, 0, 1); 10 | return 0; 11 | } -------------------------------------------------------------------------------- /src/main.odin: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "core:runtime" 4 | // import "core:fmt" 5 | import "core:mem" 6 | import "core:math/rand" 7 | // import rl "vendor:raylib" 8 | import rl "raylib" 9 | 10 | foreign import "odin_env" 11 | 12 | // @(default_calling_convention="c") 13 | // foreign odin_env { 14 | // @(link_name="wasm_testing") 15 | // wasm_testing :: proc() --- 16 | // } 17 | 18 | camera: rl.Camera3D 19 | 20 | ctx: runtime.Context 21 | 22 | tempAllocatorData: [mem.Megabyte * 4]byte 23 | tempAllocatorArena: mem.Arena 24 | 25 | mainMemoryData: [mem.Megabyte * 16]byte 26 | mainMemoryArena: mem.Arena 27 | 28 | timer: f32 29 | cubePos: [32]rl.Vector3 30 | cubeColors: [32]rl.Color 31 | 32 | @(export, link_name="_main") 33 | _main :: proc "c" () { 34 | ctx = runtime.default_context() 35 | context = ctx 36 | 37 | mem.arena_init(&mainMemoryArena, mainMemoryData[:]) 38 | mem.arena_init(&tempAllocatorArena, tempAllocatorData[:]) 39 | 40 | ctx.allocator = mem.arena_allocator(&mainMemoryArena) 41 | ctx.temp_allocator = mem.arena_allocator(&tempAllocatorArena) 42 | 43 | camera.position = {3, 3, 3} 44 | camera.target = {0,0,0} 45 | camera.up = {0, 1, 0} 46 | camera.fovy = 80 47 | camera.projection = .PERSPECTIVE 48 | 49 | rl.InitWindow(800, 600, "test") 50 | rl.SetTargetFPS(60) 51 | 52 | // wasm_testing() 53 | } 54 | 55 | @(export, link_name="step") 56 | step :: proc "contextless" () { 57 | context = ctx 58 | update() 59 | } 60 | 61 | update :: proc() { 62 | free_all(context.temp_allocator) 63 | 64 | timer -= rl.GetFrameTime() 65 | if timer <= 0 { 66 | timer = 1 67 | 68 | for c in &cubePos { 69 | c.x = rand.float32_range(-10, 10) 70 | c.y = rand.float32_range(-10, 10) 71 | c.z = rand.float32_range(-10, 10) 72 | } 73 | 74 | for &c in &cubeColors { 75 | c = rl.Color { 76 | u8(rand.uint32()), 77 | u8(rand.uint32()), 78 | u8(rand.uint32()), 79 | 255, 80 | } 81 | 82 | } 83 | } 84 | 85 | rl.BeginDrawing() 86 | defer rl.EndDrawing() 87 | 88 | rl.UpdateCamera(&camera, .ORBITAL) 89 | 90 | rl.ClearBackground(rl.RAYWHITE) 91 | rl.BeginMode3D(camera) 92 | { 93 | for i in 0..<32 { 94 | rl.DrawCube(cubePos[i], 1, 1, 1, cubeColors[i]) 95 | } 96 | rl.DrawGrid(10, 1) 97 | } 98 | rl.EndMode3D() 99 | } 100 | -------------------------------------------------------------------------------- /src/raylib/raylib.odin: -------------------------------------------------------------------------------- 1 | /* 2 | Package vendor:raylib implements bindings for version 5.0 of the raylib library (https://www.raylib.com/) 3 | 4 | ********************************************************************************************* 5 | * 6 | * raylib v5.0 - A simple and easy-to-use library to enjoy videogames programming (www.raylib.com) 7 | * 8 | * FEATURES: 9 | * - NO external dependencies, all required libraries included with raylib 10 | * - Multiplatform: Windows, Linux, FreeBSD, OpenBSD, NetBSD, DragonFly, 11 | * MacOS, Haiku, Android, Raspberry Pi, DRM native, HTML5. 12 | * - Written in plain C code (C99) in PascalCase/camelCase notation 13 | * - Hardware accelerated with OpenGL (1.1, 2.1, 3.3, 4.3 or ES2 - choose at compile) 14 | * - Unique OpenGL abstraction layer (usable as standalone module): [rlgl] 15 | * - Multiple Fonts formats supported (TTF, XNA fonts, AngelCode fonts) 16 | * - Outstanding texture formats support, including compressed formats (DXT, ETC, ASTC) 17 | * - Full 3d support for 3d Shapes, Models, Billboards, Heightmaps and more! 18 | * - Flexible Materials system, supporting classic maps and PBR maps 19 | * - Animated 3D models supported (skeletal bones animation) (IQM) 20 | * - Shaders support, including Model shaders and Postprocessing shaders 21 | * - Powerful math module for Vector, Matrix and Quaternion operations: [raymath] 22 | * - Audio loading and playing with streaming support (WAV, OGG, MP3, FLAC, XM, MOD) 23 | * - VR stereo rendering with configurable HMD device parameters 24 | * - Bindings to multiple programming languages available! 25 | * 26 | * NOTES: 27 | * - One default Font is loaded on InitWindow()->LoadFontDefault() [core, text] 28 | * - One default Texture2D is loaded on rlglInit(), 1x1 white pixel R8G8B8A8 [rlgl] (OpenGL 3.3 or ES2) 29 | * - One default Shader is loaded on rlglInit()->rlLoadShaderDefault() [rlgl] (OpenGL 3.3 or ES2) 30 | * - One default RenderBatch is loaded on rlglInit()->rlLoadRenderBatch() [rlgl] (OpenGL 3.3 or ES2) 31 | * 32 | * DEPENDENCIES (included): 33 | * [rcore] rglfw (Camilla Löwy - github.com/glfw/glfw) for window/context management and input (PLATFORM_DESKTOP) 34 | * [rlgl] glad (David Herberth - github.com/Dav1dde/glad) for OpenGL 3.3 extensions loading (PLATFORM_DESKTOP) 35 | * [raudio] miniaudio (David Reid - github.com/mackron/miniaudio) for audio device/context management 36 | * 37 | * OPTIONAL DEPENDENCIES (included): 38 | * [rcore] msf_gif (Miles Fogle) for GIF recording 39 | * [rcore] sinfl (Micha Mettke) for DEFLATE decompression algorithm 40 | * [rcore] sdefl (Micha Mettke) for DEFLATE compression algorithm 41 | * [rtextures] stb_image (Sean Barret) for images loading (BMP, TGA, PNG, JPEG, HDR...) 42 | * [rtextures] stb_image_write (Sean Barret) for image writing (BMP, TGA, PNG, JPG) 43 | * [rtextures] stb_image_resize (Sean Barret) for image resizing algorithms 44 | * [rtext] stb_truetype (Sean Barret) for ttf fonts loading 45 | * [rtext] stb_rect_pack (Sean Barret) for rectangles packing 46 | * [rmodels] par_shapes (Philip Rideout) for parametric 3d shapes generation 47 | * [rmodels] tinyobj_loader_c (Syoyo Fujita) for models loading (OBJ, MTL) 48 | * [rmodels] cgltf (Johannes Kuhlmann) for models loading (glTF) 49 | * [rmodels] Model3D (bzt) for models loading (M3D, https://bztsrc.gitlab.io/model3d) 50 | * [raudio] dr_wav (David Reid) for WAV audio file loading 51 | * [raudio] dr_flac (David Reid) for FLAC audio file loading 52 | * [raudio] dr_mp3 (David Reid) for MP3 audio file loading 53 | * [raudio] stb_vorbis (Sean Barret) for OGG audio loading 54 | * [raudio] jar_xm (Joshua Reisenauer) for XM audio module loading 55 | * [raudio] jar_mod (Joshua Reisenauer) for MOD audio module loading 56 | * 57 | * 58 | * LICENSE: zlib/libpng 59 | * 60 | * raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified, 61 | * BSD-like license that allows static linking with closed source software: 62 | * 63 | * Copyright (c) 2013-2023 Ramon Santamaria (@raysan5) 64 | * 65 | * This software is provided "as-is", without any express or implied warranty. In no event 66 | * will the authors be held liable for any damages arising from the use of this software. 67 | * 68 | * Permission is granted to anyone to use this software for any purpose, including commercial 69 | * applications, and to alter it and redistribute it freely, subject to the following restrictions: 70 | * 71 | * 1. The origin of this software must not be misrepresented; you must not claim that you 72 | * wrote the original software. If you use this software in a product, an acknowledgment 73 | * in the product documentation would be appreciated but is not required. 74 | * 75 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented 76 | * as being the original software. 77 | * 78 | * 3. This notice may not be removed or altered from any source distribution. 79 | * 80 | ********************************************************************************************* 81 | */ 82 | package raylib 83 | 84 | import "core:fmt" 85 | import "core:mem" 86 | import "core:strings" 87 | import builtin "core:builtin" 88 | 89 | cint :: builtin.i32 90 | cuint :: builtin.u32 91 | clong :: builtin.u32 when (ODIN_OS == .Windows || size_of(builtin.rawptr) == 4) else builtin.u64 92 | 93 | USE_LINALG :: #config(RAYLIB_USE_LINALG, true) 94 | import "core:math/linalg" 95 | _ :: linalg 96 | 97 | MAX_TEXTFORMAT_BUFFERS :: #config(RAYLIB_MAX_TEXTFORMAT_BUFFERS, 4) 98 | MAX_TEXT_BUFFER_LENGTH :: #config(RAYLIB_MAX_TEXT_BUFFER_LENGTH, 1024) 99 | 100 | #assert(size_of(rune) == size_of(cint)) 101 | 102 | RAYLIB_SHARED :: #config(RAYLIB_SHARED, false) 103 | 104 | when ODIN_OS == .Windows { 105 | when RAYLIB_SHARED { 106 | @(extra_linker_flags="/NODEFAULTLIB:msvcrt") 107 | foreign import lib { 108 | "windows/raylibdll.lib", 109 | "system:Winmm.lib", 110 | "system:Gdi32.lib", 111 | "system:User32.lib", 112 | "system:Shell32.lib", 113 | } 114 | } else { 115 | @(extra_linker_flags="/NODEFAULTLIB:libcmt") 116 | foreign import lib { 117 | "windows/raylib.lib", 118 | "system:Winmm.lib", 119 | "system:Gdi32.lib", 120 | "system:User32.lib", 121 | "system:Shell32.lib", 122 | } 123 | } 124 | } else when ODIN_OS == .Linux { 125 | when RAYLIB_SHARED { 126 | foreign import lib { 127 | // Note(bumbread): I'm not sure why in `linux/` folder there are 128 | // multiple copies of raylib.so, but since these bindings are for 129 | // particular version of the library, I better specify it. Ideally, 130 | // though, it's best specified in terms of major (.so.4) 131 | "linux/libraylib.so.500", 132 | "system:dl", 133 | "system:pthread", 134 | } 135 | } else { 136 | foreign import lib { 137 | "linux/libraylib.a", 138 | "system:dl", 139 | "system:pthread", 140 | } 141 | } 142 | } else when ODIN_OS == .Darwin { 143 | when ODIN_ARCH == .arm64 { 144 | when RAYLIB_SHARED { 145 | foreign import lib { 146 | "macos-arm64/libraylib.500.dylib", 147 | "system:Cocoa.framework", 148 | "system:OpenGL.framework", 149 | "system:IOKit.framework", 150 | } 151 | } else { 152 | foreign import lib { 153 | "macos-arm64/libraylib.a", 154 | "system:Cocoa.framework", 155 | "system:OpenGL.framework", 156 | "system:IOKit.framework", 157 | } 158 | } 159 | } else { 160 | when RAYLIB_SHARED { 161 | foreign import lib { 162 | "macos/libraylib.500.dylib", 163 | "system:Cocoa.framework", 164 | "system:OpenGL.framework", 165 | "system:IOKit.framework", 166 | } 167 | } else { 168 | foreign import lib { 169 | "macos/libraylib.a", 170 | "system:Cocoa.framework", 171 | "system:OpenGL.framework", 172 | "system:IOKit.framework", 173 | } 174 | } 175 | } 176 | } else { 177 | // foreign import lib "system:raylib" 178 | } 179 | 180 | VERSION_MAJOR :: 5 181 | VERSION_MINOR :: 0 182 | VERSION_PATCH :: 0 183 | VERSION :: "5.0" 184 | 185 | PI :: 3.14159265358979323846 186 | DEG2RAD :: PI/180.0 187 | RAD2DEG :: 180.0/PI 188 | 189 | 190 | // Some Basic Colors 191 | // NOTE: Custom raylib color palette for amazing visuals on WHITE background 192 | LIGHTGRAY :: Color{ 200, 200, 200, 255 } // Light Gray 193 | GRAY :: Color{ 130, 130, 130, 255 } // Gray 194 | DARKGRAY :: Color{ 80, 80, 80, 255 } // Dark Gray 195 | YELLOW :: Color{ 253, 249, 0, 255 } // Yellow 196 | GOLD :: Color{ 255, 203, 0, 255 } // Gold 197 | ORANGE :: Color{ 255, 161, 0, 255 } // Orange 198 | PINK :: Color{ 255, 109, 194, 255 } // Pink 199 | RED :: Color{ 230, 41, 55, 255 } // Red 200 | MAROON :: Color{ 190, 33, 55, 255 } // Maroon 201 | GREEN :: Color{ 0, 228, 48, 255 } // Green 202 | LIME :: Color{ 0, 158, 47, 255 } // Lime 203 | DARKGREEN :: Color{ 0, 117, 44, 255 } // Dark Green 204 | SKYBLUE :: Color{ 102, 191, 255, 255 } // Sky Blue 205 | BLUE :: Color{ 0, 121, 241, 255 } // Blue 206 | DARKBLUE :: Color{ 0, 82, 172, 255 } // Dark Blue 207 | PURPLE :: Color{ 200, 122, 255, 255 } // Purple 208 | VIOLET :: Color{ 135, 60, 190, 255 } // Violet 209 | DARKPURPLE :: Color{ 112, 31, 126, 255 } // Dark Purple 210 | BEIGE :: Color{ 211, 176, 131, 255 } // Beige 211 | BROWN :: Color{ 127, 106, 79, 255 } // Brown 212 | DARKBROWN :: Color{ 76, 63, 47, 255 } // Dark Brown 213 | 214 | WHITE :: Color{ 255, 255, 255, 255 } // White 215 | BLACK :: Color{ 0, 0, 0, 255 } // Black 216 | BLANK :: Color{ 0, 0, 0, 0 } // Blank (Transparent) 217 | MAGENTA :: Color{ 255, 0, 255, 255 } // Magenta 218 | RAYWHITE :: Color{ 245, 245, 245, 255 } // My own White (raylib logo) 219 | 220 | 221 | when USE_LINALG { 222 | // Vector2 type 223 | Vector2 :: linalg.Vector2f32 224 | // Vector3 type 225 | Vector3 :: linalg.Vector3f32 226 | // Vector4 type 227 | Vector4 :: linalg.Vector4f32 228 | 229 | // Quaternion type 230 | Quaternion :: linalg.Quaternionf32 231 | 232 | // Matrix type (OpenGL style 4x4 - right handed, column major) 233 | Matrix :: linalg.Matrix4x4f32 234 | } else { 235 | // Vector2 type 236 | Vector2 :: distinct [2]f32 237 | // Vector3 type 238 | Vector3 :: distinct [3]f32 239 | // Vector4 type 240 | Vector4 :: distinct [4]f32 241 | 242 | // Quaternion type 243 | Quaternion :: distinct quaternion128 244 | 245 | // Matrix, 4x4 components, column major, OpenGL style, right handed 246 | Matrix :: struct { 247 | m0, m4, m8, m12: f32, // Matrix first row (4 components) 248 | m1, m5, m9, m13: f32, // Matrix second row (4 components) 249 | m2, m6, m10, m14: f32, // Matrix third row (4 components) 250 | m3, m7, m11, m15: f32, // Matrix fourth row (4 components) 251 | } 252 | } 253 | 254 | // Color, 4 components, R8G8B8A8 (32bit) 255 | // 256 | // Note: In Raylib this is a struct. But here we use a fixed array, so that .rgba swizzling etc work. 257 | Color :: distinct [4]u8 258 | 259 | // Rectangle type 260 | Rectangle :: struct { 261 | x: f32, // Rectangle top-left corner position x 262 | y: f32, // Rectangle top-left corner position y 263 | width: f32, // Rectangle width 264 | height: f32, // Rectangle height 265 | } 266 | 267 | // Image type, bpp always RGBA (32bit) 268 | // NOTE: Data stored in CPU memory (RAM) 269 | Image :: struct { 270 | data: rawptr, // Image raw data 271 | width: cint, // Image base width 272 | height: cint, // Image base height 273 | mipmaps: cint, // Mipmap levels, 1 by default 274 | format: PixelFormat, // Data format (PixelFormat type) 275 | } 276 | 277 | // Texture type 278 | // NOTE: Data stored in GPU memory 279 | Texture :: struct { 280 | id: cuint, // OpenGL texture id 281 | width: cint, // Texture base width 282 | height: cint, // Texture base height 283 | mipmaps: cint, // Mipmap levels, 1 by default 284 | format: PixelFormat, // Data format (PixelFormat type) 285 | } 286 | 287 | // Texture2D type, same as Texture 288 | Texture2D :: Texture 289 | 290 | // TextureCubemap type, actually, same as Texture 291 | TextureCubemap :: Texture 292 | 293 | // RenderTexture type, for texture rendering 294 | RenderTexture :: struct { 295 | id: cuint, // OpenGL framebuffer object id 296 | texture: Texture, // Color buffer attachment texture 297 | depth: Texture, // Depth buffer attachment texture 298 | } 299 | 300 | // RenderTexture2D type, same as RenderTexture 301 | RenderTexture2D :: RenderTexture 302 | 303 | // N-Patch layout info 304 | NPatchInfo :: struct { 305 | source: Rectangle, // Texture source rectangle 306 | left: cint, // Left border offset 307 | top: cint, // Top border offset 308 | right: cint, // Right border offset 309 | bottom: cint, // Bottom border offset 310 | layout: NPatchLayout, // Layout of the n-patch: 3x3, 1x3 or 3x1 311 | } 312 | 313 | // Font character info 314 | GlyphInfo :: struct { 315 | value: rune, // Character value (Unicode) 316 | offsetX: cint, // Character offset X when drawing 317 | offsetY: cint, // Character offset Y when drawing 318 | advanceX: cint, // Character advance position X 319 | image: Image, // Character image data 320 | } 321 | 322 | // Font type, includes texture and charSet array data 323 | Font :: struct { 324 | baseSize: cint, // Base size (default chars height) 325 | charsCount: cint, // Number of characters 326 | charsPadding: cint, // Padding around the chars 327 | texture: Texture2D, // Characters texture atlas 328 | recs: [^]Rectangle, // Characters rectangles in texture 329 | chars: [^]GlyphInfo, // Characters info data 330 | } 331 | 332 | // Camera type, defines a camera position/orientation in 3d space 333 | Camera3D :: struct { 334 | position: Vector3, // Camera position 335 | target: Vector3, // Camera target it looks-at 336 | up: Vector3, // Camera up vector (rotation over its axis) 337 | fovy: f32, // Camera field-of-view apperture in Y (degrees) in perspective, used as near plane width in orthographic 338 | projection: CameraProjection, // Camera projection: CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC 339 | } 340 | 341 | Camera :: Camera3D // Camera type fallback, defaults to Camera3D 342 | 343 | // Camera2D type, defines a 2d camera 344 | Camera2D :: struct { 345 | offset: Vector2, // Camera offset (displacement from target) 346 | target: Vector2, // Camera target (rotation and zoom origin) 347 | rotation: f32, // Camera rotation in degrees 348 | zoom: f32, // Camera zoom (scaling), should be 1.0f by default 349 | } 350 | 351 | // Vertex data definning a mesh 352 | // NOTE: Data stored in CPU memory (and GPU) 353 | Mesh :: struct { 354 | vertexCount: cint, // Number of vertices stored in arrays 355 | triangleCount: cint, // Number of triangles stored (indexed or not) 356 | 357 | // Default vertex data 358 | vertices: [^]f32, // Vertex position (XYZ - 3 components per vertex) (shader-location = 0) 359 | texcoords: [^]f32, // Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1) 360 | texcoords2: [^]f32, // Vertex second texture coordinates (useful for lightmaps) (shader-location = 5) 361 | normals: [^]f32, // Vertex normals (XYZ - 3 components per vertex) (shader-location = 2) 362 | tangents: [^]f32, // Vertex tangents (XYZW - 4 components per vertex) (shader-location = 4) 363 | colors: [^]u8, // Vertex colors (RGBA - 4 components per vertex) (shader-location = 3) 364 | indices: [^]u16, // Vertex indices (in case vertex data comes indexed) 365 | 366 | // Animation vertex data 367 | animVertices: [^]f32, // Animated vertex positions (after bones transformations) 368 | animNormals: [^]f32, // Animated normals (after bones transformations) 369 | boneIds: [^]u8, // Vertex bone ids, up to 4 bones influence by vertex (skinning) 370 | boneWeights: [^]f32, // Vertex bone weight, up to 4 bones influence by vertex (skinning) 371 | 372 | // OpenGL identifiers 373 | vaoId: u32, // OpenGL Vertex Array Object id 374 | vboId: [^]u32, // OpenGL Vertex Buffer Objects id (default vertex data) 375 | } 376 | 377 | // Shader type (generic) 378 | Shader :: struct { 379 | id: cuint, // Shader program id 380 | locs: [^]cint, // Shader locations array (MAX_SHADER_LOCATIONS) 381 | } 382 | 383 | // Material texture map 384 | MaterialMap :: struct { 385 | texture: Texture2D, // Material map texture 386 | color: Color, // Material map color 387 | value: f32, // Material map value 388 | } 389 | 390 | // Material type (generic) 391 | Material :: struct { 392 | shader: Shader, // Material shader 393 | maps: [^]MaterialMap, // Material maps array (MAX_MATERIAL_MAPS) 394 | params: [4]f32, // Material generic parameters (if required) 395 | } 396 | 397 | // Transformation properties 398 | Transform :: struct { 399 | translation: Vector3, // Translation 400 | rotation: Quaternion, // Rotation 401 | scale: Vector3, // Scale 402 | } 403 | 404 | // Bone information 405 | BoneInfo :: struct { 406 | name: [32]byte `fmt:"s,0"`, // Bone name 407 | parent: cint, // Bone parent 408 | } 409 | 410 | // Model type 411 | Model :: struct { 412 | transform: Matrix, // Local transform matrix 413 | 414 | meshCount: cint, // Number of meshes 415 | materialCount: cint, // Number of materials 416 | meshes: [^]Mesh, // Meshes array 417 | materials: [^]Material, // Materials array 418 | meshMaterial: [^]cint, // Mesh material number 419 | 420 | // Animation data 421 | boneCount: cint, // Number of bones 422 | bones: [^]BoneInfo, // Bones information (skeleton) 423 | bindPose: [^]Transform, // Bones base transformation (pose) 424 | } 425 | 426 | // Model animation 427 | ModelAnimation :: struct { 428 | boneCount: cint, // Number of bones 429 | frameCount: cint, // Number of animation frames 430 | bones: [^]BoneInfo, // Bones information (skeleton) 431 | framePoses: [^][^]Transform, // Poses array by frame 432 | } 433 | 434 | // Ray type (useful for raycast) 435 | Ray :: struct { 436 | position: Vector3, // Ray position (origin) 437 | direction: Vector3, // Ray direction 438 | } 439 | 440 | // RayCollision, ray hit information 441 | RayCollision :: struct { 442 | hit: bool, // Did the ray hit something? 443 | distance: f32, // Distance to nearest hit 444 | point: Vector3, // Point of nearest hit 445 | normal: Vector3, // Surface normal of hit 446 | } 447 | 448 | // Bounding box type 449 | BoundingBox :: struct { 450 | min: Vector3, // Minimum vertex box-corner 451 | max: Vector3, // Maximum vertex box-corner 452 | } 453 | 454 | // Wave type, defines audio wave data 455 | Wave :: struct { 456 | frameCount: cuint, // Total number of frames (considering channels) 457 | sampleRate: cuint, // Frequency (samples per second) 458 | sampleSize: cuint, // Bit depth (bits per sample): 8, 16, 32 (24 not supported) 459 | channels: cuint, // Number of channels (1-mono, 2-stereo) 460 | data: rawptr, // Buffer data pointer 461 | } 462 | 463 | // Audio stream type 464 | // NOTE: Actual structs are defined internally in raudio module 465 | AudioStream :: struct { 466 | buffer: rawptr, // Pointer to internal data used by the audio system 467 | processor: rawptr, // Pointer to internal data processor, useful for audio effects 468 | 469 | sampleRate: cuint, // Frequency (samples per second) 470 | sampleSize: cuint, // Bit depth (bits per sample): 8, 16, 32 (24 not supported) 471 | channels: cuint, // Number of channels (1-mono, 2-stereo) 472 | } 473 | 474 | // Sound source type 475 | Sound :: struct { 476 | using stream: AudioStream, // Audio stream 477 | frameCount: cuint, // Total number of frames (considering channels) 478 | } 479 | 480 | // Music stream type (audio file streaming from memory) 481 | // NOTE: Anything longer than ~10 seconds should be streamed 482 | Music :: struct { 483 | using stream: AudioStream, // Audio stream 484 | frameCount: cuint, // Total number of frames (considering channels) 485 | looping: bool, // Music looping enable 486 | 487 | ctxType: cint, // Type of music context (audio filetype) 488 | ctxData: rawptr, // Audio context data, depends on type 489 | } 490 | 491 | // Head-Mounted-Display device parameters 492 | VrDeviceInfo :: struct { 493 | hResolution: cint, // Horizontal resolution in pixels 494 | vResolution: cint, // Vertical resolution in pixels 495 | hScreenSize: f32, // Horizontal size in meters 496 | vScreenSize: f32, // Vertical size in meters 497 | vScreenCenter: f32, // Screen center in meters 498 | eyeToScreenDistance: f32, // Distance between eye and display in meters 499 | lensSeparationDistance: f32, // Lens separation distance in meters 500 | interpupillaryDistance: f32, // IPD (distance between pupils) in meters 501 | lensDistortionValues: [4]f32, // Lens distortion constant parameters 502 | chromaAbCorrection: [4]f32, // Chromatic aberration correction parameters 503 | } 504 | 505 | // VR Stereo rendering configuration for simulator 506 | VrStereoConfig :: struct { 507 | projection: [2]Matrix, // VR projection matrices (per eye) 508 | viewOffset: [2]Matrix, // VR view offset matrices (per eye) 509 | leftLensCenter: [2]f32, // VR left lens center 510 | rightLensCenter: [2]f32, // VR right lens center 511 | leftScreenCenter: [2]f32, // VR left screen center 512 | rightScreenCenter: [2]f32, // VR right screen center 513 | scale: [2]f32, // VR distortion scale 514 | scaleIn: [2]f32, // VR distortion scale in 515 | } 516 | 517 | // File path list 518 | FilePathList :: struct { 519 | capacity: cuint, // Filepaths max entries 520 | count: cuint, // Filepaths entries count 521 | paths: [^]cstring, // Filepaths entries 522 | } 523 | 524 | // Automation event 525 | AutomationEvent :: struct { 526 | frame: cuint, // Event frame 527 | type: cuint, // Event type (AutomationEventType) 528 | params: [4]cint, // Event parameters (if required) --- 529 | } 530 | 531 | // Automation event list 532 | AutomationEventList :: struct { 533 | capacity: cuint, // Events max entries (MAX_AUTOMATION_EVENTS) 534 | count: cuint, // Events entries count 535 | events: [^]AutomationEvent, // Events entries 536 | } 537 | 538 | //---------------------------------------------------------------------------------- 539 | // Enumerators Definition 540 | //---------------------------------------------------------------------------------- 541 | // System/Window config flags 542 | // NOTE: Every bit registers one state (use it with bit masks) 543 | // By default all flags are set to 0 544 | ConfigFlag :: enum cint { 545 | VSYNC_HINT = 6, // Set to try enabling V-Sync on GPU 546 | FULLSCREEN_MODE = 1, // Set to run program in fullscreen 547 | WINDOW_RESIZABLE = 2, // Set to allow resizable window 548 | WINDOW_UNDECORATED = 3, // Set to disable window decoration (frame and buttons) 549 | WINDOW_HIDDEN = 7, // Set to hide window 550 | WINDOW_MINIMIZED = 9, // Set to minimize window (iconify) 551 | WINDOW_MAXIMIZED = 10, // Set to maximize window (expanded to monitor) 552 | WINDOW_UNFOCUSED = 11, // Set to window non focused 553 | WINDOW_TOPMOST = 12, // Set to window always on top 554 | WINDOW_ALWAYS_RUN = 8, // Set to allow windows running while minimized 555 | WINDOW_TRANSPARENT = 4, // Set to allow transparent framebuffer 556 | WINDOW_HIGHDPI = 13, // Set to support HighDPI 557 | WINDOW_MOUSE_PASSTHROUGH = 14, // Set to support mouse passthrough, only supported when FLAG_WINDOW_UNDECORATED 558 | BORDERLESS_WINDOWED_MODE = 15, // Set to run program in borderless windowed mode 559 | MSAA_4X_HINT = 5, // Set to try enabling MSAA 4X 560 | INTERLACED_HINT = 16, // Set to try enabling interlaced video format (for V3D) 561 | } 562 | ConfigFlags :: distinct bit_set[ConfigFlag; cint] 563 | 564 | 565 | // Trace log level 566 | TraceLogLevel :: enum cint { 567 | ALL = 0, // Display all logs 568 | TRACE, // Trace logging, intended for internal use only 569 | DEBUG, // Debug logging, used for internal debugging, it should be disabled on release builds 570 | INFO, // Info logging, used for program execution info 571 | WARNING, // Warning logging, used on recoverable failures 572 | ERROR, // Error logging, used on unrecoverable failures 573 | FATAL, // Fatal logging, used to abort program: exit(EXIT_FAILURE) 574 | NONE, // Disable logging 575 | } 576 | 577 | // Keyboard keys (US keyboard layout) 578 | // NOTE: Use GetKeyPressed() to allow redefining 579 | // required keys for alternative layouts 580 | KeyboardKey :: enum cint { 581 | KEY_NULL = 0, // Key: NULL, used for no key pressed 582 | // Alphanumeric keys 583 | APOSTROPHE = 39, // Key: ' 584 | COMMA = 44, // Key: , 585 | MINUS = 45, // Key: - 586 | PERIOD = 46, // Key: . 587 | SLASH = 47, // Key: / 588 | ZERO = 48, // Key: 0 589 | ONE = 49, // Key: 1 590 | TWO = 50, // Key: 2 591 | THREE = 51, // Key: 3 592 | FOUR = 52, // Key: 4 593 | FIVE = 53, // Key: 5 594 | SIX = 54, // Key: 6 595 | SEVEN = 55, // Key: 7 596 | EIGHT = 56, // Key: 8 597 | NINE = 57, // Key: 9 598 | SEMICOLON = 59, // Key: ; 599 | EQUAL = 61, // Key: = 600 | A = 65, // Key: A | a 601 | B = 66, // Key: B | b 602 | C = 67, // Key: C | c 603 | D = 68, // Key: D | d 604 | E = 69, // Key: E | e 605 | F = 70, // Key: F | f 606 | G = 71, // Key: G | g 607 | H = 72, // Key: H | h 608 | I = 73, // Key: I | i 609 | J = 74, // Key: J | j 610 | K = 75, // Key: K | k 611 | L = 76, // Key: L | l 612 | M = 77, // Key: M | m 613 | N = 78, // Key: N | n 614 | O = 79, // Key: O | o 615 | P = 80, // Key: P | p 616 | Q = 81, // Key: Q | q 617 | R = 82, // Key: R | r 618 | S = 83, // Key: S | s 619 | T = 84, // Key: T | t 620 | U = 85, // Key: U | u 621 | V = 86, // Key: V | v 622 | W = 87, // Key: W | w 623 | X = 88, // Key: X | x 624 | Y = 89, // Key: Y | y 625 | Z = 90, // Key: Z | z 626 | LEFT_BRACKET = 91, // Key: [ 627 | BACKSLASH = 92, // Key: '\' 628 | RIGHT_BRACKET = 93, // Key: ] 629 | GRAVE = 96, // Key: ` 630 | // Function keys 631 | SPACE = 32, // Key: Space 632 | ESCAPE = 256, // Key: Esc 633 | ENTER = 257, // Key: Enter 634 | TAB = 258, // Key: Tab 635 | BACKSPACE = 259, // Key: Backspace 636 | INSERT = 260, // Key: Ins 637 | DELETE = 261, // Key: Del 638 | RIGHT = 262, // Key: Cursor right 639 | LEFT = 263, // Key: Cursor left 640 | DOWN = 264, // Key: Cursor down 641 | UP = 265, // Key: Cursor up 642 | PAGE_UP = 266, // Key: Page up 643 | PAGE_DOWN = 267, // Key: Page down 644 | HOME = 268, // Key: Home 645 | END = 269, // Key: End 646 | CAPS_LOCK = 280, // Key: Caps lock 647 | SCROLL_LOCK = 281, // Key: Scroll down 648 | NUM_LOCK = 282, // Key: Num lock 649 | PRINT_SCREEN = 283, // Key: Print screen 650 | PAUSE = 284, // Key: Pause 651 | F1 = 290, // Key: F1 652 | F2 = 291, // Key: F2 653 | F3 = 292, // Key: F3 654 | F4 = 293, // Key: F4 655 | F5 = 294, // Key: F5 656 | F6 = 295, // Key: F6 657 | F7 = 296, // Key: F7 658 | F8 = 297, // Key: F8 659 | F9 = 298, // Key: F9 660 | F10 = 299, // Key: F10 661 | F11 = 300, // Key: F11 662 | F12 = 301, // Key: F12 663 | LEFT_SHIFT = 340, // Key: Shift left 664 | LEFT_CONTROL = 341, // Key: Control left 665 | LEFT_ALT = 342, // Key: Alt left 666 | LEFT_SUPER = 343, // Key: Super left 667 | RIGHT_SHIFT = 344, // Key: Shift right 668 | RIGHT_CONTROL = 345, // Key: Control right 669 | RIGHT_ALT = 346, // Key: Alt right 670 | RIGHT_SUPER = 347, // Key: Super right 671 | KB_MENU = 348, // Key: KB menu 672 | // Keypad keys 673 | KP_0 = 320, // Key: Keypad 0 674 | KP_1 = 321, // Key: Keypad 1 675 | KP_2 = 322, // Key: Keypad 2 676 | KP_3 = 323, // Key: Keypad 3 677 | KP_4 = 324, // Key: Keypad 4 678 | KP_5 = 325, // Key: Keypad 5 679 | KP_6 = 326, // Key: Keypad 6 680 | KP_7 = 327, // Key: Keypad 7 681 | KP_8 = 328, // Key: Keypad 8 682 | KP_9 = 329, // Key: Keypad 9 683 | KP_DECIMAL = 330, // Key: Keypad . 684 | KP_DIVIDE = 331, // Key: Keypad / 685 | KP_MULTIPLY = 332, // Key: Keypad * 686 | KP_SUBTRACT = 333, // Key: Keypad - 687 | KP_ADD = 334, // Key: Keypad + 688 | KP_ENTER = 335, // Key: Keypad Enter 689 | KP_EQUAL = 336, // Key: Keypad = 690 | // Android key buttons 691 | BACK = 4, // Key: Android back button 692 | MENU = 82, // Key: Android menu button 693 | VOLUME_UP = 24, // Key: Android volume up button 694 | VOLUME_DOWN = 25, // Key: Android volume down button 695 | } 696 | 697 | // Mouse buttons 698 | MouseButton :: enum cint { 699 | LEFT = 0, // Mouse button left 700 | RIGHT = 1, // Mouse button right 701 | MIDDLE = 2, // Mouse button middle (pressed wheel) 702 | SIDE = 3, // Mouse button side (advanced mouse device) 703 | EXTRA = 4, // Mouse button extra (advanced mouse device) 704 | FORWARD = 5, // Mouse button fordward (advanced mouse device) 705 | BACK = 6, // Mouse button back (advanced mouse device) 706 | } 707 | 708 | // Mouse cursor 709 | MouseCursor :: enum cint { 710 | DEFAULT = 0, // Default pointer shape 711 | ARROW = 1, // Arrow shape 712 | IBEAM = 2, // Text writing cursor shape 713 | CROSSHAIR = 3, // Cross shape 714 | POINTING_HAND = 4, // Pointing hand cursor 715 | RESIZE_EW = 5, // Horizontal resize/move arrow shape 716 | RESIZE_NS = 6, // Vertical resize/move arrow shape 717 | RESIZE_NWSE = 7, // Top-left to bottom-right diagonal resize/move arrow shape 718 | RESIZE_NESW = 8, // The top-right to bottom-left diagonal resize/move arrow shape 719 | RESIZE_ALL = 9, // The omnidirectional resize/move cursor shape 720 | NOT_ALLOWED = 10, // The operation-not-allowed shape 721 | } 722 | 723 | // Gamepad buttons 724 | GamepadButton :: enum cint { 725 | UNKNOWN = 0, // Unknown button, just for error checking 726 | LEFT_FACE_UP, // Gamepad left DPAD up button 727 | LEFT_FACE_RIGHT, // Gamepad left DPAD right button 728 | LEFT_FACE_DOWN, // Gamepad left DPAD down button 729 | LEFT_FACE_LEFT, // Gamepad left DPAD left button 730 | RIGHT_FACE_UP, // Gamepad right button up (i.e. PS3: Triangle, Xbox: Y) 731 | RIGHT_FACE_RIGHT, // Gamepad right button right (i.e. PS3: Square, Xbox: X) 732 | RIGHT_FACE_DOWN, // Gamepad right button down (i.e. PS3: Cross, Xbox: A) 733 | RIGHT_FACE_LEFT, // Gamepad right button left (i.e. PS3: Circle, Xbox: B) 734 | LEFT_TRIGGER_1, // Gamepad top/back trigger left (first), it could be a trailing button 735 | LEFT_TRIGGER_2, // Gamepad top/back trigger left (second), it could be a trailing button 736 | RIGHT_TRIGGER_1, // Gamepad top/back trigger right (one), it could be a trailing button 737 | RIGHT_TRIGGER_2, // Gamepad top/back trigger right (second), it could be a trailing button 738 | MIDDLE_LEFT, // Gamepad center buttons, left one (i.e. PS3: Select) 739 | MIDDLE, // Gamepad center buttons, middle one (i.e. PS3: PS, Xbox: XBOX) 740 | MIDDLE_RIGHT, // Gamepad center buttons, right one (i.e. PS3: Start) 741 | LEFT_THUMB, // Gamepad joystick pressed button left 742 | RIGHT_THUMB, // Gamepad joystick pressed button right 743 | } 744 | 745 | // Gamepad axis 746 | GamepadAxis :: enum cint { 747 | LEFT_X = 0, // Gamepad left stick X axis 748 | LEFT_Y = 1, // Gamepad left stick Y axis 749 | RIGHT_X = 2, // Gamepad right stick X axis 750 | RIGHT_Y = 3, // Gamepad right stick Y axis 751 | LEFT_TRIGGER = 4, // Gamepad back trigger left, pressure level: [1..-1] 752 | RIGHT_TRIGGER = 5, // Gamepad back trigger right, pressure level: [1..-1] 753 | } 754 | 755 | // Material map index 756 | MaterialMapIndex :: enum cint { 757 | ALBEDO = 0, // Albedo material (same as: MATERIAL_MAP_DIFFUSE) 758 | METALNESS, // Metalness material (same as: MATERIAL_MAP_SPECULAR) 759 | NORMAL, // Normal material 760 | ROUGHNESS, // Roughness material 761 | OCCLUSION, // Ambient occlusion material 762 | EMISSION, // Emission material 763 | HEIGHT, // Heightmap material 764 | CUBEMAP, // Cubemap material (NOTE: Uses GL_TEXTURE_CUBE_MAP) 765 | IRRADIANCE, // Irradiance material (NOTE: Uses GL_TEXTURE_CUBE_MAP) 766 | PREFILTER, // Prefilter material (NOTE: Uses GL_TEXTURE_CUBE_MAP) 767 | BRDF, // Brdf material 768 | } 769 | 770 | 771 | // Shader location index 772 | ShaderLocationIndex :: enum cint { 773 | VERTEX_POSITION = 0, // Shader location: vertex attribute: position 774 | VERTEX_TEXCOORD01, // Shader location: vertex attribute: texcoord01 775 | VERTEX_TEXCOORD02, // Shader location: vertex attribute: texcoord02 776 | VERTEX_NORMAL, // Shader location: vertex attribute: normal 777 | VERTEX_TANGENT, // Shader location: vertex attribute: tangent 778 | VERTEX_COLOR, // Shader location: vertex attribute: color 779 | MATRIX_MVP, // Shader location: matrix uniform: model-view-projection 780 | MATRIX_VIEW, // Shader location: matrix uniform: view (camera transform) 781 | MATRIX_PROJECTION, // Shader location: matrix uniform: projection 782 | MATRIX_MODEL, // Shader location: matrix uniform: model (transform) 783 | MATRIX_NORMAL, // Shader location: matrix uniform: normal 784 | VECTOR_VIEW, // Shader location: vector uniform: view 785 | COLOR_DIFFUSE, // Shader location: vector uniform: diffuse color 786 | COLOR_SPECULAR, // Shader location: vector uniform: specular color 787 | COLOR_AMBIENT, // Shader location: vector uniform: ambient color 788 | MAP_ALBEDO, // Shader location: sampler2d texture: albedo (same as: SHADER_LOC_MAP_DIFFUSE) 789 | MAP_METALNESS, // Shader location: sampler2d texture: metalness (same as: SHADER_LOC_MAP_SPECULAR) 790 | MAP_NORMAL, // Shader location: sampler2d texture: normal 791 | MAP_ROUGHNESS, // Shader location: sampler2d texture: roughness 792 | MAP_OCCLUSION, // Shader location: sampler2d texture: occlusion 793 | MAP_EMISSION, // Shader location: sampler2d texture: emission 794 | MAP_HEIGHT, // Shader location: sampler2d texture: height 795 | MAP_CUBEMAP, // Shader location: samplerCube texture: cubemap 796 | MAP_IRRADIANCE, // Shader location: samplerCube texture: irradiance 797 | MAP_PREFILTER, // Shader location: samplerCube texture: prefilter 798 | MAP_BRDF, // Shader location: sampler2d texture: brdf 799 | } 800 | 801 | 802 | // Shader uniform data type 803 | ShaderUniformDataType :: enum cint { 804 | FLOAT = 0, // Shader uniform type: float 805 | VEC2, // Shader uniform type: vec2 (2 float) 806 | VEC3, // Shader uniform type: vec3 (3 float) 807 | VEC4, // Shader uniform type: vec4 (4 float) 808 | INT, // Shader uniform type: int 809 | IVEC2, // Shader uniform type: ivec2 (2 int) 810 | IVEC3, // Shader uniform type: ivec3 (3 int) 811 | IVEC4, // Shader uniform type: ivec4 (4 int) 812 | SAMPLER2D, // Shader uniform type: sampler2d 813 | } 814 | 815 | // Pixel formats 816 | // NOTE: Support depends on OpenGL version and platform 817 | PixelFormat :: enum cint { 818 | UNKNOWN = 0, 819 | UNCOMPRESSED_GRAYSCALE = 1, // 8 bit per pixel (no alpha) 820 | UNCOMPRESSED_GRAY_ALPHA, // 8*2 bpp (2 channels) 821 | UNCOMPRESSED_R5G6B5, // 16 bpp 822 | UNCOMPRESSED_R8G8B8, // 24 bpp 823 | UNCOMPRESSED_R5G5B5A1, // 16 bpp (1 bit alpha) 824 | UNCOMPRESSED_R4G4B4A4, // 16 bpp (4 bit alpha) 825 | UNCOMPRESSED_R8G8B8A8, // 32 bpp 826 | UNCOMPRESSED_R32, // 32 bpp (1 channel - float) 827 | UNCOMPRESSED_R32G32B32, // 32*3 bpp (3 channels - float) 828 | UNCOMPRESSED_R32G32B32A32, // 32*4 bpp (4 channels - float) 829 | UNCOMPRESSED_R16, // 16 bpp (1 channel - float) 830 | UNCOMPRESSED_R16G16B16, // 16*3 bpp (3 channels - float) 831 | UNCOMPRESSED_R16G16B16A16, // 16*4 bpp (4 channels - float) 832 | COMPRESSED_DXT1_RGB, // 4 bpp (no alpha) 833 | COMPRESSED_DXT1_RGBA, // 4 bpp (1 bit alpha) 834 | COMPRESSED_DXT3_RGBA, // 8 bpp 835 | COMPRESSED_DXT5_RGBA, // 8 bpp 836 | COMPRESSED_ETC1_RGB, // 4 bpp 837 | COMPRESSED_ETC2_RGB, // 4 bpp 838 | COMPRESSED_ETC2_EAC_RGBA, // 8 bpp 839 | COMPRESSED_PVRT_RGB, // 4 bpp 840 | COMPRESSED_PVRT_RGBA, // 4 bpp 841 | COMPRESSED_ASTC_4x4_RGBA, // 8 bpp 842 | COMPRESSED_ASTC_8x8_RGBA, // 2 bpp 843 | } 844 | 845 | // Texture parameters: filter mode 846 | // NOTE 1: Filtering considers mipmaps if available in the texture 847 | // NOTE 2: Filter is accordingly set for minification and magnification 848 | TextureFilter :: enum cint { 849 | POINT = 0, // No filter, just pixel approximation 850 | BILINEAR, // Linear filtering 851 | TRILINEAR, // Trilinear filtering (linear with mipmaps) 852 | ANISOTROPIC_4X, // Anisotropic filtering 4x 853 | ANISOTROPIC_8X, // Anisotropic filtering 8x 854 | ANISOTROPIC_16X, // Anisotropic filtering 16x 855 | } 856 | 857 | // Texture parameters: wrap mode 858 | TextureWrap :: enum cint { 859 | REPEAT = 0, // Repeats texture in tiled mode 860 | CLAMP, // Clamps texture to edge pixel in tiled mode 861 | MIRROR_REPEAT, // Mirrors and repeats the texture in tiled mode 862 | MIRROR_CLAMP, // Mirrors and clamps to border the texture in tiled mode 863 | } 864 | 865 | // Cubemap layouts 866 | CubemapLayout :: enum cint { 867 | AUTO_DETECT = 0, // Automatically detect layout type 868 | LINE_VERTICAL, // Layout is defined by a vertical line with faces 869 | LINE_HORIZONTAL, // Layout is defined by an horizontal line with faces 870 | CROSS_THREE_BY_FOUR, // Layout is defined by a 3x4 cross with cubemap faces 871 | CROSS_FOUR_BY_THREE, // Layout is defined by a 4x3 cross with cubemap faces 872 | PANORAMA, // Layout is defined by a panorama image (equirectangular map) 873 | } 874 | 875 | // Font type, defines generation method 876 | FontType :: enum cint { 877 | DEFAULT = 0, // Default font generation, anti-aliased 878 | BITMAP, // Bitmap font generation, no anti-aliasing 879 | SDF, // SDF font generation, requires external shader 880 | } 881 | 882 | // Color blending modes (pre-defined) 883 | BlendMode :: enum cint { 884 | ALPHA = 0, // Blend textures considering alpha (default) 885 | ADDITIVE, // Blend textures adding colors 886 | MULTIPLIED, // Blend textures multiplying colors 887 | ADD_COLORS, // Blend textures adding colors (alternative) 888 | SUBTRACT_COLORS, // Blend textures subtracting colors (alternative) 889 | ALPHA_PREMULTIPLY, // Blend premultiplied textures considering alpha 890 | CUSTOM, // Blend textures using custom src/dst factors (use rlSetBlendFactors()) 891 | CUSTOM_SEPARATE, // Blend textures using custom rgb/alpha separate src/dst factors (use rlSetBlendFactorsSeparate()) 892 | } 893 | 894 | // Gestures 895 | // NOTE: It could be used as flags to enable only some gestures 896 | Gesture :: enum cuint { 897 | TAP = 0, // Tap gesture 898 | DOUBLETAP = 1, // Double tap gesture 899 | HOLD = 2, // Hold gesture 900 | DRAG = 3, // Drag gesture 901 | SWIPE_RIGHT = 4, // Swipe right gesture 902 | SWIPE_LEFT = 5, // Swipe left gesture 903 | SWIPE_UP = 6, // Swipe up gesture 904 | SWIPE_DOWN = 7, // Swipe down gesture 905 | PINCH_IN = 8, // Pinch in gesture 906 | PINCH_OUT = 9, // Pinch out gesture 907 | } 908 | Gestures :: distinct bit_set[Gesture; cuint] 909 | 910 | // Camera system modes 911 | CameraMode :: enum cint { 912 | CUSTOM = 0, // Custom camera 913 | FREE, // Free camera 914 | ORBITAL, // Orbital camera 915 | FIRST_PERSON, // First person camera 916 | THIRD_PERSON, // Third person camera 917 | } 918 | 919 | // Camera projection 920 | CameraProjection :: enum cint { 921 | PERSPECTIVE = 0, // Perspective projection 922 | ORTHOGRAPHIC, // Orthographic projection 923 | } 924 | 925 | // N-patch layout 926 | NPatchLayout :: enum cint { 927 | NINE_PATCH = 0, // Npatch layout: 3x3 tiles 928 | THREE_PATCH_VERTICAL, // Npatch layout: 1x3 tiles 929 | THREE_PATCH_HORIZONTAL, // Npatch layout: 3x1 tiles 930 | } 931 | 932 | 933 | 934 | // Callbacks to hook some internal functions 935 | // WARNING: This callbacks are intended for advance users 936 | // TraceLogCallback :: #type proc "c" (logLevel: TraceLogLevel, text: cstring, args: c.va_list) // Logging: Redirect trace log messages 937 | LoadFileDataCallback :: #type proc "c"(fileName: cstring, dataSize: ^cint) -> [^]u8 // FileIO: Load binary data 938 | SaveFileDataCallback :: #type proc "c" (fileName: cstring, data: rawptr, dataSize: cint) -> bool // FileIO: Save binary data 939 | LoadFileTextCallback :: #type proc "c" (fileName: cstring) -> [^]u8 // FileIO: Load text data 940 | SaveFileTextCallback :: #type proc "c" (fileName: cstring, text: cstring) -> bool // FileIO: Save text data 941 | 942 | AudioCallback :: #type proc "c" (bufferData: rawptr, frames: cuint) 943 | 944 | 945 | @(default_calling_convention="c") 946 | foreign { 947 | //------------------------------------------------------------------------------------ 948 | // Global Variables Definition 949 | //------------------------------------------------------------------------------------ 950 | // It's lonely here... 951 | 952 | //------------------------------------------------------------------------------------ 953 | // Window and Graphics Device Functions (Module: core) 954 | //------------------------------------------------------------------------------------ 955 | 956 | // Window-related functions 957 | 958 | InitWindow :: proc(width, height: cint, title: cstring) --- // Initialize window and OpenGL context 959 | WindowShouldClose :: proc() -> bool --- // Check if application should close (KEY_ESCAPE pressed or windows close icon clicked) 960 | CloseWindow :: proc() --- // Close window and unload OpenGL context 961 | IsWindowReady :: proc() -> bool --- // Check if window has been initialized successfully 962 | IsWindowFullscreen :: proc() -> bool --- // Check if window is currently fullscreen 963 | IsWindowHidden :: proc() -> bool --- // Check if window is currently hidden (only PLATFORM_DESKTOP) 964 | IsWindowMinimized :: proc() -> bool --- // Check if window is currently minimized (only PLATFORM_DESKTOP) 965 | IsWindowMaximized :: proc() -> bool --- // Check if window is currently maximized (only PLATFORM_DESKTOP) 966 | IsWindowFocused :: proc() -> bool --- // Check if window is currently focused (only PLATFORM_DESKTOP) 967 | IsWindowResized :: proc() -> bool --- // Check if window has been resized last frame 968 | IsWindowState :: proc(flags: ConfigFlags) -> bool --- // Check if one specific window flag is enabled 969 | SetWindowState :: proc(flags: ConfigFlags) --- // Set window configuration state using flags (only PLATFORM_DESKTOP) 970 | ClearWindowState :: proc(flags: ConfigFlags) --- // Clear window configuration state flags 971 | ToggleFullscreen :: proc() --- // Toggle window state: fullscreen/windowed (only PLATFORM_DESKTOP) 972 | ToggleBorderlessWindowed :: proc() --- // Toggle window state: borderless windowed (only PLATFORM_DESKTOP) 973 | MaximizeWindow :: proc() --- // Set window state: maximized, if resizable (only PLATFORM_DESKTOP) 974 | MinimizeWindow :: proc() --- // Set window state: minimized, if resizable (only PLATFORM_DESKTOP) 975 | RestoreWindow :: proc() --- // Set window state: not minimized/maximized (only PLATFORM_DESKTOP) 976 | SetWindowIcon :: proc(image: Image) --- // Set icon for window (single image, RGBA 32bit, only PLATFORM_DESKTOP) 977 | SetWindowIcons :: proc(images: [^]Image, count: cint) --- // Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP) 978 | SetWindowTitle :: proc(title: cstring) --- // Set title for window (only PLATFORM_DESKTOP and PLATFORM_WEB) 979 | SetWindowPosition :: proc(x, y: cint) --- // Set window position on screen (only PLATFORM_DESKTOP) 980 | SetWindowMonitor :: proc(monitor: cint) --- // Set monitor for the current window 981 | SetWindowMinSize :: proc(width, height: cint) --- // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE) 982 | SetWindowMaxSize :: proc(width, height: cint) --- // Set window maximum dimensions (for FLAG_WINDOW_RESIZABLE) 983 | SetWindowSize :: proc(width, height: cint) --- // Set window dimensions 984 | SetWindowOpacity :: proc(opacity: f32) --- // Set window opacity [0.0f..1.0f] (only PLATFORM_DESKTOP) 985 | SetWindowFocused :: proc() --- // Set window focused (only PLATFORM_DESKTOP) 986 | GetWindowHandle :: proc() -> rawptr --- // Get native window handle 987 | GetScreenWidth :: proc() -> cint --- // Get current screen width 988 | GetScreenHeight :: proc() -> cint --- // Get current screen height 989 | GetRenderWidth :: proc() -> cint --- // Get current render width (it considers HiDPI) 990 | GetRenderHeight :: proc() -> cint --- // Get current render height (it considers HiDPI) 991 | GetMonitorCount :: proc() -> cint --- // Get number of connected monitors 992 | GetCurrentMonitor :: proc() -> cint --- // Get current connected monitor 993 | GetMonitorPosition :: proc(monitor: cint) -> Vector2 --- // Get specified monitor position 994 | GetMonitorWidth :: proc(monitor: cint) -> cint --- // Get specified monitor width (current video mode used by monitor) 995 | GetMonitorHeight :: proc(monitor: cint) -> cint --- // Get specified monitor height (current video mode used by monitor) 996 | GetMonitorPhysicalWidth :: proc(monitor: cint) -> cint --- // Get specified monitor physical width in millimetres 997 | GetMonitorPhysicalHeight :: proc(monitor: cint) -> cint --- // Get specified monitor physical height in millimetres 998 | GetMonitorRefreshRate :: proc(monitor: cint) -> cint --- // Get specified monitor refresh rate 999 | GetWindowPosition :: proc() -> Vector2 --- // Get window position XY on monitor 1000 | GetWindowScaleDPI :: proc() -> Vector2 --- // Get window scale DPI factor 1001 | GetMonitorName :: proc(monitor: cint) -> cstring --- // Get the human-readable, UTF-8 encoded name of the specified monitor 1002 | SetClipboardText :: proc(text: cstring) --- // Set clipboard text content 1003 | GetClipboardText :: proc() -> cstring --- // Get clipboard text content 1004 | EnableEventWaiting :: proc() --- // Enable waiting for events on EndDrawing(), no automatic event polling 1005 | DisableEventWaiting :: proc() --- // Disable waiting for events on EndDrawing(), automatic events polling 1006 | 1007 | 1008 | // Custom frame control functions 1009 | // NOTE: Those functions are intended for advance users that want full control over the frame processing 1010 | // By default EndDrawing() does this job: draws everything + SwapScreenBuffer() + manage frame timing + PollInputEvents() 1011 | // To avoid that behaviour and control frame processes manually, enable in config.h: SUPPORT_CUSTOM_FRAME_CONTROL 1012 | 1013 | SwapScreenBuffer :: proc() --- // Swap back buffer with front buffer (screen drawing) 1014 | PollInputEvents :: proc() --- // Register all input events 1015 | WaitTime :: proc(seconds: f64) --- // Wait for some time (halt program execution) 1016 | 1017 | 1018 | // Cursor-related functions 1019 | 1020 | ShowCursor :: proc() --- // Shows cursor 1021 | HideCursor :: proc() --- // Hides cursor 1022 | IsCursorHidden :: proc() -> bool --- // Check if cursor is not visible 1023 | EnableCursor :: proc() --- // Enables cursor (unlock cursor) 1024 | DisableCursor :: proc() --- // Disables cursor (lock cursor) 1025 | IsCursorOnScreen :: proc() -> bool --- // Check if cursor is on the current screen. 1026 | 1027 | // Drawing-related functions 1028 | 1029 | ClearBackground :: proc(color: Color) --- // Set background color (framebuffer clear color) 1030 | BeginDrawing :: proc() --- // Setup canvas (framebuffer) to start drawing 1031 | EndDrawing :: proc() --- // End canvas drawing and swap buffers (double buffering) 1032 | BeginMode2D :: proc(camera: Camera2D) --- // Initialize 2D mode with custom camera (2D) 1033 | EndMode2D :: proc() --- // Ends 2D mode with custom camera 1034 | BeginMode3D :: proc(camera: Camera3D) --- // Initializes 3D mode with custom camera (3D) 1035 | EndMode3D :: proc() --- // Ends 3D mode and returns to default 2D orthographic mode 1036 | BeginTextureMode :: proc(target: RenderTexture2D) --- // Initializes render texture for drawing 1037 | EndTextureMode :: proc() --- // Ends drawing to render texture 1038 | BeginShaderMode :: proc(shader: Shader) --- // Begin custom shader drawing 1039 | EndShaderMode :: proc() --- // End custom shader drawing (use default shader) 1040 | BeginBlendMode :: proc(mode: BlendMode) --- // Begin blending mode (alpha, additive, multiplied) 1041 | EndBlendMode :: proc() --- // End blending mode (reset to default: alpha blending) 1042 | BeginScissorMode :: proc(x, y, width, height: cint) --- // Begin scissor mode (define screen area for following drawing) 1043 | EndScissorMode :: proc() --- // End scissor mode 1044 | BeginVrStereoMode :: proc(config: VrStereoConfig) --- // Begin stereo rendering (requires VR simulator) 1045 | EndVrStereoMode :: proc() --- // End stereo rendering (requires VR simulator) 1046 | 1047 | // VR stereo config functions for VR simulator 1048 | 1049 | LoadVrStereoConfig :: proc(device: VrDeviceInfo) -> VrStereoConfig --- // Load VR stereo config for VR simulator device parameters 1050 | UnloadVrStereoConfig :: proc(config: VrStereoConfig) --- // Unload VR stereo config 1051 | 1052 | // Shader management functions 1053 | // NOTE: Shader functionality is not available on OpenGL 1.1 1054 | 1055 | LoadShader :: proc(vsFileName, fsFileName: cstring) -> Shader --- // Load shader from files and bind default locations 1056 | LoadShaderFromMemory :: proc(vsCode, fsCode: cstring) -> Shader --- // Load shader from code strings and bind default locations 1057 | IsShaderReady :: proc(shader: Shader) -> bool --- // Check if a shader is ready 1058 | GetShaderLocation :: proc(shader: Shader, uniformName: cstring) -> cint --- // Get shader uniform location 1059 | GetShaderLocationAttrib :: proc(shader: Shader, attribName: cstring) -> cint --- // Get shader attribute location 1060 | SetShaderValue :: proc(shader: Shader, locIndex: ShaderLocationIndex, value: rawptr, uniformType: ShaderUniformDataType) --- // Set shader uniform value 1061 | SetShaderValueV :: proc(shader: Shader, locIndex: ShaderLocationIndex, value: rawptr, uniformType: ShaderUniformDataType, count: cint) --- // Set shader uniform value vector 1062 | SetShaderValueMatrix :: proc(shader: Shader, locIndex: ShaderLocationIndex, mat: Matrix) --- // Set shader uniform value (matrix 4x4) 1063 | SetShaderValueTexture :: proc(shader: Shader, locIndex: ShaderLocationIndex, texture: Texture2D) --- // Set shader uniform value for texture (sampler2d) 1064 | UnloadShader :: proc(shader: Shader) --- // Unload shader from GPU memory (VRAM) 1065 | 1066 | // Screen-space-related functions 1067 | 1068 | GetMouseRay :: proc(mousePosition: Vector2, camera: Camera) -> Ray --- // Get a ray trace from mouse position 1069 | GetCameraMatrix :: proc(camera: Camera) -> Matrix --- // Get camera transform matrix (view matrix) 1070 | GetCameraMatrix2D :: proc(camera: Camera2D) -> Matrix --- // Get camera 2d transform matrix 1071 | GetWorldToScreen :: proc(position: Vector3, camera: Camera) -> Vector2 --- // Get the screen space position for a 3d world space position 1072 | GetScreenToWorld2D :: proc(position: Vector2, camera: Camera2D) -> Vector2 --- // Get the world space position for a 2d camera screen space position 1073 | GetWorldToScreenEx :: proc(position: Vector3, camera: Camera, width, height: cint) -> Vector2 --- // Get size position for a 3d world space position 1074 | GetWorldToScreen2D :: proc(position: Vector2, camera: Camera2D) -> Vector2 --- // Get the screen space position for a 2d camera world space position 1075 | 1076 | // Timing-related functions 1077 | 1078 | SetTargetFPS :: proc(fps: cint) --- // Set target FPS (maximum) 1079 | GetFPS :: proc() -> cint --- // Returns current FPS 1080 | GetFrameTime :: proc() -> f32 --- // Returns time in seconds for last frame drawn (delta time) 1081 | GetTime :: proc() -> f64 --- // Returns elapsed time in seconds since InitWindow() 1082 | 1083 | // Random value generation functions 1084 | 1085 | SetRandomSeed :: proc(seed: cuint) --- // Set the seed for the random number generator 1086 | GetRandomValue :: proc(min, max: cint) -> cint --- // Get a random value between min and max (both included) 1087 | LoadRandomSequence :: proc(count : cuint, min, max: cint) --- // Load random values sequence, no values repeated 1088 | UnloadRandomSequence :: proc(sequence : ^cint) --- // Unload random values sequence 1089 | 1090 | // Misc. functions 1091 | TakeScreenshot :: proc(fileName: cstring) --- // Takes a screenshot of current screen (filename extension defines format) 1092 | SetConfigFlags :: proc(flags: ConfigFlags) --- // Setup init configuration flags (view FLAGS). NOTE: This function is expected to be called before window creation 1093 | OpenURL :: proc(url: cstring) --- // Open URL with default system browser (if available) 1094 | 1095 | // NOTE: Following functions implemented in module [utils] 1096 | //------------------------------------------------------------------ 1097 | TraceLog :: proc(logLevel: TraceLogLevel, text: cstring, #c_vararg args: ..any) --- // Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR) 1098 | SetTraceLogLevel :: proc(logLevel: TraceLogLevel) --- // Set the current threshold (minimum) log level 1099 | MemAlloc :: proc(size: cuint) -> rawptr --- // Internal memory allocator 1100 | MemRealloc :: proc(ptr: rawptr, size: cuint) -> rawptr --- // Internal memory reallocator 1101 | MemFree :: proc(ptr: rawptr) --- // Internal memory free 1102 | 1103 | // Set custom callbacks 1104 | // WARNING: Callbacks setup is intended for advance users 1105 | 1106 | // SetTraceLogCallback :: proc(callback: TraceLogCallback) --- // Set custom trace log 1107 | SetLoadFileDataCallback :: proc(callback: LoadFileDataCallback) --- // Set custom file binary data loader 1108 | SetSaveFileDataCallback :: proc(callback: SaveFileDataCallback) --- // Set custom file binary data saver 1109 | SetLoadFileTextCallback :: proc(callback: LoadFileTextCallback) --- // Set custom file text data loader 1110 | SetSaveFileTextCallback :: proc(callback: SaveFileTextCallback) --- // Set custom file text data saver 1111 | 1112 | // Files management functions 1113 | 1114 | LoadFileData :: proc(fileName: cstring, dataSize: ^cint) -> [^]byte --- // Load file data as byte array (read) 1115 | UnloadFileData :: proc(data: [^]byte) --- // Unload file data allocated by LoadFileData() 1116 | SaveFileData :: proc(fileName: cstring, data: rawptr, dataSize: cint) -> bool --- // Save data to file from byte array (write), returns true on success 1117 | ExportDataAsCode :: proc(data: rawptr, dataSize: cint, fileName: cstring) -> bool --- // Export data to code (.h), returns true on success 1118 | LoadFileText :: proc(fileName: cstring) -> [^]byte --- // Load text data from file (read), returns a '\0' terminated string 1119 | UnloadFileText :: proc(text: [^]byte) --- // Unload file text data allocated by LoadFileText() 1120 | SaveFileText :: proc(fileName: cstring, text: [^]byte) -> bool --- // Save text data to file (write), string must be '\0' terminated, returns true on success 1121 | 1122 | // File system functions 1123 | 1124 | FileExists :: proc(fileName: cstring) -> bool --- // Check if file exists 1125 | DirectoryExists :: proc(dirPath: cstring) -> bool --- // Check if a directory path exists 1126 | IsFileExtension :: proc(fileName, ext: cstring) -> bool --- // Check file extension (including point: .png, .wav) 1127 | GetFileLength :: proc(fileName: cstring) -> cint --- // Get file length in bytes (NOTE: GetFileSize() conflicts with windows.h) 1128 | GetFileExtension :: proc(fileName: cstring) -> cstring --- // Get pointer to extension for a filename string (includes dot: '.png') 1129 | GetFileName :: proc(filePath: cstring) -> cstring --- // Get pointer to filename for a path string 1130 | GetFileNameWithoutExt :: proc(filePath: cstring) -> cstring --- // Get filename string without extension (uses static string) 1131 | GetDirectoryPath :: proc(filePath: cstring) -> cstring --- // Get full path for a given fileName with path (uses static string) 1132 | GetPrevDirectoryPath :: proc(dirPath: cstring) -> cstring --- // Get previous directory path for a given path (uses static string) 1133 | GetWorkingDirectory :: proc() -> cstring --- // Get current working directory (uses static string) 1134 | GetApplicationDirectory :: proc() -> cstring --- // Get the directory of the running application (uses static string) 1135 | ChangeDirectory :: proc(dir: cstring) -> bool --- // Change working directory, return true on success 1136 | IsPathFile :: proc(path: cstring) -> bool --- // Check if a given path is a file or a directory 1137 | LoadDirectoryFiles :: proc(dirPath: cstring) -> FilePathList --- // Load directory filepaths 1138 | LoadDirectoryFilesEx :: proc(basePath: cstring, filter: cstring, scanSubdirs: bool) -> FilePathList --- // Load directory filepaths with extension filtering and recursive directory scan 1139 | UnloadDirectoryFiles :: proc(files: FilePathList) --- // Unload filepaths 1140 | IsFileDropped :: proc() -> bool --- // Check if a file has been dropped into window 1141 | LoadDroppedFiles :: proc() -> FilePathList --- // Load dropped filepaths 1142 | UnloadDroppedFiles :: proc(files: FilePathList) --- // Unload dropped filepaths 1143 | GetFileModTime :: proc(fileName: cstring) -> clong --- // Get file modification time (last write time) 1144 | 1145 | // Compression/Encoding functionality 1146 | 1147 | CompressData :: proc(data: rawptr, dataSize: cint, compDataSize: ^cint) -> [^]byte --- // Compress data (DEFLATE algorithm), memory must be MemFree() 1148 | DecompressData :: proc(compData: rawptr, compDataSize: cint, dataSize: ^cint) -> [^]byte --- // Decompress data (DEFLATE algorithm), memory must be MemFree() 1149 | EncodeDataBase64 :: proc(data: rawptr, dataSize: cint, outputSize: ^cint) -> [^]byte --- // Encode data to Base64 string, memory must be MemFree() 1150 | DecodeDataBase64 :: proc(data: rawptr, outputSize: ^cint) -> [^]byte --- // Decode Base64 string data, memory must be MemFree() 1151 | 1152 | // Automation events functionality 1153 | 1154 | LoadAutomationEventList :: proc(fileName: cstring) -> AutomationEventList --- // Load automation events list from file, NULL for empty list, capacity = MAX_AUTOMATION_EVENTS 1155 | UnloadAutomationEventList :: proc(list: ^AutomationEventList) --- // Unload automation events list from file 1156 | ExportAutomationEventList :: proc(list: AutomationEventList, fileName: cstring) -> bool --- // Export automation events list as text file 1157 | SetAutomationEventList :: proc(list: ^AutomationEventList) --- // Set automation event list to record to 1158 | SetAutomationEventBaseFrame :: proc(frame: cint) --- // Set automation event internal base frame to start recording 1159 | StartAutomationEventRecording :: proc() --- // Start recording automation events (AutomationEventList must be set) 1160 | StopAutomationEventRecording :: proc() --- // Stop recording automation events 1161 | PlayAutomationEvent :: proc(event: AutomationEvent) --- // Play a recorded automation event 1162 | 1163 | //------------------------------------------------------------------------------------ 1164 | // Input Handling Functions (Module: core) 1165 | //------------------------------------------------------------------------------------ 1166 | 1167 | // Input-related functions: keyboard 1168 | 1169 | IsKeyPressed :: proc(key: KeyboardKey) -> bool --- // Detect if a key has been pressed once 1170 | IsKeyPressedRepeat :: proc(key: KeyboardKey) -> bool --- // Check if a key has been pressed again (Only PLATFORM_DESKTOP) 1171 | IsKeyDown :: proc(key: KeyboardKey) -> bool --- // Detect if a key is being pressed 1172 | IsKeyReleased :: proc(key: KeyboardKey) -> bool --- // Detect if a key has been released once 1173 | IsKeyUp :: proc(key: KeyboardKey) -> bool --- // Detect if a key is NOT being pressed 1174 | GetKeyPressed :: proc() -> KeyboardKey --- // Get key pressed (keycode), call it multiple times for keys queued 1175 | GetCharPressed :: proc() -> rune --- // Get char pressed (unicode), call it multiple times for chars queued 1176 | SetExitKey :: proc(key: KeyboardKey) --- // Set a custom key to exit program (default is ESC) 1177 | 1178 | // Input-related functions: gamepads 1179 | 1180 | IsGamepadAvailable :: proc(gamepad: cint) -> bool --- // Check if a gamepad is available 1181 | GetGamepadName :: proc(gamepad: cint) -> cstring --- // Get gamepad internal name id 1182 | IsGamepadButtonPressed :: proc(gamepad: cint, button: GamepadButton) -> bool --- // Check if a gamepad button has been pressed once 1183 | IsGamepadButtonDown :: proc(gamepad: cint, button: GamepadButton) -> bool --- // Check if a gamepad button is being pressed 1184 | IsGamepadButtonReleased :: proc(gamepad: cint, button: GamepadButton) -> bool --- // Check if a gamepad button has been released once 1185 | IsGamepadButtonUp :: proc(gamepad: cint, button: GamepadButton) -> bool --- // Check if a gamepad button is NOT being pressed 1186 | GetGamepadButtonPressed :: proc() -> GamepadButton --- // Get the last gamepad button pressed 1187 | GetGamepadAxisCount :: proc(gamepad: cint) -> cint --- // Get gamepad axis count for a gamepad 1188 | GetGamepadAxisMovement :: proc(gamepad: cint, axis: GamepadAxis) -> f32 --- // Get axis movement value for a gamepad axis 1189 | SetGamepadMappings :: proc(mappings: cstring) -> cint --- // Set internal gamepad mappings (SDL_GameControllerDB) 1190 | 1191 | // Input-related functions: mouse 1192 | 1193 | IsMouseButtonPressed :: proc(button: MouseButton) -> bool --- // Detect if a mouse button has been pressed once 1194 | IsMouseButtonDown :: proc(button: MouseButton) -> bool --- // Detect if a mouse button is being pressed 1195 | IsMouseButtonReleased :: proc(button: MouseButton) -> bool --- // Detect if a mouse button has been released once 1196 | 1197 | when VERSION != "5.0" { 1198 | #panic("IsMouseButtonUp was broken in Raylib 5.0 but should be fixed in Raylib > 5.0. Remove this panic and the when block around it and also remove the workaround version of IsMouseButtonUp just after the end of the 'foreign lib {' block.") 1199 | IsMouseButtonUp :: proc(button: MouseButton) -> bool --- 1200 | } 1201 | 1202 | GetMouseX :: proc() -> cint --- // Returns mouse position X 1203 | GetMouseY :: proc() -> cint --- // Returns mouse position Y 1204 | GetMousePosition :: proc() -> Vector2 --- // Returns mouse position XY 1205 | GetMouseDelta :: proc() -> Vector2 --- // Returns mouse delta XY 1206 | SetMousePosition :: proc(x, y: cint) --- // Set mouse position XY 1207 | SetMouseOffset :: proc(offsetX, offsetY: cint) --- // Set mouse offset 1208 | SetMouseScale :: proc(scaleX, scaleY: f32) --- // Set mouse scaling 1209 | GetMouseWheelMove :: proc() -> f32 --- // Returns mouse wheel movement Y 1210 | GetMouseWheelMoveV :: proc() -> Vector2 --- // Get mouse wheel movement for both X and Y 1211 | SetMouseCursor :: proc(cursor: MouseCursor) --- // Set mouse cursor 1212 | 1213 | // Input-related functions: touch 1214 | 1215 | GetTouchX :: proc() -> cint --- // Returns touch position X for touch point 0 (relative to screen size) 1216 | GetTouchY :: proc() -> cint --- // Returns touch position Y for touch point 0 (relative to screen size) 1217 | GetTouchPosition :: proc(index: cint) -> Vector2 --- // Returns touch position XY for a touch point index (relative to screen size) 1218 | GetTouchPointId :: proc(index: cint) -> cint --- // Get touch point identifier for given index 1219 | GetTouchPointCount :: proc() -> cint --- // Get number of touch points 1220 | 1221 | //------------------------------------------------------------------------------------ 1222 | // Gestures and Touch Handling Functions (Module: rgestures) 1223 | //------------------------------------------------------------------------------------ 1224 | 1225 | SetGesturesEnabled :: proc(flags: Gestures) --- // Enable a set of gestures using flags 1226 | // IsGestureDetected :: proc(gesture: Gesture) -> bool --- // Check if a gesture have been detected 1227 | 1228 | GetGestureDetected :: proc() -> Gestures --- // Get latest detected gesture 1229 | GetGestureHoldDuration :: proc() -> f32 --- // Get gesture hold time in milliseconds 1230 | GetGestureDragVector :: proc() -> Vector2 --- // Get gesture drag vector 1231 | GetGestureDragAngle :: proc() -> f32 --- // Get gesture drag angle 1232 | GetGesturePinchVector :: proc() -> Vector2 --- // Get gesture pinch delta 1233 | GetGesturePinchAngle :: proc() -> f32 --- // Get gesture pinch angle 1234 | 1235 | //------------------------------------------------------------------------------------ 1236 | // Camera System Functions (Module: camera) 1237 | //------------------------------------------------------------------------------------ 1238 | 1239 | UpdateCamera :: proc(camera: ^Camera, mode: CameraMode) --- // Set camera mode (multiple camera modes available) 1240 | UpdateCameraPro :: proc(camera: ^Camera, movement: Vector3, rotation: Vector3, zoom: f32) --- // Update camera movement/rotation 1241 | 1242 | //------------------------------------------------------------------------------------ 1243 | // Basic Shapes Drawing Functions (Module: shapes) 1244 | //------------------------------------------------------------------------------------ 1245 | // Set texture and rectangle to be used on shapes drawing 1246 | // NOTE: It can be useful when using basic shapes and one single font, 1247 | // defining a font char white rectangle would allow drawing everything in a single draw call 1248 | 1249 | SetShapesTexture :: proc(texture: Texture2D, source: Rectangle) --- 1250 | 1251 | // Basic shapes drawing functions 1252 | 1253 | DrawPixel :: proc(posX, posY: cint, color: Color) --- // Draw a pixel 1254 | DrawPixelV :: proc(position: Vector2, color: Color) --- // Draw a pixel (Vector version) 1255 | DrawLine :: proc(startPosX, startPosY, endPosX, endPosY: cint, color: Color) --- // Draw a line 1256 | DrawLineV :: proc(startPos, endPos: Vector2, color: Color) --- // Draw a line (using gl lines) 1257 | DrawLineEx :: proc(startPos, endPos: Vector2, thick: f32, color: Color) --- // Draw a line (using triangles/quads) 1258 | DrawLineStrip :: proc(points: [^]Vector2, pointCount: cint, color: Color) --- // Draw lines sequence (using gl lines) 1259 | DrawLineBezier :: proc(startPos, endPos: Vector2, thick: f32, color: Color) --- // Draw line segment cubic-bezier in-out interpolation 1260 | DrawCircle :: proc(centerX, centerY: cint, radius: f32, color: Color) --- // Draw a color-filled circle 1261 | DrawCircleSector :: proc(center: Vector2, radius: f32, startAngle, endAngle: f32, segments: cint, color: Color) --- // Draw a piece of a circle 1262 | DrawCircleSectorLines :: proc(center: Vector2, radius: f32, startAngle, endAngle: f32, segments: cint, color: Color) --- // Draw circle sector outline 1263 | DrawCircleGradient :: proc(centerX, centerY: cint, radius: f32, color1, color2: Color) --- // Draw a gradient-filled circle 1264 | DrawCircleV :: proc(center: Vector2, radius: f32, color: Color) --- // Draw a color-filled circle (Vector version) 1265 | DrawCircleLines :: proc(centerX, centerY: cint, radius: f32, color: Color) --- // Draw circle outline 1266 | DrawCircleLinesV :: proc(center: Vector2, radius: f32, color: Color) --- // Draw circle outline (Vector version) 1267 | DrawEllipse :: proc(centerX, centerY: cint, radiusH, radiusV: f32, color: Color) --- // Draw ellipse 1268 | DrawEllipseLines :: proc(centerX, centerY: cint, radiusH, radiusV: f32, color: Color) --- // Draw ellipse outline 1269 | DrawRing :: proc(center: Vector2, innerRadius, outerRadius: f32, startAngle, endAngle: f32, segments: cint, color: Color) --- // Draw ring 1270 | DrawRingLines :: proc(center: Vector2, innerRadius, outerRadius: f32, startAngle, endAngle: f32, segments: cint, color: Color) --- // Draw ring outline 1271 | DrawRectangle :: proc(posX, posY: cint, width, height: cint, color: Color) --- // Draw a color-filled rectangle 1272 | DrawRectangleV :: proc(position: Vector2, size: Vector2, color: Color) --- // Draw a color-filled rectangle (Vector version) 1273 | DrawRectangleRec :: proc(rec: Rectangle, color: Color) --- // Draw a color-filled rectangle 1274 | DrawRectanglePro :: proc(rec: Rectangle, origin: Vector2, rotation: f32, color: Color) --- // Draw a color-filled rectangle with pro parameters 1275 | DrawRectangleGradientV :: proc(posX, posY: cint, width, height: cint, color1, color2: Color) --- // Draw a vertical-gradient-filled rectangle 1276 | DrawRectangleGradientH :: proc(posX, posY: cint, width, height: cint, color1, color2: Color) --- // Draw a horizontal-gradient-filled rectangle 1277 | DrawRectangleGradientEx :: proc(rec: Rectangle, col1, col2, col3, col4: Color) --- // Draw a gradient-filled rectangle with custom vertex colors 1278 | DrawRectangleLines :: proc(posX, posY: cint, width, height: cint, color: Color) --- // Draw rectangle outline 1279 | DrawRectangleLinesEx :: proc(rec: Rectangle, lineThick: f32, color: Color) --- // Draw rectangle outline with extended parameters 1280 | DrawRectangleRounded :: proc(rec: Rectangle, roundness: f32, segments: cint, color: Color) --- // Draw rectangle with rounded edges 1281 | DrawRectangleRoundedLines :: proc(rec: Rectangle, roundness: f32, segments: cint, lineThick: f32, color: Color) --- // Draw rectangle with rounded edges outline 1282 | DrawTriangle :: proc(v1, v2, v3: Vector2, color: Color) --- // Draw a color-filled triangle (vertex in counter-clockwise order!) 1283 | DrawTriangleLines :: proc(v1, v2, v3: Vector2, color: Color) --- // Draw triangle outline (vertex in counter-clockwise order!) 1284 | DrawTriangleFan :: proc(points: [^]Vector2, pointCount: cint, color: Color) --- // Draw a triangle fan defined by points (first vertex is the center) 1285 | DrawTriangleStrip :: proc(points: [^]Vector2, pointCount: cint, color: Color) --- // Draw a triangle strip defined by points 1286 | DrawPoly :: proc(center: Vector2, sides: cint, radius: f32, rotation: f32, color: Color) --- // Draw a regular polygon (Vector version) 1287 | DrawPolyLines :: proc(center: Vector2, sides: cint, radius: f32, rotation: f32, color: Color) --- // Draw a polygon outline of n sides 1288 | DrawPolyLinesEx :: proc(center: Vector2, sides: cint, radius: f32, rotation: f32, lineThick: f32, color: Color) --- // Draw a polygon outline of n sides with extended parameters 1289 | 1290 | // Splines drawing functions 1291 | DrawSplineLinear :: proc(points: [^]Vector2, pointCount: cint, thick: f32, color: Color) --- // Draw spline: Linear, minimum 2 points 1292 | DrawSplineBasis :: proc(points: [^]Vector2, pointCount: cint, thick: f32, color: Color) --- // Draw spline: B-Spline, minimum 4 points 1293 | DrawSplineCatmullRom :: proc(points: [^]Vector2, pointCount: cint, thick: f32, color: Color) --- // Draw spline: Catmull-Rom, minimum 4 points 1294 | DrawSplineBezierQuadratic :: proc(points: [^]Vector2, pointCount: cint, thick: f32, color: Color) --- // Draw spline: Quadratic Bezier, minimum 3 points (1 control point): [p1, c2, p3, c4...] 1295 | DrawSplineBezierCubic :: proc(points: [^]Vector2, pointCount: cint, thick: f32, color: Color) --- // Draw spline: Cubic Bezier, minimum 4 points (2 control points): [p1, c2, c3, p4, c5, c6...] 1296 | DrawSplineSegmentLinear :: proc(p1, p2: Vector2, thick: f32, color: Color) --- // Draw spline segment: Linear, 2 points 1297 | DrawSplineSegmentBasis :: proc(p1, p2, p3, p4: Vector2, thick: f32, color: Color) --- // Draw spline segment: B-Spline, 4 points 1298 | DrawSplineSegmentCatmullRom :: proc(p1, p2, p3, p4: Vector2, thick: f32, color: Color) --- // Draw spline segment: Catmull-Rom, 4 points 1299 | DrawSplineSegmentBezierQuadratic :: proc(p1, c2, p3: Vector2, thick: f32, color: Color) --- // Draw spline segment: Quadratic Bezier, 2 points, 1 control point 1300 | DrawSplineSegmentBezierCubic :: proc(p1, c2, c3, p4: Vector2, thick: f32, color: Color) --- // Draw spline segment: Cubic Bezier, 2 points, 2 control points 1301 | 1302 | // Spline segment point evaluation functions, for a given t [0.0f .. 1.0f] 1303 | GetSplinePointLinear :: proc(startPos, endPos: Vector2, t: f32) -> Vector2 --- // Get (evaluate) spline point: Linear 1304 | GetSplinePointBasis :: proc(p1, p2, p3, p4: Vector2, t: f32) -> Vector2 --- // Get (evaluate) spline point: B-Spline 1305 | GetSplinePointCatmullRom :: proc(p1, p2, p3, p4: Vector2, t: f32) -> Vector2 --- // Get (evaluate) spline point: Catmull-Rom 1306 | GetSplinePointBezierQuad :: proc(p1, c2, p3: Vector2, t: f32) -> Vector2 --- // Get (evaluate) spline point: Quadratic Bezier 1307 | GetSplinePointBezierCubic :: proc(p1, c2, c3, p4: Vector2, t: f32) -> Vector2 --- // Get (evaluate) spline point: Cubic Bezier 1308 | // Basic shapes collision detection functions 1309 | CheckCollisionRecs :: proc(rec1, rec2: Rectangle) -> bool --- // Check collision between two rectangles 1310 | CheckCollisionCircles :: proc(center1: Vector2, radius1: f32, center2: Vector2, radius2: f32) -> bool --- // Check collision between two circles 1311 | CheckCollisionCircleRec :: proc(center: Vector2, radius: f32, rec: Rectangle) -> bool --- // Check collision between circle and rectangle 1312 | CheckCollisionPointRec :: proc(point: Vector2, rec: Rectangle) -> bool --- // Check if point is inside rectangle 1313 | CheckCollisionPointCircle :: proc(point, center: Vector2, radius: f32) -> bool --- // Check if point is inside circle 1314 | CheckCollisionPointTriangle :: proc(point: Vector2, p1, p2, p3: Vector2) -> bool --- // Check if point is inside a triangle 1315 | CheckCollisionPointPoly :: proc(point: Vector2, points: [^]Vector2, pointCount: cint) -> bool --- // Check if point is within a polygon described by array of vertices 1316 | CheckCollisionLines :: proc(startPos1, endPos1, startPos2, endPos2: Vector2, collisionPoint: [^]Vector2) -> bool --- // Check the collision between two lines defined by two points each, returns collision point by reference 1317 | CheckCollisionPointLine :: proc(point: Vector2, p1, p2: Vector2, threshold: cint) -> bool --- // Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold] 1318 | GetCollisionRec :: proc(rec1, rec2: Rectangle) -> Rectangle --- // Get collision rectangle for two rectangles collision 1319 | 1320 | 1321 | 1322 | // Image loading functions 1323 | // NOTE: These functions do not require GPU access 1324 | 1325 | LoadImage :: proc(fileName: cstring) -> Image --- // Load image from file into CPU memory (RAM) 1326 | LoadImageRaw :: proc(fileName: cstring, width, height: cint, format: PixelFormat, headerSize: cint) -> Image --- // Load image from RAW file data 1327 | LoadImageSvg :: proc(fileNameOrString: cstring, width, height: cint) -> Image --- // Load image from SVG file data or string with specified size 1328 | LoadImageAnim :: proc(fileName: cstring, frames: [^]cint) -> Image --- // Load image sequence from file (frames appended to image.data) 1329 | LoadImageFromMemory :: proc(fileType: cstring, fileData: rawptr, dataSize: cint) -> Image --- // Load image from memory buffer, fileType refers to extension: i.e. '.png' 1330 | LoadImageFromTexture :: proc(texture: Texture2D) -> Image --- // Load image from GPU texture data 1331 | LoadImageFromScreen :: proc() -> Image --- // Load image from screen buffer and (screenshot) 1332 | IsImageReady :: proc(image: Image) -> bool --- // Check if an image is ready 1333 | UnloadImage :: proc(image: Image) --- // Unload image from CPU memory (RAM) 1334 | ExportImage :: proc(image: Image, fileName: cstring) -> bool --- // Export image data to file, returns true on success 1335 | ExportImageToMemory :: proc(image: Image, fileType: cstring, fileSize: ^cint) -> rawptr --- // Export image to memory buffer 1336 | ExportImageAsCode :: proc(image: Image, fileName: cstring) -> bool --- // Export image as code file defining an array of bytes, returns true on success 1337 | 1338 | // Image generation functions 1339 | 1340 | GenImageColor :: proc(width, height: cint, color: Color) -> Image --- // Generate image: plain color 1341 | GenImageGradientLinear :: proc(width, height, direction: cint, start, end: Color) -> Image --- // Generate image: linear gradient, direction in degrees [0..360], 0=Vertical gradient 1342 | GenImageGradientRadial :: proc(width, height: cint, density: f32, inner, outer: Color) -> Image --- // Generate image: radial gradient 1343 | GenImageGradientSquare :: proc(width, height: cint, density: f32, inner, outer: Color) -> Image --- // Generate image: square gradient 1344 | GenImageChecked :: proc(width, height: cint, checksX, checksY: cint, col1, col2: Color) -> Image --- // Generate image: checked 1345 | GenImageWhiteNoise :: proc(width, height: cint, factor: f32) -> Image --- // Generate image: white noise 1346 | GenImagePerlinNoise :: proc(width, height: cint, offsetX, offsetY: cint, scale: f32) -> Image --- // Generate image: perlin noise 1347 | GenImageCellular :: proc(width, height: cint, tileSize: cint) -> Image --- // Generate image: cellular algorithm, bigger tileSize means bigger cells 1348 | GenImageText :: proc(width, height: cint, text: cstring) -> Image --- // Generate image: grayscale image from text data 1349 | 1350 | // Image manipulation functions 1351 | 1352 | ImageCopy :: proc(image: Image) -> Image --- // Create an image duplicate (useful for transformations) 1353 | ImageFromImage :: proc(image: Image, rec: Rectangle) -> Image --- // Create an image from another image piece 1354 | ImageText :: proc(text: cstring, fontSize: cint, color: Color) -> Image --- // Create an image from text (default font) 1355 | ImageTextEx :: proc(font: Font, text: cstring, fontSize: f32, spacing: f32, tint: Color) -> Image --- // Create an image from text (custom sprite font) 1356 | ImageFormat :: proc(image: ^Image, newFormat: PixelFormat) --- // Convert image data to desired format 1357 | ImageToPOT :: proc(image: ^Image, fill: Color) --- // Convert image to POT (power-of-two) 1358 | ImageCrop :: proc(image: ^Image, crop: Rectangle) --- // Crop an image to a defined rectangle 1359 | ImageAlphaCrop :: proc(image: ^Image, threshold: f32) --- // Crop image depending on alpha value 1360 | ImageAlphaClear :: proc(image: ^Image, color: Color, threshold: f32) --- // Clear alpha channel to desired color 1361 | ImageAlphaMask :: proc(image: ^Image, alphaMask: Image) --- // Apply alpha mask to image 1362 | ImageAlphaPremultiply :: proc(image: ^Image) --- // Premultiply alpha channel 1363 | ImageBlurGaussian :: proc(image: ^Image, blurSize: cint) --- // Apply Gaussian blur using a box blur approximation 1364 | ImageResize :: proc(image: ^Image, newWidth, newHeight: cint) --- // Resize image (Bicubic scaling algorithm) 1365 | ImageResizeNN :: proc(image: ^Image, newWidth, newHeight: cint) --- // Resize image (Nearest-Neighbor scaling algorithm) 1366 | ImageResizeCanvas :: proc(image: ^Image, newWidth, newHeight: cint, offsetX, offsetY: cint, fill: Color) --- // Resize canvas and fill with color 1367 | ImageMipmaps :: proc(image: ^Image) --- // Compute all mipmap levels for a provided image 1368 | ImageDither :: proc(image: ^Image, rBpp, gBpp, bBpp, aBpp: cint) --- // Dither image data to 16bpp or lower (Floyd-Steinberg dithering) 1369 | ImageFlipVertical :: proc(image: ^Image) --- // Flip image vertically 1370 | ImageFlipHorizontal :: proc(image: ^Image) --- // Flip image horizontally 1371 | ImageRotate :: proc(image: ^Image, degrees: cint) --- // Rotate image by input angle in degrees( -359 to 359) 1372 | ImageRotateCW :: proc(image: ^Image) --- // Rotate image clockwise 90deg 1373 | ImageRotateCCW :: proc(image: ^Image) --- // Rotate image counter-clockwise 90deg 1374 | ImageColorTint :: proc(image: ^Image, color: Color) --- // Modify image color: tint 1375 | ImageColorInvert :: proc(image: ^Image) --- // Modify image color: invert 1376 | ImageColorGrayscale :: proc(image: ^Image) --- // Modify image color: grayscale 1377 | ImageColorContrast :: proc(image: ^Image, contrast: f32) --- // Modify image color: contrast (-100 to 100) 1378 | ImageColorBrightness :: proc(image: ^Image, brightness: cint) --- // Modify image color: brightness (-255 to 255) 1379 | ImageColorReplace :: proc(image: ^Image, color, replace: Color) --- // Modify image color: replace color 1380 | LoadImageColors :: proc(image: Image) -> [^]Color --- // Load color data from image as a Color array (RGBA - 32bit) 1381 | LoadImagePalette :: proc(image: Image, maxPaletteSize: cint, colorCount: ^cint) -> [^]Color --- // Load colors palette from image as a Color array (RGBA - 32bit) 1382 | UnloadImageColors :: proc(colors: [^]Color) --- // Unload color data loaded with LoadImageColors() 1383 | UnloadImagePalette :: proc(colors: [^]Color) --- // Unload colors palette loaded with LoadImagePalette() 1384 | GetImageAlphaBorder :: proc(image: Image, threshold: f32) -> Rectangle --- // Get image alpha border rectangle 1385 | GetImageColor :: proc(image: Image, x, y: cint) -> Color --- // Get image pixel color at (x, y) position 1386 | 1387 | // Image drawing functions 1388 | // NOTE: Image software-rendering functions (CPU) 1389 | 1390 | ImageClearBackground :: proc(dst: ^Image, color: Color) --- // Clear image background with given color 1391 | ImageDrawPixel :: proc(dst: ^Image, posX, posY: cint, color: Color) --- // Draw pixel within an image 1392 | ImageDrawPixelV :: proc(dst: ^Image, position: Vector2, color: Color) --- // Draw pixel within an image (Vector version) 1393 | ImageDrawLine :: proc(dst: ^Image, startPosX, startPosY, endPosX, endPosY: cint, color: Color) --- // Draw line within an image 1394 | ImageDrawLineV :: proc(dst: ^Image, start, end: Vector2, color: Color) --- // Draw line within an image (Vector version) 1395 | ImageDrawCircle :: proc(dst: ^Image, centerX, centerY: cint, radius: cint, color: Color) --- // Draw a filled circle within an image 1396 | ImageDrawCircleV :: proc(dst: ^Image, center: Vector2, radius: cint, color: Color) --- // Draw a filled circle within an image (Vector version) 1397 | ImageDrawCircleLines :: proc(dst: ^Image, centerX, centerY: cint, radius: cint, color: Color) --- // Draw circle outline within an image 1398 | ImageDrawCircleLinesV :: proc(dst: ^Image, center: Vector2, radius: cint, color: Color) --- // Draw circle outline within an image (Vector version) 1399 | ImageDrawRectangle :: proc(dst: ^Image, posX, posY: cint, width, height: cint, color: Color) --- // Draw rectangle within an image 1400 | ImageDrawRectangleV :: proc(dst: ^Image, position, size: Vector2, color: Color) --- // Draw rectangle within an image (Vector version) 1401 | ImageDrawRectangleRec :: proc(dst: ^Image, rec: Rectangle, color: Color) --- // Draw rectangle within an image 1402 | ImageDrawRectangleLines :: proc(dst: ^Image, rec: Rectangle, thick: cint, color: Color) --- // Draw rectangle lines within an image 1403 | ImageDraw :: proc(dst: ^Image, src: Image, srcRec, dstRec: Rectangle, tint: Color) --- // Draw a source image within a destination image (tint applied to source) 1404 | ImageDrawText :: proc(dst: ^Image, text: cstring, posX, posY: cint, fontSize: cint, color: Color) --- // Draw text (using default font) within an image (destination) 1405 | ImageDrawTextEx :: proc(dst: ^Image, font: Font, text: cstring, position: Vector2, fontSize: f32, spacing: f32, tint: Color) --- // Draw text (custom sprite font) within an image (destination) 1406 | 1407 | // Texture loading functions 1408 | // NOTE: These functions require GPU access 1409 | 1410 | LoadTexture :: proc(fileName: cstring) -> Texture2D --- // Load texture from file into GPU memory (VRAM) 1411 | LoadTextureFromImage :: proc(image: Image) -> Texture2D --- // Load texture from image data 1412 | LoadTextureCubemap :: proc(image: Image, layout: CubemapLayout) -> TextureCubemap --- // Load cubemap from image, multiple image cubemap layouts supported 1413 | LoadRenderTexture :: proc(width, height: cint) -> RenderTexture2D --- // Load texture for rendering (framebuffer) 1414 | IsTextureReady :: proc(texture: Texture2D) -> bool --- // Check if a texture is ready 1415 | UnloadTexture :: proc(texture: Texture2D) --- // Unload texture from GPU memory (VRAM) 1416 | IsRenderTextureReady :: proc(target: RenderTexture2D) -> bool --- // Check if a render texture is ready 1417 | UnloadRenderTexture :: proc(target: RenderTexture2D) --- // Unload render texture from GPU memory (VRAM) 1418 | UpdateTexture :: proc(texture: Texture2D, pixels: rawptr) --- // Update GPU texture with new data 1419 | UpdateTextureRec :: proc(texture: Texture2D, rec: Rectangle, pixels: rawptr) --- // Update GPU texture rectangle with new data 1420 | 1421 | // Texture configuration functions 1422 | 1423 | GenTextureMipmaps :: proc(texture: ^Texture2D) --- // Generate GPU mipmaps for a texture 1424 | SetTextureFilter :: proc(texture: Texture2D, filter: TextureFilter) --- // Set texture scaling filter mode 1425 | SetTextureWrap :: proc(texture: Texture2D, wrap: TextureWrap) --- // Set texture wrapping mode 1426 | 1427 | // Texture drawing functions 1428 | DrawTexture :: proc(texture: Texture2D, posX, posY: cint, tint: Color) --- // Draw a Texture2D 1429 | DrawTextureV :: proc(texture: Texture2D, position: Vector2, tint: Color) --- // Draw a Texture2D with position defined as Vector2 1430 | DrawTextureEx :: proc(texture: Texture2D, position: Vector2, rotation: f32, scale: f32, tint: Color) --- // Draw a Texture2D with extended parameters 1431 | DrawTextureRec :: proc(texture: Texture2D, source: Rectangle, position: Vector2, tint: Color) --- // Draw a part of a texture defined by a rectangle 1432 | DrawTexturePro :: proc(texture: Texture2D, source, dest: Rectangle, origin: Vector2, rotation: f32, tint: Color) --- // Draw a part of a texture defined by a rectangle with 'pro' parameters 1433 | DrawTextureNPatch :: proc(texture: Texture2D, nPatchInfo: NPatchInfo, dest: Rectangle, origin: Vector2, rotation: f32, tint: Color) --- // Draws a texture (or part of it) that stretches or shrinks nicely 1434 | 1435 | // Color/pixel related functions 1436 | 1437 | Fade :: proc(color: Color, alpha: f32) -> Color --- // Get color with alpha applied, alpha goes from 0.0f to 1.0f 1438 | ColorToInt :: proc(color: Color) -> cuint --- // Get hexadecimal value for a Color 1439 | ColorNormalize :: proc(color: Color) -> Vector4 --- // Get Color normalized as float [0..1] 1440 | ColorFromNormalized :: proc(normalized: Vector4) -> Color --- // Get Color from normalized values [0..1] 1441 | ColorToHSV :: proc(color: Color) -> Vector3 --- // Get HSV values for a Color, hue [0..360], saturation/value [0..1] 1442 | ColorFromHSV :: proc(hue, saturation, value: f32) -> Color --- // Get a Color from HSV values, hue [0..360], saturation/value [0..1] 1443 | ColorTint :: proc(color, tint: Color) -> Color --- // Get color multiplied with another color 1444 | ColorBrightness :: proc(color: Color, factor: f32) -> Color --- // Get color with brightness correction, brightness factor goes from -1.0f to 1.0f 1445 | ColorContrast :: proc(color: Color, contrast: f32) -> Color --- // Get color with contrast correction, contrast values between -1.0f and 1.0f 1446 | ColorAlpha :: proc(color: Color, alpha: f32) -> Color --- // Get color with alpha applied, alpha goes from 0.0f to 1.0f 1447 | ColorAlphaBlend :: proc(dst, src, tint: Color) -> Color --- // Get src alpha-blended into dst color with tint 1448 | GetColor :: proc(hexValue: cuint) -> Color --- // Get Color structure from hexadecimal value 1449 | GetPixelColor :: proc(srcPtr: rawptr, format: PixelFormat) -> Color --- // Get Color from a source pixel pointer of certain format 1450 | SetPixelColor :: proc(dstPtr: rawptr, color: Color, format: PixelFormat) --- // Set color formatted into destination pixel pointer 1451 | GetPixelDataSize :: proc(width, height: cint, format: PixelFormat) -> cint --- // Get pixel data size in bytes for certain format 1452 | 1453 | 1454 | 1455 | 1456 | //------------------------------------------------------------------------------------ 1457 | // Font Loading and Text Drawing Functions (Module: text) 1458 | //------------------------------------------------------------------------------------ 1459 | 1460 | // Font loading/unloading functions 1461 | 1462 | GetFontDefault :: proc() -> Font --- // Get the default Font 1463 | LoadFont :: proc(fileName: cstring) -> Font --- // Load font from file into GPU memory (VRAM) 1464 | LoadFontEx :: proc(fileName: cstring, fontSize: cint, codepoints: [^]rune, codepointCount: cint) -> Font --- // Load font from file with extended parameters, use NULL for codepoints and 0 for codepointCount to load the default character set 1465 | LoadFontFromImage :: proc(image: Image, key: Color, firstChar: rune) -> Font --- // Load font from Image (XNA style) 1466 | LoadFontFromMemory :: proc(fileType: cstring, fileData: rawptr, dataSize: cint, fontSize: cint, codepoints: [^]rune, codepointCount: cint) -> Font --- // Load font from memory buffer, fileType refers to extension: i.e. '.ttf' 1467 | IsFontReady :: proc(font: Font) -> bool --- // Check if a font is ready 1468 | LoadFontData :: proc(fileData: rawptr, dataSize: cint, fontSize: cint, codepoints: [^]rune, codepointCount: cint, type: FontType) -> [^]GlyphInfo --- // Load font data for further use 1469 | GenImageFontAtlas :: proc(glyphs: [^]GlyphInfo, glyphRecs: ^[^]Rectangle, codepointCount: cint, fontSize: cint, padding: cint, packMethod: cint) -> Image --- // Generate image font atlas using chars info 1470 | UnloadFontData :: proc(glyphs: [^]GlyphInfo, glyphCount: cint) --- // Unload font chars info data (RAM) 1471 | UnloadFont :: proc(font: Font) --- // Unload font from GPU memory (VRAM) 1472 | ExportFontAsCode :: proc(font: Font, fileName: cstring) -> bool --- // Export font as code file, returns true on success 1473 | 1474 | // Text drawing functions 1475 | 1476 | DrawFPS :: proc(posX, posY: cint) --- // Draw current FPS 1477 | DrawText :: proc(text: cstring, posX, posY: cint, fontSize: cint, color: Color) --- // Draw text (using default font) 1478 | DrawTextEx :: proc(font: Font, text: cstring, position: Vector2, fontSize: f32, spacing: f32, tint: Color) --- // Draw text using font and additional parameters 1479 | DrawTextPro :: proc(font: Font, text: cstring, position, origin: Vector2, rotation: f32, fontSize: f32, spacing: f32, tint: Color) --- // Draw text using Font and pro parameters (rotation) 1480 | DrawTextCodepoint :: proc(font: Font, codepoint: rune, position: Vector2, fontSize: f32, tint: Color) --- // Draw one character (codepoint) 1481 | DrawTextCodepoints :: proc(font: Font, codepoints: [^]rune, codepointCount: cint, position: Vector2, fontSize: f32, spacing: f32, tint: Color) --- // Draw multiple character (codepoint) 1482 | 1483 | // Text font info functions 1484 | 1485 | SetTextLineSpacing :: proc(spacing: cint) --- // Set vertical line spacing when drawing with line-breaks 1486 | MeasureText :: proc(text: cstring, fontSize: cint) -> cint --- // Measure string width for default font 1487 | MeasureTextEx :: proc(font: Font, text: cstring, fontSize: f32, spacing: f32) -> Vector2 --- // Measure string size for Font 1488 | GetGlyphIndex :: proc(font: Font, codepoint: rune) -> cint --- // Get glyph index position in font for a codepoint (unicode character), fallback to '?' if not found 1489 | GetGlyphInfo :: proc(font: Font, codepoint: rune) -> GlyphInfo --- // Get glyph font info data for a codepoint (unicode character), fallback to '?' if not found 1490 | GetGlyphAtlasRec :: proc(font: Font, codepoint: rune) -> Rectangle --- // Get glyph rectangle in font atlas for a codepoint (unicode character), fallback to '?' if not found 1491 | 1492 | // Text codepoints management functions (unicode characters) 1493 | 1494 | LoadUTF8 :: proc(codepoints: [^]rune, length: cint) -> [^]byte --- // Load UTF-8 text encoded from codepoints array 1495 | UnloadUTF8 :: proc(text: [^]byte) --- // Unload UTF-8 text encoded from codepoints array 1496 | LoadCodepoints :: proc(text: rawptr, count: ^cint) -> [^]rune --- // Load all codepoints from a UTF-8 text string, codepoints count returned by parameter 1497 | UnloadCodepoints :: proc(codepoints: [^]rune) --- // Unload codepoints data from memory 1498 | GetCodepointCount :: proc(text : cstring) -> cint --- // Get total number of codepoints in a UTF-8 encoded string 1499 | GetCodepoint :: proc(text: cstring, codepointSize: ^cint) -> rune --- // Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure 1500 | GetCodepointNext :: proc(text: cstring, codepointSize: ^cint) -> rune --- // Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure 1501 | GetCodepointPrevious :: proc(text: cstring, codepointSize: ^cint) -> rune --- // Get previous codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure 1502 | CodepointToUTF8 :: proc(codepoint: rune, utf8Size: ^cint) -> cstring --- // Encode one codepoint into UTF-8 byte array (array length returned as parameter) 1503 | 1504 | // Text strings management functions (no UTF-8 strings, only byte chars) 1505 | // NOTE: Some strings allocate memory internally for returned strings, just be careful! 1506 | 1507 | TextCopy :: proc(dst: [^]byte, src: cstring) -> cint --- // Copy one string to another, returns bytes copied 1508 | TextIsEqual :: proc(text1, text2: cstring) -> bool --- // Check if two text string are equal 1509 | TextLength :: proc(text: cstring) -> cuint --- // Get text length, checks for '\0' ending 1510 | 1511 | // TextFormat is defined at the bottom of this file 1512 | 1513 | TextSubtext :: proc(text: cstring, position: cint, length: cint) -> cstring --- // Get a piece of a text string 1514 | TextReplace :: proc(text: [^]byte, replace, by: cstring) -> [^]byte --- // Replace text string (WARNING: memory must be freed!) 1515 | TextInsert :: proc(text, insert: cstring, position: cint) -> [^]byte --- // Insert text in a position (WARNING: memory must be freed!) 1516 | TextJoin :: proc(textList: [^]cstring, count: cint, delimiter: cstring) -> cstring --- // Join text strings with delimiter 1517 | TextSplit :: proc(text: cstring, delimiter: byte, count: ^cint) -> [^]cstring --- // Split text into multiple strings 1518 | TextAppend :: proc(text: [^]byte, append: cstring, position: ^cint) --- // Append text at specific position and move cursor! 1519 | TextFindIndex :: proc(text, find: cstring) -> cint --- // Find first text occurrence within a string 1520 | TextToUpper :: proc(text: cstring) -> cstring --- // Get upper case version of provided string 1521 | TextToLower :: proc(text: cstring) -> cstring --- // Get lower case version of provided string 1522 | TextToPascal :: proc(text: cstring) -> cstring --- // Get Pascal case notation version of provided string 1523 | TextToInteger :: proc(text: cstring) -> cint --- // Get integer value from text (negative values not supported) 1524 | 1525 | 1526 | //------------------------------------------------------------------------------------ 1527 | // Basic 3d Shapes Drawing Functions (Module: models) 1528 | //------------------------------------------------------------------------------------ 1529 | 1530 | // Basic geometric 3D shapes drawing functions 1531 | 1532 | DrawLine3D :: proc(startPos, endPos: Vector3, color: Color) --- // Draw a line in 3D world space 1533 | DrawPoint3D :: proc(position: Vector3, color: Color) --- // Draw a point in 3D space, actually a small line 1534 | DrawCircle3D :: proc(center: Vector3, radius: f32, rotationAxis: Vector3, rotationAngle: f32, color: Color) --- // Draw a circle in 3D world space 1535 | DrawTriangle3D :: proc(v1, v2, v3: Vector3, color: Color) --- // Draw a color-filled triangle (vertex in counter-clockwise order!) 1536 | DrawTriangleStrip3D :: proc(points: [^]Vector3, pointCount: cint, color: Color) --- // Draw a triangle strip defined by points 1537 | DrawCube :: proc(position: Vector3, width, height, length: f32, color: Color) --- // Draw cube 1538 | DrawCubeV :: proc(position: Vector3, size: Vector3, color: Color) --- // Draw cube (Vector version) 1539 | DrawCubeWires :: proc(position: Vector3, width, height, length: f32, color: Color) --- // Draw cube wires 1540 | DrawCubeWiresV :: proc(position, size: Vector3, color: Color) --- // Draw cube wires (Vector version) 1541 | DrawSphere :: proc(centerPos: Vector3, radius: f32, color: Color) --- // Draw sphere 1542 | DrawSphereEx :: proc(centerPos: Vector3, radius: f32, rings, slices: cint, color: Color) --- // Draw sphere with extended parameters 1543 | DrawSphereWires :: proc(centerPos: Vector3, radius: f32, rings, slices: cint, color: Color) --- // Draw sphere wires 1544 | DrawCylinder :: proc(position: Vector3, radiusTop, radiusBottom: f32, height: f32, slices: cint, color: Color) --- // Draw a cylinder/cone 1545 | DrawCylinderEx :: proc(startPos, endPos: Vector3, startRadius, endRadius: f32, sides: cint, color: Color) --- // Draw a cylinder with base at startPos and top at endPos 1546 | DrawCylinderWires :: proc(position: Vector3, radiusTop, radiusBottom, height: f32, slices: cint, color: Color) --- // Draw a cylinder/cone wires 1547 | DrawCylinderWiresEx :: proc(startPos, endPos: Vector3, startRadius, endRadius: f32, sides: cint, color: Color) --- // Draw a cylinder wires with base at startPos and top at endPos 1548 | DrawCapsule :: proc(startPos, endPos: Vector3, radius: f32, slices, rings: cint, color: Color) --- // Draw a capsule with the center of its sphere caps at startPos and endPos 1549 | DrawCapsuleWires :: proc(startPos, endPos: Vector3, radius: f32, slices, rings: cint, color: Color) --- // Draw capsule wireframe with the center of its sphere caps at startPos and endPos 1550 | DrawPlane :: proc(centerPos: Vector3, size: Vector2, color: Color) --- // Draw a plane XZ 1551 | DrawRay :: proc(ray: Ray, color: Color) --- // Draw a ray line 1552 | DrawGrid :: proc(slices: cint, spacing: f32) --- // Draw a grid (centered at (0, 0, 0)) 1553 | 1554 | //------------------------------------------------------------------------------------ 1555 | // Model 3d Loading and Drawing Functions (Module: models) 1556 | //------------------------------------------------------------------------------------ 1557 | 1558 | // Model management functions 1559 | 1560 | LoadModel :: proc(fileName: cstring) -> Model --- // Load model from files (meshes and materials) 1561 | LoadModelFromMesh :: proc(mesh: Mesh) -> Model --- // Load model from generated mesh (default material) 1562 | IsModelReady :: proc(model: Model) -> bool --- // Check if a model is ready 1563 | UnloadModel :: proc(model: Model) --- // Unload model (including meshes) from memory (RAM and/or VRAM) 1564 | GetModelBoundingBox :: proc(model: Model) -> BoundingBox --- // Compute model bounding box limits (considers all meshes) 1565 | 1566 | // Model drawing functions 1567 | 1568 | DrawModel :: proc(model: Model, position: Vector3, scale: f32, tint: Color) --- // Draw a model (with texture if set) 1569 | DrawModelEx :: proc(model: Model, position: Vector3, rotationAxis: Vector3, rotationAngle: f32, scale: Vector3, tint: Color) --- // Draw a model with extended parameters 1570 | DrawModelWires :: proc(model: Model, position: Vector3, scale: f32, tint: Color) --- // Draw a model wires (with texture if set) 1571 | DrawModelWiresEx :: proc(model: Model, position: Vector3, rotationAxis: Vector3, rotationAngle: f32, scale: Vector3, tint: Color) --- // Draw a model wires (with texture if set) with extended parameters 1572 | DrawBoundingBox :: proc(box: BoundingBox, color: Color) --- // Draw bounding box (wires) 1573 | DrawBillboard :: proc(camera: Camera, texture: Texture2D, position: Vector3, size: f32, tint: Color) --- // Draw a billboard texture 1574 | DrawBillboardRec :: proc(camera: Camera, texture: Texture2D, source: Rectangle, position: Vector3, size: Vector2, tint: Color) --- // Draw a billboard texture defined by source 1575 | DrawBillboardPro :: proc(camera: Camera, texture: Texture2D, source: Rectangle, position: Vector3, up: Vector3, size: Vector2, origin: Vector2, rotation: f32, tint: Color) --- // Draw a billboard texture defined by source and rotation 1576 | 1577 | // Mesh management functions 1578 | 1579 | UploadMesh :: proc(mesh: ^Mesh, is_dynamic: bool) --- // Upload mesh vertex data in GPU and provide VAO/VBO ids 1580 | UpdateMeshBuffer :: proc(mesh: Mesh, index: cint, data: rawptr, dataSize: cint, offset: cint) --- // Update mesh vertex data in GPU for a specific buffer index 1581 | UnloadMesh :: proc(mesh: Mesh) --- // Unload mesh data from CPU and GPU 1582 | DrawMesh :: proc(mesh: Mesh, material: Material, transform: Matrix) --- // Draw a 3d mesh with material and transform 1583 | DrawMeshInstanced :: proc(mesh: Mesh, material: Material, transforms: [^]Matrix, instances: cint) --- // Draw multiple mesh instances with material and different transforms 1584 | ExportMesh :: proc(mesh: Mesh, fileName: cstring) -> bool --- // Export mesh data to file, returns true on success 1585 | GetMeshBoundingBox :: proc(mesh: Mesh) -> BoundingBox --- // Compute mesh bounding box limits 1586 | GenMeshTangents :: proc(mesh: ^Mesh) --- // Compute mesh tangents 1587 | 1588 | // Mesh generation functions 1589 | 1590 | GenMeshPoly :: proc(sides: cint, radius: f32) -> Mesh --- // Generate polygonal mesh 1591 | GenMeshPlane :: proc(width, lengthL: f32, resX, resZ: cint) -> Mesh --- // Generate plane mesh (with subdivisions) 1592 | GenMeshCube :: proc(width, height, length: f32) -> Mesh --- // Generate cuboid mesh 1593 | GenMeshSphere :: proc(radius: f32, rings, slices: cint) -> Mesh --- // Generate sphere mesh (standard sphere) 1594 | GenMeshHemiSphere :: proc(radius: f32, rings, slices: cint) -> Mesh --- // Generate half-sphere mesh (no bottom cap) 1595 | GenMeshCylinder :: proc(radius, height: f32, slices: cint) -> Mesh --- // Generate cylinder mesh 1596 | GenMeshCone :: proc(radius, height: f32, slices: cint) -> Mesh --- // Generate cone/pyramid mesh 1597 | GenMeshTorus :: proc(radius, size: f32, radSeg, sides: cint) -> Mesh --- // Generate torus mesh 1598 | GenMeshKnot :: proc(radius, size: f32, radSeg, sides: cint) -> Mesh --- // Generate trefoil knot mesh 1599 | GenMeshHeightmap :: proc(heightmap: Image, size: Vector3) -> Mesh --- // Generate heightmap mesh from image data 1600 | GenMeshCubicmap :: proc(cubicmap: Image, cubeSize: Vector3) -> Mesh --- // Generate cubes-based map mesh from image data 1601 | 1602 | // Material loading/unloading functions 1603 | 1604 | LoadMaterials :: proc(fileName: cstring, materialCount: ^cint) -> [^]Material --- // Load materials from model file 1605 | LoadMaterialDefault :: proc() -> Material --- // Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps) 1606 | IsMaterialReady :: proc(material: Material) -> bool --- // Check if a material is ready 1607 | UnloadMaterial :: proc(material: Material) --- // Unload material from GPU memory (VRAM) 1608 | SetMaterialTexture :: proc(material: ^Material, mapType: MaterialMapIndex, texture: Texture2D) --- // Set texture for a material map type (MATERIAL_MAP_DIFFUSE, MATERIAL_MAP_SPECULAR...) 1609 | SetModelMeshMaterial :: proc(model: ^Model, meshId: cint, materialId: cint) --- // Set material for a mesh 1610 | 1611 | // Model animations loading/unloading functions 1612 | 1613 | LoadModelAnimations :: proc(fileName: cstring, animCount: ^cint) -> [^]ModelAnimation --- // Load model animations from file 1614 | UpdateModelAnimation :: proc(model: Model, anim: ModelAnimation, frame: cint) --- // Update model animation pose 1615 | UnloadModelAnimation :: proc(anim: ModelAnimation) --- // Unload animation data 1616 | UnloadModelAnimations :: proc(animations: [^]ModelAnimation, animCount: cint) --- // Unload animation array data 1617 | IsModelAnimationValid :: proc(model: Model, anim: ModelAnimation) -> bool --- // Check model animation skeleton match 1618 | 1619 | // Collision detection functions 1620 | 1621 | CheckCollisionSpheres :: proc(center1: Vector3, radius1: f32, center2: Vector3, radius2: f32) -> bool --- // Check collision between two spheres 1622 | CheckCollisionBoxes :: proc(box1, box2: BoundingBox) -> bool --- // Check collision between two bounding boxes 1623 | CheckCollisionBoxSphere :: proc(box: BoundingBox, center: Vector3, radius: f32) -> bool --- // Check collision between box and sphere 1624 | GetRayCollisionSphere :: proc(ray: Ray, center: Vector3, radius: f32) -> RayCollision --- // Get collision info between ray and sphere 1625 | GetRayCollisionBox :: proc(ray: Ray, box: BoundingBox) -> RayCollision --- // Get collision info between ray and box 1626 | GetRayCollisionMesh :: proc(ray: Ray, mesh: Mesh, transform: Matrix) -> RayCollision --- // Get collision info between ray and mesh 1627 | GetRayCollisionTriangle :: proc(ray: Ray, p1, p2, p3: Vector3) -> RayCollision --- // Get collision info between ray and triangle 1628 | GetRayCollisionQuad :: proc(ray: Ray, p1, p2, p3, p4: Vector3) -> RayCollision --- // Get collision info between ray and quad 1629 | 1630 | //------------------------------------------------------------------------------------ 1631 | // Audio Loading and Playing Functions (Module: audio) 1632 | //------------------------------------------------------------------------------------ 1633 | 1634 | // Audio device management functions 1635 | 1636 | InitAudioDevice :: proc() --- // Initialize audio device and context 1637 | CloseAudioDevice :: proc() --- // Close the audio device and context 1638 | IsAudioDeviceReady :: proc() -> bool --- // Check if audio device has been initialized successfully 1639 | SetMasterVolume :: proc(volume: f32) --- // Set master volume (listener) 1640 | GetMasterVolume :: proc() -> f32 --- // Get master volume (listener) 1641 | 1642 | // Wave/Sound loading/unloading functions 1643 | 1644 | LoadWave :: proc(fileName: cstring) -> Wave --- // Load wave data from file 1645 | LoadWaveFromMemory :: proc(fileType: cstring, fileData: rawptr, dataSize: cint) -> Wave --- // Load wave from memory buffer, fileType refers to extension: i.e. '.wav' 1646 | IsWaveReady :: proc(wave: Wave) -> bool --- // Checks if wave data is ready 1647 | LoadSound :: proc(fileName: cstring) -> Sound --- // Load sound from file 1648 | LoadSoundFromWave :: proc(wave: Wave) -> Sound --- // Load sound from wave data 1649 | LoadSoundAlias :: proc(source: Sound) -> Sound --- // Create a new sound that shares the same sample data as the source sound, does not own the sound data 1650 | IsSoundReady :: proc(sound: Sound) -> bool --- // Checks if a sound is ready 1651 | UpdateSound :: proc(sound: Sound, data: rawptr, frameCount: cint) --- // Update sound buffer with new data 1652 | UnloadWave :: proc(wave: Wave) --- // Unload wave data 1653 | UnloadSound :: proc(sound: Sound) --- // Unload sound 1654 | UnloadSoundAlias :: proc(alias: Sound) --- // Unload a sound alias (does not deallocate sample data) 1655 | ExportWave :: proc(wave: Wave, fileName: cstring) -> bool --- // Export wave data to file, returns true on success 1656 | ExportWaveAsCode :: proc(wave: Wave, fileName: cstring) -> bool --- // Export wave sample data to code (.h), returns true on success 1657 | 1658 | // Wave/Sound management functions 1659 | 1660 | PlaySound :: proc(sound: Sound) --- // Play a sound 1661 | StopSound :: proc(sound: Sound) --- // Stop playing a sound 1662 | PauseSound :: proc(sound: Sound) --- // Pause a sound 1663 | ResumeSound :: proc(sound: Sound) --- // Resume a paused sound 1664 | IsSoundPlaying :: proc(sound: Sound) -> bool --- // Check if a sound is currently playing 1665 | SetSoundVolume :: proc(sound: Sound, volume: f32) --- // Set volume for a sound (1.0 is max level) 1666 | SetSoundPitch :: proc(sound: Sound, pitch: f32) --- // Set pitch for a sound (1.0 is base level) 1667 | SetSoundPan :: proc(sound: Sound, pan: f32) --- // Set pan for a sound (0.5 is center) 1668 | WaveCopy :: proc(wave: Wave) -> Wave --- // Copy a wave to a new wave 1669 | WaveCrop :: proc(wave: ^Wave, initSample, finalSample: cint) --- // Crop a wave to defined samples range 1670 | WaveFormat :: proc(wave: ^Wave, sampleRate, sampleSize: cint, channels: cint) --- // Convert wave data to desired format 1671 | LoadWaveSamples :: proc(wave: Wave) -> [^]f32 --- // Load samples data from wave as a 32bit float data array 1672 | UnloadWaveSamples :: proc(samples: [^]f32) --- // Unload samples data loaded with LoadWaveSamples() 1673 | 1674 | 1675 | // Music management functions 1676 | 1677 | LoadMusicStream :: proc(fileName: cstring) -> Music --- // Load music stream from file 1678 | LoadMusicStreamFromMemory :: proc(fileType: cstring, data: rawptr, dataSize: cint) -> Music --- // Load music stream from data 1679 | IsMusicReady :: proc(music: Music) -> bool --- // Checks if a music stream is ready 1680 | UnloadMusicStream :: proc(music: Music) --- // Unload music stream 1681 | PlayMusicStream :: proc(music: Music) --- // Start music playing 1682 | IsMusicStreamPlaying :: proc(music: Music) -> bool --- // Check if music is playing 1683 | UpdateMusicStream :: proc(music: Music) --- // Updates buffers for music streaming 1684 | StopMusicStream :: proc(music: Music) --- // Stop music playing 1685 | PauseMusicStream :: proc(music: Music) --- // Pause music playing 1686 | ResumeMusicStream :: proc(music: Music) --- // Resume playing paused music 1687 | SeekMusicStream :: proc(music: Music, position: f32) --- // Seek music to a position (in seconds) 1688 | SetMusicVolume :: proc(music: Music, volume: f32) --- // Set volume for music (1.0 is max level) 1689 | SetMusicPitch :: proc(music: Music, pitch: f32) --- // Set pitch for a music (1.0 is base level) 1690 | SetMusicPan :: proc(music: Music, pan: f32) --- // Set pan for a music (0.5 is center) 1691 | GetMusicTimeLength :: proc(music: Music) -> f32 --- // Get music time length (in seconds) 1692 | GetMusicTimePlayed :: proc(music: Music) -> f32 --- // Get current music time played (in seconds) 1693 | 1694 | // AudioStream management functions 1695 | 1696 | LoadAudioStream :: proc(sampleRate, sampleSize: cuint, channels: cuint) -> AudioStream --- // Load audio stream (to stream raw audio pcm data) 1697 | IsAudioStreamReady :: proc(stream: AudioStream) -> bool --- // Checks if an audio stream is ready 1698 | UnloadAudioStream :: proc(stream: AudioStream) --- // Unload audio stream and free memory 1699 | UpdateAudioStream :: proc(stream: AudioStream, data: rawptr, frameCount: cint) --- // Update audio stream buffers with data 1700 | IsAudioStreamProcessed :: proc(stream: AudioStream) -> bool --- // Check if any audio stream buffers requires refill 1701 | PlayAudioStream :: proc(stream: AudioStream) --- // Play audio stream 1702 | PauseAudioStream :: proc(stream: AudioStream) --- // Pause audio stream 1703 | ResumeAudioStream :: proc(stream: AudioStream) --- // Resume audio stream 1704 | IsAudioStreamPlaying :: proc(stream: AudioStream) -> bool --- // Check if audio stream is playing 1705 | StopAudioStream :: proc(stream: AudioStream) --- // Stop audio stream 1706 | SetAudioStreamVolume :: proc(stream: AudioStream, volume: f32) --- // Set volume for audio stream (1.0 is max level) 1707 | SetAudioStreamPitch :: proc(stream: AudioStream, pitch: f32) --- // Set pitch for audio stream (1.0 is base level) 1708 | SetAudioStreamPan :: proc(stream: AudioStream, pan: f32) --- // Set pan for audio stream (0.5 is centered) 1709 | SetAudioStreamBufferSizeDefault :: proc(size: cint) --- // Default size for new audio streams 1710 | SetAudioStreamCallback :: proc(stream: AudioStream, callback: AudioCallback) --- // Audio thread callback to request new data 1711 | 1712 | AttachAudioStreamProcessor :: proc(stream: AudioStream, processor: AudioCallback) --- // Attach audio stream processor to stream, receives the samples as s 1713 | DetachAudioStreamProcessor :: proc(stream: AudioStream, processor: AudioCallback) --- // Detach audio stream processor from stream 1714 | 1715 | AttachAudioMixedProcessor :: proc(processor: AudioCallback) --- // Attach audio stream processor to the entire audio pipeline, receives the samples as s 1716 | DetachAudioMixedProcessor :: proc(processor: AudioCallback) --- // Detach audio stream processor from the entire audio pipeline 1717 | } 1718 | 1719 | // Workaround for broken IsMouseButtonUp in Raylib 5.0. 1720 | when VERSION == "5.0" { 1721 | IsMouseButtonUp :: proc "c" (button: MouseButton) -> bool { 1722 | return !IsMouseButtonDown(button) 1723 | } 1724 | } else { 1725 | #panic("Remove this this when block and everything inside it for Raylib > 5.0. It's just here to fix a bug in Raylib 5.0. See IsMouseButtonUp inside 'foreign lib {' block.") 1726 | } 1727 | 1728 | // Check if a gesture have been detected 1729 | IsGestureDetected :: proc "c" (gesture: Gesture) -> bool { 1730 | @(default_calling_convention="c") 1731 | foreign { 1732 | IsGestureDetected :: proc "c" (gesture: Gestures) -> bool --- 1733 | } 1734 | return IsGestureDetected({gesture}) 1735 | } 1736 | 1737 | 1738 | // Text formatting with variables (sprintf style) 1739 | TextFormat :: proc(text: cstring, args: ..any) -> cstring { 1740 | @static buffers: [MAX_TEXTFORMAT_BUFFERS][MAX_TEXT_BUFFER_LENGTH]byte 1741 | @static index: u32 1742 | 1743 | buffer := buffers[index][:] 1744 | mem.zero_slice(buffer) 1745 | 1746 | index = (index+1)%MAX_TEXTFORMAT_BUFFERS 1747 | 1748 | str := fmt.bprintf(buffer[:len(buffer)-1], string(text), ..args) 1749 | buffer[len(str)] = 0 1750 | 1751 | return cstring(raw_data(buffer)) 1752 | } 1753 | 1754 | // Text formatting with variables (sprintf style) and allocates (must be freed with 'MemFree') 1755 | TextFormatAlloc :: proc(text: cstring, args: ..any) -> cstring { 1756 | str := fmt.tprintf(string(text), ..args) 1757 | return strings.clone_to_cstring(str, MemAllocator()) 1758 | } 1759 | 1760 | 1761 | MemAllocator :: proc "contextless" () -> mem.Allocator { 1762 | return mem.Allocator{MemAllocatorProc, nil} 1763 | } 1764 | 1765 | MemAllocatorProc :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode, 1766 | size, alignment: int, 1767 | old_memory: rawptr, old_size: int, location := #caller_location) -> (data: []byte, err: mem.Allocator_Error) { 1768 | switch mode { 1769 | case .Alloc, .Alloc_Non_Zeroed: 1770 | ptr := MemAlloc(cuint(size)) 1771 | if ptr == nil { 1772 | err = .Out_Of_Memory 1773 | return 1774 | } 1775 | data = mem.byte_slice(ptr, size) 1776 | return 1777 | case .Free: 1778 | MemFree(old_memory) 1779 | return nil, nil 1780 | 1781 | case .Resize, .Resize_Non_Zeroed: 1782 | ptr := MemRealloc(old_memory, cuint(size)) 1783 | if ptr == nil { 1784 | err = .Out_Of_Memory 1785 | return 1786 | } 1787 | data = mem.byte_slice(ptr, size) 1788 | return 1789 | 1790 | case .Free_All, .Query_Features, .Query_Info: 1791 | return nil, .Mode_Not_Implemented 1792 | } 1793 | return nil, .Mode_Not_Implemented 1794 | } 1795 | --------------------------------------------------------------------------------