raylib.odin 129 KB

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