raylib.odin 129 KB

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