mirror of
https://github.com/odin-lang/Odin.git
synced 2026-07-11 02:19:30 +00:00
added initial 6.0 bindings
This commit is contained in:
2
vendor/raylib/LICENSE
vendored
2
vendor/raylib/LICENSE
vendored
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2013-2023 Ramon Santamaria (@raysan5)
|
||||
Copyright (c) 2013-2026 Ramon Santamaria (@raysan5)
|
||||
|
||||
This software is provided "as-is", without any express or implied warranty. In no event
|
||||
will the authors be held liable for any damages arising from the use of this software.
|
||||
|
||||
89
vendor/raylib/README.md
vendored
89
vendor/raylib/README.md
vendored
@@ -1,8 +1,8 @@
|
||||
<img align="left" src="https://github.com/raysan5/raylib/blob/master/logo/raylib_logo_animation.gif" width="288px">
|
||||
<img align="left" style="width:260px" src="https://github.com/raysan5/raylib/blob/master/logo/raylib_logo_animation.gif" width="288px">
|
||||
|
||||
**raylib is a simple and easy-to-use library to enjoy videogames programming.**
|
||||
|
||||
raylib is highly inspired by Borland BGI graphics lib and by XNA framework and it's specially well suited for prototyping, tooling, graphical applications, embedded systems and education.
|
||||
raylib is highly inspired by Borland BGI graphics lib and by XNA framework and it's especially well suited for prototyping, tooling, graphical applications, embedded systems and education.
|
||||
|
||||
*NOTE for ADVENTURERS: raylib is a programming library to enjoy videogames programming; no fancy interface, no visual helpers, no debug button... just coding in the most pure spartan-programmers way.*
|
||||
|
||||
@@ -14,75 +14,76 @@ Ready to learn? Jump to [code examples!](https://www.raylib.com/examples.html)
|
||||
|
||||
[](https://github.com/raysan5/raylib/releases)
|
||||
[](https://github.com/raysan5/raylib/stargazers)
|
||||
[](https://github.com/raysan5/raylib/commits/master)
|
||||
[](https://github.com/raysan5/raylib/commits/master)
|
||||
[](https://github.com/sponsors/raysan5)
|
||||
[](https://repology.org/project/raylib/versions)
|
||||
[](LICENSE)
|
||||
|
||||
[](https://discord.gg/raylib)
|
||||
[](https://www.reddit.com/r/raylib/)
|
||||
[](https://www.reddit.com/r/raylib/)
|
||||
[](https://www.youtube.com/c/raylib)
|
||||
[](https://www.twitch.tv/raysan5)
|
||||
|
||||
[](https://github.com/raysan5/raylib/actions?query=workflow%3AWindows)
|
||||
[](https://github.com/raysan5/raylib/actions?query=workflow%3ALinux)
|
||||
[](https://github.com/raysan5/raylib/actions?query=workflow%3AmacOS)
|
||||
[](https://github.com/raysan5/raylib/actions?query=workflow%3AAndroid)
|
||||
[](https://github.com/raysan5/raylib/actions?query=workflow%3AWebAssembly)
|
||||
[](https://github.com/raysan5/raylib/actions/workflows/build_windows.yml)
|
||||
[](https://github.com/raysan5/raylib/actions/workflows/build_linux.yml)
|
||||
[](https://github.com/raysan5/raylib/actions/workflows/build_macos.yml)
|
||||
[](https://github.com/raysan5/raylib/actions/workflows/build_webassembly.yml)
|
||||
|
||||
[](https://github.com/raysan5/raylib/actions?query=workflow%3ACMakeBuilds)
|
||||
[](https://github.com/raysan5/raylib/actions/workflows/windows_examples.yml)
|
||||
[](https://github.com/raysan5/raylib/actions/workflows/linux_examples.yml)
|
||||
[](https://github.com/raysan5/raylib/actions/workflows/build_cmake.yml)
|
||||
[](https://github.com/raysan5/raylib/actions/workflows/build_examples_windows.yml)
|
||||
[](https://github.com/raysan5/raylib/actions/workflows/build_examples_linux.yml)
|
||||
|
||||
features
|
||||
--------
|
||||
- **NO external dependencies**, all required libraries are [bundled into raylib](https://github.com/raysan5/raylib/tree/master/src/external)
|
||||
- **NO external dependencies**, all required libraries are [included into raylib](https://github.com/raysan5/raylib/tree/master/src/external)
|
||||
- Multiple platforms supported: **Windows, Linux, MacOS, RPI, Android, HTML5... and more!**
|
||||
- Written in plain C code (C99) using PascalCase/camelCase notation
|
||||
- Hardware accelerated with OpenGL (**1.1, 2.1, 3.3, 4.3, ES 2.0 or ES 3.0**)
|
||||
- Hardware accelerated with OpenGL: **1.1, 2.1, 3.3, 4.3, ES 2.0, ES 3.0**
|
||||
- **Unique OpenGL abstraction layer** (usable as standalone module): [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h)
|
||||
- Multiple **Fonts** formats supported (TTF, Image fonts, AngelCode fonts)
|
||||
- **Software Renderer** backend (no OpenGL required!): [rlsw](https://github.com/raysan5/raylib/blob/master/src/external/rlsw.h)
|
||||
- Multiple **Fonts** formats supported (TTF, OTF, FNT, BDF, sprite fonts)
|
||||
- Multiple texture formats supported, including **compressed formats** (DXT, ETC, ASTC)
|
||||
- **Full 3D support**, including 3D Shapes, Models, Billboards, Heightmaps and more!
|
||||
- **Full 3D support**, including 3D Shapes, Models, Billboards, Heightmaps and more!
|
||||
- Flexible Materials system, supporting classic maps and **PBR maps**
|
||||
- **Animated 3D models** supported (skeletal bones animation) (IQM)
|
||||
- Shaders support, including model and **postprocessing** shaders.
|
||||
- **Animated 3D models** supported (skeletal bones animation) (IQM, M3D, glTF)
|
||||
- Shaders support, including model shaders and **postprocessing** shaders
|
||||
- **Powerful math module** for Vector, Matrix and Quaternion operations: [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h)
|
||||
- Audio loading and playing with streaming support (WAV, OGG, MP3, FLAC, XM, MOD)
|
||||
- Audio loading and playing with streaming support (WAV, QOA, OGG, MP3, FLAC, XM, MOD)
|
||||
- **VR stereo rendering** support with configurable HMD device parameters
|
||||
- Huge examples collection with [+120 code examples](https://github.com/raysan5/raylib/tree/master/examples)!
|
||||
- Bindings to [+60 programming languages](https://github.com/raysan5/raylib/blob/master/BINDINGS.md)!
|
||||
- **Free and open source**.
|
||||
- Huge examples collection with [+140 code examples](https://github.com/raysan5/raylib/tree/master/examples)!
|
||||
- Bindings to [+70 programming languages](https://github.com/raysan5/raylib/blob/master/BINDINGS.md)!
|
||||
- **Free and open source**
|
||||
|
||||
basic example
|
||||
--------------
|
||||
This is a basic raylib example, it creates a window and it draws the text `"Congrats! You created your first window!"` in the middle of the screen. Check this example [running live on web here](https://www.raylib.com/examples/core/loader.html?name=core_basic_window).
|
||||
```odin
|
||||
package example
|
||||
This is a basic raylib example, it creates a window and draws the text `"Congrats! You created your first window!"` in the middle of the screen. Check this example [running live on web here](https://www.raylib.com/examples/core/loader.html?name=core_basic_window).
|
||||
```c
|
||||
#include "raylib.h"
|
||||
|
||||
import rl "vendor:raylib"
|
||||
int main(void)
|
||||
{
|
||||
InitWindow(800, 450, "raylib example - basic window");
|
||||
|
||||
main :: proc() {
|
||||
rl.InitWindow(800, 450, "raylib [core] example - basic window")
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
rl.BeginDrawing()
|
||||
rl.ClearBackground(rl.RAYWHITE)
|
||||
rl.DrawText("Congrats! You created your first window!", 190, 200, 20, rl.LIGHTGRAY)
|
||||
rl.EndDrawing()
|
||||
while (!WindowShouldClose())
|
||||
{
|
||||
BeginDrawing();
|
||||
ClearBackground(RAYWHITE);
|
||||
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
rl.CloseWindow()
|
||||
CloseWindow();
|
||||
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
build and installation
|
||||
----------------------
|
||||
|
||||
raylib binary releases for Windows, Linux, macOS, Android and HTML5 are available at the [Github Releases page](https://github.com/raysan5/raylib/releases).
|
||||
|
||||
raylib is also available via multiple [package managers](https://github.com/raysan5/raylib/issues/613) on multiple OS distributions.
|
||||
raylib is also available via multiple package managers on multiple OS distributions.
|
||||
|
||||
#### Installing and building raylib on multiple platforms
|
||||
|
||||
@@ -113,7 +114,7 @@ learning and docs
|
||||
|
||||
raylib is designed to be learned using [the examples](https://github.com/raysan5/raylib/tree/master/examples) as the main reference. There is no standard API documentation but there is a [**cheatsheet**](https://www.raylib.com/cheatsheet/cheatsheet.html) containing all the functions available on the library a short description of each one of them, input parameters and result value names should be intuitive enough to understand how each function works.
|
||||
|
||||
Some additional documentation about raylib design can be found in raylib GitHub Wiki. Here are the relevant links:
|
||||
Some additional documentation about raylib design can be found in [raylib GitHub Wiki](https://github.com/raysan5/raylib/wiki). Here are the relevant links:
|
||||
|
||||
- [raylib cheatsheet](https://www.raylib.com/cheatsheet/cheatsheet.html)
|
||||
- [raylib architecture](https://github.com/raysan5/raylib/wiki/raylib-architecture)
|
||||
@@ -129,15 +130,23 @@ raylib is present in several networks and raylib community is growing everyday.
|
||||
|
||||
- Webpage: [https://www.raylib.com](https://www.raylib.com)
|
||||
- Discord: [https://discord.gg/raylib](https://discord.gg/raylib)
|
||||
- Twitter: [https://www.twitter.com/raysan5](https://www.twitter.com/raysan5)
|
||||
- X: [https://x.com/raysan5](https://x.com/raysan5)
|
||||
- BlueSky: [https://bsky.app/profile/raysan5](https://bsky.app/profile/raysan5.bsky.social)
|
||||
- Twitch: [https://www.twitch.tv/raysan5](https://www.twitch.tv/raysan5)
|
||||
- Reddit: [https://www.reddit.com/r/raylib](https://www.reddit.com/r/raylib)
|
||||
- Patreon: [https://www.patreon.com/raylib](https://www.patreon.com/raylib)
|
||||
- YouTube: [https://www.youtube.com/channel/raylib](https://www.youtube.com/c/raylib)
|
||||
|
||||
contributors
|
||||
------------
|
||||
|
||||
<a href="https://github.com/raysan5/raylib/graphs/contributors">
|
||||
<img src="https://contrib.rocks/image?repo=raysan5/raylib&max=800&columns=24&anon=0" />
|
||||
</a>
|
||||
|
||||
license
|
||||
-------
|
||||
|
||||
raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified, BSD-like license that allows static linking with closed source software. Check [LICENSE](LICENSE) for further details.
|
||||
|
||||
raylib uses internally some libraries for window/graphics/inputs management and also to support different file formats loading, all those libraries are embedded with and are available in [src/external](https://github.com/raysan5/raylib/tree/master/src/external) directory. Check [raylib dependencies LICENSES](https://github.com/raysan5/raylib/wiki/raylib-dependencies) on raylib Wiki for details.
|
||||
raylib uses internally some libraries for window/graphics/inputs management and also to support different file formats loading, all those libraries are embedded with and are available in [src/external](https://github.com/raysan5/raylib/tree/master/src/external) directory. Check [raylib dependencies LICENSES](https://github.com/raysan5/raylib/wiki/raylib-dependencies) on [raylib Wiki](https://github.com/raysan5/raylib/wiki) for details.
|
||||
|
||||
BIN
vendor/raylib/linux/libraygui.a
vendored
BIN
vendor/raylib/linux/libraygui.a
vendored
Binary file not shown.
BIN
vendor/raylib/linux/libraylib.a
vendored
BIN
vendor/raylib/linux/libraylib.a
vendored
Binary file not shown.
BIN
vendor/raylib/macos-arm64/libraygui.a
vendored
BIN
vendor/raylib/macos-arm64/libraygui.a
vendored
Binary file not shown.
BIN
vendor/raylib/macos/libraygui.a
vendored
BIN
vendor/raylib/macos/libraygui.a
vendored
Binary file not shown.
BIN
vendor/raylib/macos/libraylib.a
vendored
BIN
vendor/raylib/macos/libraylib.a
vendored
Binary file not shown.
143
vendor/raylib/raylib.odin
vendored
143
vendor/raylib/raylib.odin
vendored
@@ -1,19 +1,19 @@
|
||||
/*
|
||||
Bindings for [[ raylib v5.5 ; https://www.raylib.com ]].
|
||||
Bindings for [[ raylib v6.0 ; https://www.raylib.com ]].
|
||||
|
||||
*********************************************************************************************
|
||||
**********************************************************************************************
|
||||
*
|
||||
* raylib v5.5 - A simple and easy-to-use library to enjoy videogames programming (www.raylib.com)
|
||||
* raylib v6.0 - A simple and easy-to-use library to enjoy videogames programming (www.raylib.com)
|
||||
*
|
||||
* FEATURES:
|
||||
* - NO external dependencies, all required libraries included with raylib
|
||||
* - Multiplatform: Windows, Linux, FreeBSD, OpenBSD, NetBSD, DragonFly,
|
||||
* MacOS, Haiku, Android, Raspberry Pi, DRM native, HTML5.
|
||||
* - Multiplatform: Windows, Linux, macOS, FreeBSD, Web, Android, Raspberry Pi, DRM native...
|
||||
* - Written in plain C code (C99) in PascalCase/camelCase notation
|
||||
* - Hardware accelerated with OpenGL (1.1, 2.1, 3.3, 4.3, ES2, ES3 - choose at compile)
|
||||
* - Unique OpenGL abstraction layer (usable as standalone module): [rlgl]
|
||||
* - Software renderer optional, for systems with no GPU: [rlsw]
|
||||
* - Custom OpenGL abstraction layer (usable as standalone module): [rlgl]
|
||||
* - Multiple Fonts formats supported (TTF, OTF, FNT, BDF, Sprite fonts)
|
||||
* - Outstanding texture formats support, including compressed formats (DXT, ETC, ASTC)
|
||||
* - Many texture formats supported, including compressed formats (DXT, ETC, ASTC)
|
||||
* - Full 3d support for 3d Shapes, Models, Billboards, Heightmaps and more!
|
||||
* - Flexible Materials system, supporting classic maps and PBR maps
|
||||
* - Animated 3D models supported (skeletal bones animation) (IQM, M3D, GLTF)
|
||||
@@ -29,24 +29,23 @@ Bindings for [[ raylib v5.5 ; https://www.raylib.com ]].
|
||||
* - One default Shader is loaded on rlglInit()->rlLoadShaderDefault() [rlgl] (OpenGL 3.3 or ES2)
|
||||
* - One default RenderBatch is loaded on rlglInit()->rlLoadRenderBatch() [rlgl] (OpenGL 3.3 or ES2)
|
||||
*
|
||||
* DEPENDENCIES (included):
|
||||
* [rcore][GLFW] rglfw (Camilla Löwy - github.com/glfw/glfw) for window/context management and input
|
||||
* [rcore][RGFW] rgfw (ColleagueRiley - github.com/ColleagueRiley/RGFW) for window/context management and input
|
||||
* [rlgl] glad/glad_gles2 (David Herberth - github.com/Dav1dde/glad) for OpenGL 3.3 extensions loading
|
||||
* DEPENDENCIES:
|
||||
* [rcore] Depends on the selected platform backend, check rcore.c header for details
|
||||
* [rlgl] glad/glad_gles2 (David Herberth - github.com/Dav1dde/glad) for OpenGL extensions loading
|
||||
* [raudio] miniaudio (David Reid - github.com/mackron/miniaudio) for audio device/context management
|
||||
*
|
||||
* OPTIONAL DEPENDENCIES (included):
|
||||
* [rcore] msf_gif (Miles Fogle) for GIF recording
|
||||
* [rcore] sinfl (Micha Mettke) for DEFLATE decompression algorithm
|
||||
* [rcore] sdefl (Micha Mettke) for DEFLATE compression algorithm
|
||||
* [rcore] rprand (Ramon Snatamaria) for pseudo-random numbers generation
|
||||
* [rtextures] qoi (Dominic Szablewski - https://phoboslab.org) for QOI image manage
|
||||
* [rtextures] stb_image (Sean Barret) for images loading (BMP, TGA, PNG, JPEG, HDR...)
|
||||
* [rtextures] stb_image_write (Sean Barret) for image writing (BMP, TGA, PNG, JPG)
|
||||
* [rtextures] stb_image_resize2 (Sean Barret) for image resizing algorithms
|
||||
* [rtextures] stb_perlin (Sean Barret) for Perlin Noise image generation
|
||||
* [rtext] stb_truetype (Sean Barret) for ttf fonts loading
|
||||
* [rtext] stb_rect_pack (Sean Barret) for rectangles packing
|
||||
* [rcore] rprand (Ramon Santamaria) for pseudo-random numbers generation
|
||||
* [rtextures] qoi (Dominic Szablewski - https://phoboslab.org) for QOI image management
|
||||
* [rtextures] stb_image (Sean Barrett) for images loading (BMP, TGA, PNG, JPEG, HDR...)
|
||||
* [rtextures] stb_image_write (Sean Barrett) for image writing (BMP, TGA, PNG, JPG)
|
||||
* [rtextures] stb_image_resize2 (Sean Barrett) for image resizing algorithms
|
||||
* [rtextures] stb_perlin (Sean Barrett) for Perlin Noise image generation
|
||||
* [rtextures] rltexgpu (Ramon Santamaria) for GPU-compressed texture formats
|
||||
* [rtext] stb_truetype (Sean Barrett) for ttf fonts loading
|
||||
* [rtext] stb_rect_pack (Sean Barrett) for rectangles packing
|
||||
* [rmodels] par_shapes (Philip Rideout) for parametric 3d shapes generation
|
||||
* [rmodels] tinyobj_loader_c (Syoyo Fujita) for models loading (OBJ, MTL)
|
||||
* [rmodels] cgltf (Johannes Kuhlmann) for models loading (glTF)
|
||||
@@ -55,10 +54,10 @@ Bindings for [[ raylib v5.5 ; https://www.raylib.com ]].
|
||||
* [raudio] dr_wav (David Reid) for WAV audio file loading
|
||||
* [raudio] dr_flac (David Reid) for FLAC audio file loading
|
||||
* [raudio] dr_mp3 (David Reid) for MP3 audio file loading
|
||||
* [raudio] stb_vorbis (Sean Barret) for OGG audio loading
|
||||
* [raudio] stb_vorbis (Sean Barrett) for OGG audio loading
|
||||
* [raudio] jar_xm (Joshua Reisenauer) for XM audio module loading
|
||||
* [raudio] jar_mod (Joshua Reisenauer) for MOD audio module loading
|
||||
* [raudio] qoa (Dominic Szablewski - https://phoboslab.org) for QOA audio manage
|
||||
* [raudio] qoa (Dominic Szablewski - https://phoboslab.org) for QOA audio management
|
||||
*
|
||||
*
|
||||
* LICENSE: zlib/libpng
|
||||
@@ -66,7 +65,7 @@ Bindings for [[ raylib v5.5 ; https://www.raylib.com ]].
|
||||
* raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2013-2024 Ramon Santamaria (@raysan5)
|
||||
* Copyright (c) 2013-2026 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
@@ -83,7 +82,7 @@ Bindings for [[ raylib v5.5 ; https://www.raylib.com ]].
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*
|
||||
*********************************************************************************************
|
||||
**********************************************************************************************
|
||||
*/
|
||||
package raylib
|
||||
|
||||
@@ -115,13 +114,13 @@ when ODIN_OS == .Windows {
|
||||
// multiple copies of raylib.so, but since these bindings are for
|
||||
// particular version of the library, I better specify it. Ideally,
|
||||
// though, it's best specified in terms of major (.so.4)
|
||||
"linux/libraylib.so.550" when RAYLIB_SHARED else "linux/libraylib.a",
|
||||
"linux/libraylib.so.600" when RAYLIB_SHARED else "linux/libraylib.a",
|
||||
"system:dl",
|
||||
"system:pthread",
|
||||
}
|
||||
} else when ODIN_OS == .Darwin {
|
||||
foreign import lib {
|
||||
"macos/libraylib.550.dylib" when RAYLIB_SHARED else "macos/libraylib.a",
|
||||
"macos/libraylib.600.dylib" when RAYLIB_SHARED else "macos/libraylib.a",
|
||||
"system:Cocoa.framework",
|
||||
"system:OpenGL.framework",
|
||||
"system:IOKit.framework",
|
||||
@@ -134,10 +133,10 @@ when ODIN_OS == .Windows {
|
||||
foreign import lib "system:raylib"
|
||||
}
|
||||
|
||||
VERSION_MAJOR :: 5
|
||||
VERSION_MINOR :: 5
|
||||
VERSION_MAJOR :: 6
|
||||
VERSION_MINOR :: 0
|
||||
VERSION_PATCH :: 0
|
||||
VERSION :: "5.5"
|
||||
VERSION :: "6.0"
|
||||
|
||||
PI :: 3.14159265358979323846
|
||||
DEG2RAD :: PI/180.0
|
||||
@@ -271,7 +270,7 @@ Camera3D :: struct {
|
||||
position: Vector3, // Camera position
|
||||
target: Vector3, // Camera target it looks-at
|
||||
up: Vector3, // Camera up vector (rotation over its axis)
|
||||
fovy: f32, // Camera field-of-view apperture in Y (degrees) in perspective, used as near plane width in orthographic
|
||||
fovy: f32, // Camera field-of-view aperture in Y (degrees) in perspective, used as near plane height in world units in orthographic
|
||||
projection: CameraProjection, // Camera projection: `.PERSPECTIVE` or `.ORTHOGRAPHIC`
|
||||
}
|
||||
|
||||
@@ -1063,7 +1062,7 @@ foreign lib {
|
||||
SetSaveFileTextCallback :: proc(callback: SaveFileTextCallback) --- // Set custom file text data saver
|
||||
|
||||
// Files management functions
|
||||
|
||||
|
||||
LoadFileData :: proc(fileName: cstring, dataSize: ^c.int) -> [^]byte --- // Load file data as byte array (read)
|
||||
UnloadFileData :: proc(data: [^]byte) --- // Unload file data allocated by LoadFileData()
|
||||
SaveFileData :: proc(fileName: cstring, data: rawptr, dataSize: c.int) -> bool --- // Save data to file from byte array (write), returns true on success
|
||||
@@ -1074,6 +1073,12 @@ foreign lib {
|
||||
|
||||
// File system functions
|
||||
|
||||
FileRename :: proc(fileName: cstring, fileRename: cstring) -> c.int --- // Rename file (if exists)
|
||||
FileRemove :: proc(fileName: cstring) -> c.int --- // Remove file (if exists)
|
||||
FileCopy :: proc(srcPath: cstring, dstPath: cstring) -> c.int --- // Copy file from one path to another, dstPath created if it doesn't exist
|
||||
FileMove :: proc(srcPath: cstring, dstPath: cstring) -> c.int --- // Move file from one directory to another, dstPath created if it doesn't exist
|
||||
FileTextReplace :: proc(fileName: cstring, search: cstring, replacement: cstring) -> c.int --- // Replace text in an existing file
|
||||
FileTextFindIndex :: proc(fileName: cstring, search: cstring) -> c.int --- // Find text in existing file
|
||||
FileExists :: proc(fileName: cstring) -> bool --- // Check if file exists
|
||||
DirectoryExists :: proc(dirPath: cstring) -> bool --- // Check if a directory path exists
|
||||
IsFileExtension :: proc(fileName, ext: cstring) -> bool --- // Check file extension (including point: .png, .wav)
|
||||
@@ -1101,12 +1106,12 @@ foreign lib {
|
||||
|
||||
CompressData :: proc(data: rawptr, dataSize: c.int, compDataSize: ^c.int) -> [^]byte --- // Compress data (DEFLATE algorithm), memory must be MemFree()
|
||||
DecompressData :: proc(compData: rawptr, compDataSize: c.int, dataSize: ^c.int) -> [^]byte --- // Decompress data (DEFLATE algorithm), memory must be MemFree()
|
||||
EncodeDataBase64 :: proc(data: rawptr, dataSize: c.int, outputSize: ^c.int) -> [^]byte --- // Encode data to Base64 string, memory must be MemFree()
|
||||
DecodeDataBase64 :: proc(data: rawptr, outputSize: ^c.int) -> [^]byte --- // Decode Base64 string data, memory must be MemFree()
|
||||
EncodeDataBase64 :: proc(data: rawptr, dataSize: c.int, outputSize: ^c.int) -> cstring --- // Encode data to Base64 string (includes NULL terminator), memory must be MemFree()
|
||||
DecodeDataBase64 :: proc(data: rawptr, outputSize: ^c.int) -> cstring --- // Decode Base64 string (expected NULL terminated), memory must be MemFree()
|
||||
ComputeCRC32 :: proc(data: rawptr, dataSize: c.int) -> c.uint --- // Compute CRC32 hash code
|
||||
ComputeMD5 :: proc (data: rawptr, dataSize: c.int) -> [^]c.uint --- // Compute MD5 hash code, returns static int[4] (16 bytes)
|
||||
ComputeSHA1 :: proc(data: rawptr, dataSize: c.int) -> [^]c.uint --- // Compute SHA1 hash code, returns static int[5] (20 bytes)
|
||||
|
||||
ComputeSHA256 :: proc(data: rawptr, dataSize: c.int) -> [^]c.uint --- // Compute SHA256 hash code, returns static int[8] (32 bytes)
|
||||
|
||||
// Automation events functionality
|
||||
|
||||
@@ -1132,6 +1137,7 @@ foreign lib {
|
||||
IsKeyUp :: proc(key: KeyboardKey) -> bool --- // Detect if a key is NOT being pressed
|
||||
GetKeyPressed :: proc() -> KeyboardKey --- // Get key pressed (keycode), call it multiple times for keys queued
|
||||
GetCharPressed :: proc() -> rune --- // Get char pressed (unicode), call it multiple times for chars queued
|
||||
GetKeyName :: proc(key: c.int) -> cstring --- // Get name of a QWERTY key on the current keyboard layout (eg returns string 'q' for KEY_A on an AZERTY keyboard)
|
||||
SetExitKey :: proc(key: KeyboardKey) --- // Set a custom key to exit program (default is ESC)
|
||||
|
||||
// Input-related functions: gamepads
|
||||
@@ -1233,15 +1239,18 @@ foreign lib {
|
||||
DrawLineEx :: proc(startPos, endPos: Vector2, thick: f32, color: Color) --- // Draw a line (using triangles/quads)
|
||||
DrawLineStrip :: proc(points: [^]Vector2, pointCount: c.int, color: Color) --- // Draw lines sequence (using gl lines)
|
||||
DrawLineBezier :: proc(startPos, endPos: Vector2, thick: f32, color: Color) --- // Draw line segment cubic-bezier in-out interpolation
|
||||
DrawLineDashed :: proc(startPos, endPos: Vector2, dashSize: c.int, spaceSize: c.int, color: Color) --- // Draw a dashed line
|
||||
DrawCircle :: proc(centerX, centerY: c.int, radius: f32, color: Color) --- // Draw a color-filled circle
|
||||
DrawCircleSector :: proc(center: Vector2, radius: f32, startAngle, endAngle: f32, segments: c.int, color: Color) --- // Draw a piece of a circle
|
||||
DrawCircleSectorLines :: proc(center: Vector2, radius: f32, startAngle, endAngle: f32, segments: c.int, color: Color) --- // Draw circle sector outline
|
||||
DrawCircleGradient :: proc(centerX, centerY: c.int, radius: f32, inner, outer: Color) --- // Draw a gradient-filled circle
|
||||
DrawCircleGradient :: proc(center: Vector2, radius: f32, inner, outer: Color) --- // Draw a gradient-filled circle
|
||||
DrawCircleV :: proc(center: Vector2, radius: f32, color: Color) --- // Draw a color-filled circle (Vector version)
|
||||
DrawCircleLines :: proc(centerX, centerY: c.int, radius: f32, color: Color) --- // Draw circle outline
|
||||
DrawCircleLinesV :: proc(center: Vector2, radius: f32, color: Color) --- // Draw circle outline (Vector version)
|
||||
DrawEllipse :: proc(centerX, centerY: c.int, radiusH, radiusV: f32, color: Color) --- // Draw ellipse
|
||||
DrawEllipseV :: proc(center: Vector2, radiusH, radiusV: f32, color: Color) --- // Draw ellipse (Vector version)
|
||||
DrawEllipseLines :: proc(centerX, centerY: c.int, radiusH, radiusV: f32, color: Color) --- // Draw ellipse outline
|
||||
DrawEllipseLinesV :: proc(center: Vector2, radiusH, radiusV: f32, color: Color) --- // Draw ellipse outline (Vector version)
|
||||
DrawRing :: proc(center: Vector2, innerRadius, outerRadius: f32, startAngle, endAngle: f32, segments: c.int, color: Color) --- // Draw ring
|
||||
DrawRingLines :: proc(center: Vector2, innerRadius, outerRadius: f32, startAngle, endAngle: f32, segments: c.int, color: Color) --- // Draw ring outline
|
||||
DrawRectangle :: proc(posX, posY: c.int, width, height: c.int, color: Color) --- // Draw a color-filled rectangle
|
||||
@@ -1250,7 +1259,7 @@ foreign lib {
|
||||
DrawRectanglePro :: proc(rec: Rectangle, origin: Vector2, rotation: f32, color: Color) --- // Draw a color-filled rectangle with pro parameters
|
||||
DrawRectangleGradientV :: proc(posX, posY: c.int, width, height: c.int, top, bottom: Color) --- // Draw a vertical-gradient-filled rectangle
|
||||
DrawRectangleGradientH :: proc(posX, posY: c.int, width, height: c.int, left, right: Color) --- // Draw a horizontal-gradient-filled rectangle
|
||||
DrawRectangleGradientEx :: proc(rec: Rectangle, topLeft, bottomLeft, topRight, bottomRight: Color) --- // Draw a gradient-filled rectangle with custom vertex colors
|
||||
DrawRectangleGradientEx :: proc(rec: Rectangle, topLeft, bottomLeft, bottomRight, topRight: Color) --- // Draw a gradient-filled rectangle with custom vertex colors
|
||||
DrawRectangleLines :: proc(posX, posY: c.int, width, height: c.int, color: Color) --- // Draw rectangle outline
|
||||
DrawRectangleLinesEx :: proc(rec: Rectangle, lineThick: f32, color: Color) --- // Draw rectangle outline with extended parameters
|
||||
DrawRectangleRounded :: proc(rec: Rectangle, roundness: f32, segments: c.int, color: Color) --- // Draw rectangle with rounded edges
|
||||
@@ -1471,12 +1480,13 @@ foreign lib {
|
||||
|
||||
// Text font info functions
|
||||
|
||||
SetTextLineSpacing :: proc(spacing: c.int) --- // Set vertical line spacing when drawing with line-breaks
|
||||
MeasureText :: proc(text: cstring, fontSize: c.int) -> c.int --- // Measure string width for default font
|
||||
MeasureTextEx :: proc(font: Font, text: cstring, fontSize: f32, spacing: f32) -> Vector2 --- // Measure string size for Font
|
||||
GetGlyphIndex :: proc(font: Font, codepoint: rune) -> c.int --- // Get glyph index position in font for a codepoint (unicode character), fallback to '?' if not found
|
||||
GetGlyphInfo :: proc(font: Font, codepoint: rune) -> GlyphInfo --- // Get glyph font info data for a codepoint (unicode character), fallback to '?' if not found
|
||||
GetGlyphAtlasRec :: proc(font: Font, codepoint: rune) -> Rectangle --- // Get glyph rectangle in font atlas for a codepoint (unicode character), fallback to '?' if not found
|
||||
SetTextLineSpacing :: proc(spacing: c.int) --- // Set vertical line spacing when drawing with line-breaks
|
||||
MeasureText :: proc(text: cstring, fontSize: c.int) -> c.int --- // Measure string width for default font
|
||||
MeasureTextEx :: proc(font: Font, text: cstring, fontSize: f32, spacing: f32) -> Vector2 --- // Measure string size for Font
|
||||
MeasureTextCodepoints :: proc(font: Font, codepoints: [^]c.int, length: c.int, fontSize, spacing: f32) --- // Measure string size for an existing array of codepoints for Font
|
||||
GetGlyphIndex :: proc(font: Font, codepoint: rune) -> c.int --- // Get glyph index position in font for a codepoint (unicode character), fallback to '?' if not found
|
||||
GetGlyphInfo :: proc(font: Font, codepoint: rune) -> GlyphInfo --- // Get glyph font info data for a codepoint (unicode character), fallback to '?' if not found
|
||||
GetGlyphAtlasRec :: proc(font: Font, codepoint: rune) -> Rectangle --- // Get glyph rectangle in font atlas for a codepoint (unicode character), fallback to '?' if not found
|
||||
|
||||
// Text codepoints management functions (unicode characters)
|
||||
|
||||
@@ -1492,28 +1502,35 @@ foreign lib {
|
||||
|
||||
// Text strings management functions (no UTF-8 strings, only byte chars)
|
||||
// NOTE: Some strings allocate memory internally for returned strings, just be careful!
|
||||
|
||||
TextCopy :: proc(dst: [^]byte, src: cstring) -> c.int --- // Copy one string to another, returns bytes copied
|
||||
TextIsEqual :: proc(text1, text2: cstring) -> bool --- // Check if two text string are equal
|
||||
TextLength :: proc(text: cstring) -> c.uint --- // Get text length, checks for '\0' ending
|
||||
LoadTextLines :: proc(text: cstring, count: ^c.int) -> [^]cstring --- // Load text as separate lines ('\n')
|
||||
UnloadTextLines :: proc(text: [^]cstring, lineCount: c.int) --- // Unload text lines
|
||||
TextCopy :: proc(dst: [^]byte, src: cstring) -> c.int --- // Copy one string to another, returns bytes copied
|
||||
TextIsEqual :: proc(text1, text2: cstring) -> bool --- // Check if two text string are equal
|
||||
TextLength :: proc(text: cstring) -> c.uint --- // Get text length, checks for '\0' ending
|
||||
|
||||
// TextFormat is defined at the bottom of this file
|
||||
|
||||
TextSubtext :: proc(text: cstring, position: c.int, length: c.int) -> cstring --- // Get a piece of a text string
|
||||
TextReplace :: proc(text: [^]byte, replace, by: cstring) -> [^]byte --- // Replace text string (WARNING: memory must be freed!)
|
||||
TextInsert :: proc(text, insert: cstring, position: c.int) -> [^]byte --- // Insert text in a position (WARNING: memory must be freed!)
|
||||
TextJoin :: proc(textList: [^]cstring, count: c.int, delimiter: cstring) -> cstring --- // Join text strings with delimiter
|
||||
TextSplit :: proc(text: cstring, delimiter: byte, count: ^c.int) -> [^]cstring --- // Split text into multiple strings
|
||||
TextAppend :: proc(text: [^]byte, append: cstring, position: ^c.int) --- // Append text at specific position and move cursor!
|
||||
TextFindIndex :: proc(text, find: cstring) -> c.int --- // Find first text occurrence within a string
|
||||
TextToUpper :: proc(text: cstring) -> cstring --- // Get upper case version of provided string
|
||||
TextToLower :: proc(text: cstring) -> cstring --- // Get lower case version of provided string
|
||||
TextToPascal :: proc(text: cstring) -> cstring --- // Get Pascal case notation version of provided string
|
||||
TextToSnake :: proc(text: cstring) -> cstring --- // Get Snake case notation version of provided string
|
||||
TextToCamel :: proc(text: cstring) -> cstring --- // Get Camel case notation version of provided string
|
||||
TextSubtext :: proc(text: cstring, position: c.int, length: c.int) -> cstring --- // Get a piece of a text string
|
||||
TextRemoveSpaces :: proc(text: cstring) -> cstring --- // Remove text spaces, concat words
|
||||
GetTextBetween :: proc(text, begin, end: cstring) -> [^]byte --- // Get text between two strings
|
||||
TextReplace :: proc(text, search, replacement: cstring) -> [^]byte --- // Replace text string with new string
|
||||
TextReplaceAlloc :: proc(text, search, replacement: cstring) -> [^]byte --- // Replace text string with new string, memory must be MemFree()
|
||||
TextReplaceBetween :: proc(text, begin, end, replacement: cstring) -> [^]byte --- // Replace text between two specific strings
|
||||
TextReplaceBetweenAlloc :: proc(text, begin, end, replacement: cstring) -> [^]byte --- // Replace text between two specific strings, memory must be MemFree()
|
||||
TextInsert :: proc(text, insert: cstring, position: c.int) -> [^]byte --- // Insert text in a position (WARNING: memory must be freed!)
|
||||
TextInsertAlloc :: proc(text: cstring, insert: cstring, position: c.int) -> [^]byte --- // Insert text in a defined byte position, memory must be MemFree()
|
||||
TextJoin :: proc(textList: [^]cstring, count: c.int, delimiter: cstring) -> cstring --- // Join text strings with delimiter
|
||||
TextSplit :: proc(text: cstring, delimiter: byte, count: ^c.int) -> [^]cstring --- // Split text into multiple strings
|
||||
TextAppend :: proc(text: [^]byte, append: cstring, position: ^c.int) --- // Append text at specific position and move cursor!
|
||||
TextFindIndex :: proc(text, find: cstring) -> c.int --- // Find first text occurrence within a string
|
||||
TextToUpper :: proc(text: cstring) -> cstring --- // Get upper case version of provided string
|
||||
TextToLower :: proc(text: cstring) -> cstring --- // Get lower case version of provided string
|
||||
TextToPascal :: proc(text: cstring) -> cstring --- // Get Pascal case notation version of provided string
|
||||
TextToSnake :: proc(text: cstring) -> cstring --- // Get Snake case notation version of provided string
|
||||
TextToCamel :: proc(text: cstring) -> cstring --- // Get Camel case notation version of provided string
|
||||
|
||||
TextToInteger :: proc(text: cstring) -> c.int --- // Get integer value from text (negative values not supported)
|
||||
TextToFloat :: proc(text: cstring) -> f32 --- // Get float value from text (negative values not supported)
|
||||
TextToInteger :: proc(text: cstring) -> c.int --- // Get integer value from text (negative values not supported)
|
||||
TextToFloat :: proc(text: cstring) -> f32 --- // Get float value from text (negative values not supported)
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
@@ -1562,8 +1579,6 @@ foreign lib {
|
||||
DrawModelEx :: proc(model: Model, position: Vector3, rotationAxis: Vector3, rotationAngle: f32, scale: Vector3, tint: Color) --- // Draw a model with extended parameters
|
||||
DrawModelWires :: proc(model: Model, position: Vector3, scale: f32, tint: Color) --- // Draw a model wires (with texture if set)
|
||||
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
|
||||
DrawModelPoints :: proc(model: Model, position: Vector3, scale: f32, tint: Color) --- // Draw a model as points
|
||||
DrawModelPointsEx :: proc(model: Model, position: Vector3, rotationAxis: Vector3, rotationAngle: f32, scale: Vector3, tint: Color) --- // Draw a model as points with extended parameters
|
||||
DrawBoundingBox :: proc(box: BoundingBox, color: Color) --- // Draw bounding box (wires)
|
||||
DrawBillboard :: proc(camera: Camera, texture: Texture2D, position: Vector3, scale: f32, tint: Color) --- // Draw a billboard texture
|
||||
DrawBillboardRec :: proc(camera: Camera, texture: Texture2D, source: Rectangle, position: Vector3, size: Vector2, tint: Color) --- // Draw a billboard texture defined by source
|
||||
@@ -1661,7 +1676,7 @@ foreign lib {
|
||||
IsSoundPlaying :: proc(sound: Sound) -> bool --- // Check if a sound is currently playing
|
||||
SetSoundVolume :: proc(sound: Sound, volume: f32) --- // Set volume for a sound (1.0 is max level)
|
||||
SetSoundPitch :: proc(sound: Sound, pitch: f32) --- // Set pitch for a sound (1.0 is base level)
|
||||
SetSoundPan :: proc(sound: Sound, pan: f32) --- // Set pan for a sound (0.5 is center)
|
||||
SetSoundPan :: proc(sound: Sound, pan: f32) --- // Set pan for a sound (-1.0 left, 0.0 center, 1.0 right)
|
||||
WaveCopy :: proc(wave: Wave) -> Wave --- // Copy a wave to a new wave
|
||||
WaveCrop :: proc(wave: ^Wave, initFrame, finalFrame: c.int) --- // Crop a wave to defined samples range
|
||||
WaveFormat :: proc(wave: ^Wave, sampleRate, sampleSize: c.int, channels: c.int) --- // Convert wave data to desired format
|
||||
@@ -1684,7 +1699,7 @@ foreign lib {
|
||||
SeekMusicStream :: proc(music: Music, position: f32) --- // Seek music to a position (in seconds)
|
||||
SetMusicVolume :: proc(music: Music, volume: f32) --- // Set volume for music (1.0 is max level)
|
||||
SetMusicPitch :: proc(music: Music, pitch: f32) --- // Set pitch for a music (1.0 is base level)
|
||||
SetMusicPan :: proc(music: Music, pan: f32) --- // Set pan for a music (0.5 is center)
|
||||
SetMusicPan :: proc(music: Music, pan: f32) --- // Set pan for a music (-1.0 left, 0.0 center, 1.0 right)
|
||||
GetMusicTimeLength :: proc(music: Music) -> f32 --- // Get music time length (in seconds)
|
||||
GetMusicTimePlayed :: proc(music: Music) -> f32 --- // Get current music time played (in seconds)
|
||||
|
||||
|
||||
34
vendor/raylib/raymath.odin
vendored
34
vendor/raylib/raymath.odin
vendored
@@ -99,6 +99,11 @@ Vector2LengthSqr :: proc "c" (v: Vector2) -> f32 {
|
||||
Vector2DotProduct :: proc "c" (v1, v2: Vector2) -> f32 {
|
||||
return linalg.dot(v1, v2)
|
||||
}
|
||||
// Calculate two vectors dot product
|
||||
@(require_results)
|
||||
Vector2CrossProduct :: proc "c" (v1, v2: Vector2) -> f32 {
|
||||
return linalg.cross(v1, v2)
|
||||
}
|
||||
// Calculate distance between two vectors
|
||||
@(require_results)
|
||||
Vector2Distance :: proc "c" (v1, v2: Vector2) -> f32 {
|
||||
@@ -587,6 +592,12 @@ MatrixMultiply :: proc "c" (left, right: Matrix) -> Matrix {
|
||||
return left * right
|
||||
}
|
||||
|
||||
// Multiply matrix components by value
|
||||
@(require_results, deprecated="Prefer left * value")
|
||||
MatrixMultiplyValue :: proc "c" (left: Matrix, value: f32) -> Matrix {
|
||||
return left * Matrix(value)
|
||||
}
|
||||
|
||||
// Get translation matrix
|
||||
@(require_results)
|
||||
MatrixTranslate :: proc "c" (x, y, z: f32) -> Matrix {
|
||||
@@ -821,6 +832,29 @@ QuaternionEquals :: proc "c" (p, q: Quaternion) -> bool {
|
||||
FloatEquals(p.w, q.w)
|
||||
}
|
||||
|
||||
@(require_results)
|
||||
MatrixCompose :: proc "c" (translation: Vector3, rotation: Quaternion, scale: Vector3) -> Matrix {
|
||||
// Initialize and scale vectors
|
||||
right := Vector3 {1, 0, 0} * scale.x
|
||||
up := Vector3 {0, 1, 0} * scale.y
|
||||
forward := Vector3 {0, 0, 1} * scale.z
|
||||
|
||||
// Rotate vectors
|
||||
right = Vector3RotateByQuaternion(right, rotation)
|
||||
up = Vector3RotateByQuaternion(up, rotation)
|
||||
forward = Vector3RotateByQuaternion(forward, rotation)
|
||||
|
||||
// Set result matrix output
|
||||
result := Matrix {
|
||||
right.x, up.x, forward.x, translation.x,
|
||||
right.y, up.y, forward.y, translation.y,
|
||||
right.z, up.z, forward.z, translation.z,
|
||||
0, 0, 0, 1
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
@(private, require_results)
|
||||
fmaxf :: proc "contextless" (x, y: f32) -> f32 {
|
||||
if math.is_nan(x) {
|
||||
|
||||
60
vendor/raylib/rlgl/rlgl.odin
vendored
60
vendor/raylib/rlgl/rlgl.odin
vendored
@@ -1,26 +1,27 @@
|
||||
/**********************************************************************************************
|
||||
*
|
||||
* rlgl v5.0 - A multi-OpenGL abstraction layer with an immediate-mode style API
|
||||
* rlgl v6.0 - A multi-OpenGL abstraction layer with an immediate-mode style API
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* An abstraction layer for multiple OpenGL versions (1.1, 2.1, 3.3 Core, 4.3 Core, ES 2.0)
|
||||
* An abstraction layer for multiple OpenGL versions (1.1, 2.1, 3.3 Core, 4.3 Core, ES 2.0, ES 3.0)
|
||||
* that provides a pseudo-OpenGL 1.1 immediate-mode style API (rlVertex, rlTranslate, rlRotate...)
|
||||
*
|
||||
* ADDITIONAL NOTES:
|
||||
* When choosing an OpenGL backend different than OpenGL 1.1, some internal buffer are
|
||||
* initialized on rlglInit() to accumulate vertex data.
|
||||
* When choosing an OpenGL backend different than OpenGL 1.1, some internal buffers are
|
||||
* initialized on rlglInit() to accumulate vertex data
|
||||
*
|
||||
* When an internal state change is required all the stored vertex data is renderer in batch,
|
||||
* additionally, rlDrawRenderBatchActive() could be called to force flushing of the batch.
|
||||
* When an internal state change is required all the stored vertex data is rendered in a batch,
|
||||
* additionally, rlDrawRenderBatchActive() could be called to force flushing of the batch
|
||||
*
|
||||
* Some resources are also loaded for convenience, here the complete list:
|
||||
* - Default batch (RLGL.defaultBatch): RenderBatch system to accumulate vertex data
|
||||
* - Default texture (RLGL.defaultTextureId): 1x1 white pixel R8G8B8A8
|
||||
* - Default shader (RLGL.State.defaultShaderId, RLGL.State.defaultShaderLocs)
|
||||
*
|
||||
* Internal buffer (and resources) must be manually unloaded calling rlglClose().
|
||||
* Internal buffer (and resources) must be manually unloaded calling rlglClose()
|
||||
*
|
||||
* CONFIGURATION:
|
||||
* #define GRAPHICS_API_OPENGL_SOFTWARE
|
||||
* #define GRAPHICS_API_OPENGL_11
|
||||
* #define GRAPHICS_API_OPENGL_21
|
||||
* #define GRAPHICS_API_OPENGL_33
|
||||
@@ -28,52 +29,51 @@
|
||||
* #define GRAPHICS_API_OPENGL_ES2
|
||||
* #define GRAPHICS_API_OPENGL_ES3
|
||||
* Use selected OpenGL graphics backend, should be supported by platform
|
||||
* Those preprocessor defines are only used on rlgl module, if OpenGL version is
|
||||
* Those preprocessor defines are only used on the rlgl module, if OpenGL version is
|
||||
* required by any other module, use rlGetVersion() to check it
|
||||
*
|
||||
* #define RLGL_IMPLEMENTATION
|
||||
* Generates the implementation of the library into the included file.
|
||||
* Generates the implementation of the library into the included file
|
||||
* If not defined, the library is in header only mode and can be included in other headers
|
||||
* or source files without problems. But only ONE file should hold the implementation.
|
||||
* or source files without problems. But only ONE file should hold the implementation
|
||||
*
|
||||
* #define RLGL_RENDER_TEXTURES_HINT
|
||||
* Enable framebuffer objects (fbo) support (enabled by default)
|
||||
* Some GPUs could not support them despite the OpenGL version
|
||||
*
|
||||
* #define RLGL_SHOW_GL_DETAILS_INFO
|
||||
* #if RLGL_SHOW_GL_DETAILS_INFO
|
||||
* Show OpenGL extensions and capabilities detailed logs on init
|
||||
*
|
||||
* #define RLGL_ENABLE_OPENGL_DEBUG_CONTEXT
|
||||
* #if RLGL_ENABLE_OPENGL_DEBUG_CONTEXT
|
||||
* Enable debug context (only available on OpenGL 4.3)
|
||||
*
|
||||
* rlgl capabilities could be customized just defining some internal
|
||||
* rlgl capabilities could be customized defining some internal
|
||||
* values before library inclusion (default values listed):
|
||||
*
|
||||
* #define RL_DEFAULT_BATCH_BUFFER_ELEMENTS 8192 // Default internal render batch elements limits
|
||||
* #define RL_DEFAULT_BATCH_BUFFERS 1 // Default number of batch buffers (multi-buffering)
|
||||
* #define RL_DEFAULT_BATCH_DRAWCALLS 256 // Default number of batch draw calls (by state changes: mode, texture)
|
||||
* #define RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS 4 // Maximum number of textures units that can be activated on batch drawing (SetShaderValueTexture())
|
||||
* #define RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS 4 // Maximum number of texture units that can be activated on batch drawing (SetShaderValueTexture())
|
||||
*
|
||||
* #define RL_MAX_MATRIX_STACK_SIZE 32 // Maximum size of internal Matrix stack
|
||||
* #define RL_MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported
|
||||
* #define RL_CULL_DISTANCE_NEAR 0.01 // Default projection matrix near cull distance
|
||||
* #define RL_CULL_DISTANCE_FAR 1000.0 // Default projection matrix far cull distance
|
||||
* #define RL_CULL_DISTANCE_NEAR 0.05 // Default projection matrix near cull distance
|
||||
* #define RL_CULL_DISTANCE_FAR 4000.0 // Default projection matrix far cull distance
|
||||
*
|
||||
* When loading a shader, the following vertex attributes and uniform
|
||||
* location names are tried to be set automatically:
|
||||
*
|
||||
* #define RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION "vertexPosition" // Bound by default to shader location: 0
|
||||
* #define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD "vertexTexCoord" // Bound by default to shader location: 1
|
||||
* #define RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL "vertexNormal" // Bound by default to shader location: 2
|
||||
* #define RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR "vertexColor" // Bound by default to shader location: 3
|
||||
* #define RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT "vertexTangent" // Bound by default to shader location: 4
|
||||
* #define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2 "vertexTexCoord2" // Bound by default to shader location: 5
|
||||
* #define RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION "vertexPosition" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION
|
||||
* #define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD "vertexTexCoord" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD
|
||||
* #define RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL "vertexNormal" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL
|
||||
* #define RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR "vertexColor" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_COLOR
|
||||
* #define RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT "vertexTangent" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT
|
||||
* #define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2 "vertexTexCoord2" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2
|
||||
* #define RL_DEFAULT_SHADER_ATTRIB_NAME_BONEINDICES "vertexBoneIndices" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEINDICES
|
||||
* #define RL_DEFAULT_SHADER_ATTRIB_NAME_BONEWEIGHTS "vertexBoneWeights" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS
|
||||
* #define RL_DEFAULT_SHADER_UNIFORM_NAME_MVP "mvp" // model-view-projection matrix
|
||||
* #define RL_DEFAULT_SHADER_UNIFORM_NAME_VIEW "matView" // view matrix
|
||||
* #define RL_DEFAULT_SHADER_UNIFORM_NAME_PROJECTION "matProjection" // projection matrix
|
||||
* #define RL_DEFAULT_SHADER_UNIFORM_NAME_MODEL "matModel" // model matrix
|
||||
* #define RL_DEFAULT_SHADER_UNIFORM_NAME_NORMAL "matNormal" // normal matrix (transpose(inverse(matModelView))
|
||||
* #define RL_DEFAULT_SHADER_UNIFORM_NAME_NORMAL "matNormal" // normal matrix (transpose(inverse(matModelView)))
|
||||
* #define RL_DEFAULT_SHADER_UNIFORM_NAME_COLOR "colDiffuse" // color diffuse (base tint color, multiplied by texture color)
|
||||
* #define RL_DEFAULT_SHADER_UNIFORM_NAME_BONEMATRICES "boneMatrices" // bone matrices
|
||||
* #define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE0 "texture0" // texture0 (texture slot active 0)
|
||||
* #define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE1 "texture1" // texture1 (texture slot active 1)
|
||||
* #define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE2 "texture2" // texture2 (texture slot active 2)
|
||||
@@ -85,7 +85,7 @@
|
||||
*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* Copyright (c) 2014-2023 Ramon Santamaria (@raysan5)
|
||||
* Copyright (c) 2014-2026 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
@@ -110,7 +110,7 @@ package rlgl
|
||||
import "core:c"
|
||||
import rl "../."
|
||||
|
||||
VERSION :: "5.0"
|
||||
VERSION :: "6.0"
|
||||
|
||||
RAYLIB_SHARED :: #config(RAYLIB_SHARED, false)
|
||||
RAYLIB_WASM_LIB :: #config(RAYLIB_WASM_LIB, "../wasm/libraylib.a")
|
||||
@@ -484,6 +484,7 @@ foreign lib {
|
||||
@(link_prefix="rlgl")
|
||||
Close :: proc() --- // De-initialize rlgl (buffers, shaders, textures)
|
||||
LoadExtensions :: proc(loader: rawptr) --- // Load OpenGL extensions (loader function required)
|
||||
GetProcAddress :: proc(procName: cstring) // Get OpenGL procedure address
|
||||
GetVersion :: proc() -> GlVersion --- // Get current OpenGL version
|
||||
SetFramebufferWidth :: proc(width: c.int) --- // Set current framebuffer width
|
||||
GetFramebufferWidth :: proc() -> c.int --- // Get default framebuffer width
|
||||
@@ -547,6 +548,7 @@ foreign lib {
|
||||
LoadShaderCode :: proc(vsCode, fsCode: cstring) -> c.uint --- // Load shader from code strings
|
||||
CompileShader :: proc(shaderCode: cstring, type: c.int) -> c.uint --- // Compile custom shader and return shader id (type: VERTEX_SHADER, FRAGMENT_SHADER, COMPUTE_SHADER)
|
||||
LoadShaderProgram :: proc(vShaderId, fShaderId: c.uint) -> c.uint --- // Load custom shader program
|
||||
UnloadShader :: proc(id: c.uint) --- // Unload shader, loaded with rlLoadShader()
|
||||
UnloadShaderProgram :: proc(id: c.uint) --- // Unload shader program
|
||||
GetLocationUniform :: proc(shaderId: c.uint, uniformName: cstring) -> c.int --- // Get shader location uniform
|
||||
GetLocationAttrib :: proc(shaderId: c.uint, attribName: cstring) -> c.int --- // Get shader location attribute
|
||||
|
||||
16
vendor/raylib/v5.5/LICENSE
vendored
Normal file
16
vendor/raylib/v5.5/LICENSE
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
Copyright (c) 2013-2023 Ramon Santamaria (@raysan5)
|
||||
|
||||
This software is provided "as-is", without any express or implied warranty. In no event
|
||||
will the authors be held liable for any damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
wrote the original software. If you use this software in a product, an acknowledgment
|
||||
in the product documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
143
vendor/raylib/v5.5/README.md
vendored
Normal file
143
vendor/raylib/v5.5/README.md
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
<img align="left" src="https://github.com/raysan5/raylib/blob/master/logo/raylib_logo_animation.gif" width="288px">
|
||||
|
||||
**raylib is a simple and easy-to-use library to enjoy videogames programming.**
|
||||
|
||||
raylib is highly inspired by Borland BGI graphics lib and by XNA framework and it's specially well suited for prototyping, tooling, graphical applications, embedded systems and education.
|
||||
|
||||
*NOTE for ADVENTURERS: raylib is a programming library to enjoy videogames programming; no fancy interface, no visual helpers, no debug button... just coding in the most pure spartan-programmers way.*
|
||||
|
||||
Ready to learn? Jump to [code examples!](https://www.raylib.com/examples.html)
|
||||
|
||||
---
|
||||
|
||||
<br>
|
||||
|
||||
[](https://github.com/raysan5/raylib/releases)
|
||||
[](https://github.com/raysan5/raylib/stargazers)
|
||||
[](https://github.com/raysan5/raylib/commits/master)
|
||||
[](https://github.com/sponsors/raysan5)
|
||||
[](https://repology.org/project/raylib/versions)
|
||||
[](LICENSE)
|
||||
|
||||
[](https://discord.gg/raylib)
|
||||
[](https://www.reddit.com/r/raylib/)
|
||||
[](https://www.youtube.com/c/raylib)
|
||||
[](https://www.twitch.tv/raysan5)
|
||||
|
||||
[](https://github.com/raysan5/raylib/actions?query=workflow%3AWindows)
|
||||
[](https://github.com/raysan5/raylib/actions?query=workflow%3ALinux)
|
||||
[](https://github.com/raysan5/raylib/actions?query=workflow%3AmacOS)
|
||||
[](https://github.com/raysan5/raylib/actions?query=workflow%3AAndroid)
|
||||
[](https://github.com/raysan5/raylib/actions?query=workflow%3AWebAssembly)
|
||||
|
||||
[](https://github.com/raysan5/raylib/actions?query=workflow%3ACMakeBuilds)
|
||||
[](https://github.com/raysan5/raylib/actions/workflows/windows_examples.yml)
|
||||
[](https://github.com/raysan5/raylib/actions/workflows/linux_examples.yml)
|
||||
|
||||
features
|
||||
--------
|
||||
- **NO external dependencies**, all required libraries are [bundled into raylib](https://github.com/raysan5/raylib/tree/master/src/external)
|
||||
- Multiple platforms supported: **Windows, Linux, MacOS, RPI, Android, HTML5... and more!**
|
||||
- Written in plain C code (C99) using PascalCase/camelCase notation
|
||||
- Hardware accelerated with OpenGL (**1.1, 2.1, 3.3, 4.3, ES 2.0 or ES 3.0**)
|
||||
- **Unique OpenGL abstraction layer** (usable as standalone module): [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h)
|
||||
- Multiple **Fonts** formats supported (TTF, Image fonts, AngelCode fonts)
|
||||
- Multiple texture formats supported, including **compressed formats** (DXT, ETC, ASTC)
|
||||
- **Full 3D support**, including 3D Shapes, Models, Billboards, Heightmaps and more!
|
||||
- Flexible Materials system, supporting classic maps and **PBR maps**
|
||||
- **Animated 3D models** supported (skeletal bones animation) (IQM)
|
||||
- Shaders support, including model and **postprocessing** shaders.
|
||||
- **Powerful math module** for Vector, Matrix and Quaternion operations: [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h)
|
||||
- Audio loading and playing with streaming support (WAV, OGG, MP3, FLAC, XM, MOD)
|
||||
- **VR stereo rendering** support with configurable HMD device parameters
|
||||
- Huge examples collection with [+120 code examples](https://github.com/raysan5/raylib/tree/master/examples)!
|
||||
- Bindings to [+60 programming languages](https://github.com/raysan5/raylib/blob/master/BINDINGS.md)!
|
||||
- **Free and open source**.
|
||||
|
||||
basic example
|
||||
--------------
|
||||
This is a basic raylib example, it creates a window and it draws the text `"Congrats! You created your first window!"` in the middle of the screen. Check this example [running live on web here](https://www.raylib.com/examples/core/loader.html?name=core_basic_window).
|
||||
```odin
|
||||
package example
|
||||
|
||||
import rl "vendor:raylib"
|
||||
|
||||
main :: proc() {
|
||||
rl.InitWindow(800, 450, "raylib [core] example - basic window")
|
||||
|
||||
for !rl.WindowShouldClose() {
|
||||
rl.BeginDrawing()
|
||||
rl.ClearBackground(rl.RAYWHITE)
|
||||
rl.DrawText("Congrats! You created your first window!", 190, 200, 20, rl.LIGHTGRAY)
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
rl.CloseWindow()
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
build and installation
|
||||
----------------------
|
||||
|
||||
raylib binary releases for Windows, Linux, macOS, Android and HTML5 are available at the [Github Releases page](https://github.com/raysan5/raylib/releases).
|
||||
|
||||
raylib is also available via multiple [package managers](https://github.com/raysan5/raylib/issues/613) on multiple OS distributions.
|
||||
|
||||
#### Installing and building raylib on multiple platforms
|
||||
|
||||
[raylib Wiki](https://github.com/raysan5/raylib/wiki#development-platforms) contains detailed instructions on building and usage on multiple platforms.
|
||||
|
||||
- [Working on Windows](https://github.com/raysan5/raylib/wiki/Working-on-Windows)
|
||||
- [Working on macOS](https://github.com/raysan5/raylib/wiki/Working-on-macOS)
|
||||
- [Working on GNU Linux](https://github.com/raysan5/raylib/wiki/Working-on-GNU-Linux)
|
||||
- [Working on Chrome OS](https://github.com/raysan5/raylib/wiki/Working-on-Chrome-OS)
|
||||
- [Working on FreeBSD](https://github.com/raysan5/raylib/wiki/Working-on-FreeBSD)
|
||||
- [Working on Raspberry Pi](https://github.com/raysan5/raylib/wiki/Working-on-Raspberry-Pi)
|
||||
- [Working for Android](https://github.com/raysan5/raylib/wiki/Working-for-Android)
|
||||
- [Working for Web (HTML5)](https://github.com/raysan5/raylib/wiki/Working-for-Web-(HTML5))
|
||||
- [Working anywhere with CMake](https://github.com/raysan5/raylib/wiki/Working-with-CMake)
|
||||
|
||||
*Note that the Wiki is open for edit, if you find some issues while building raylib for your target platform, feel free to edit the Wiki or open an issue related to it.*
|
||||
|
||||
#### Setup raylib with multiple IDEs
|
||||
|
||||
raylib has been developed on Windows platform using [Notepad++](https://notepad-plus-plus.org/) and [MinGW GCC](https://www.mingw-w64.org/) compiler but it can be used with other IDEs on multiple platforms.
|
||||
|
||||
[Projects directory](https://github.com/raysan5/raylib/tree/master/projects) contains several ready-to-use **project templates** to build raylib and code examples with multiple IDEs.
|
||||
|
||||
*Note that there are lots of IDEs supported, some of the provided templates could require some review, so please, if you find some issue with a template or you think they could be improved, feel free to send a PR or open a related issue.*
|
||||
|
||||
learning and docs
|
||||
------------------
|
||||
|
||||
raylib is designed to be learned using [the examples](https://github.com/raysan5/raylib/tree/master/examples) as the main reference. There is no standard API documentation but there is a [**cheatsheet**](https://www.raylib.com/cheatsheet/cheatsheet.html) containing all the functions available on the library a short description of each one of them, input parameters and result value names should be intuitive enough to understand how each function works.
|
||||
|
||||
Some additional documentation about raylib design can be found in raylib GitHub Wiki. Here are the relevant links:
|
||||
|
||||
- [raylib cheatsheet](https://www.raylib.com/cheatsheet/cheatsheet.html)
|
||||
- [raylib architecture](https://github.com/raysan5/raylib/wiki/raylib-architecture)
|
||||
- [raylib library design](https://github.com/raysan5/raylib/wiki)
|
||||
- [raylib examples collection](https://github.com/raysan5/raylib/tree/master/examples)
|
||||
- [raylib games collection](https://github.com/raysan5/raylib-games)
|
||||
|
||||
|
||||
contact and networks
|
||||
---------------------
|
||||
|
||||
raylib is present in several networks and raylib community is growing everyday. If you are using raylib and enjoying it, feel free to join us in any of these networks. The most active network is our [Discord server](https://discord.gg/raylib)! :)
|
||||
|
||||
- Webpage: [https://www.raylib.com](https://www.raylib.com)
|
||||
- Discord: [https://discord.gg/raylib](https://discord.gg/raylib)
|
||||
- Twitter: [https://www.twitter.com/raysan5](https://www.twitter.com/raysan5)
|
||||
- Twitch: [https://www.twitch.tv/raysan5](https://www.twitch.tv/raysan5)
|
||||
- Reddit: [https://www.reddit.com/r/raylib](https://www.reddit.com/r/raylib)
|
||||
- Patreon: [https://www.patreon.com/raylib](https://www.patreon.com/raylib)
|
||||
- YouTube: [https://www.youtube.com/channel/raylib](https://www.youtube.com/c/raylib)
|
||||
|
||||
license
|
||||
-------
|
||||
|
||||
raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified, BSD-like license that allows static linking with closed source software. Check [LICENSE](LICENSE) for further details.
|
||||
|
||||
raylib uses internally some libraries for window/graphics/inputs management and also to support different file formats loading, all those libraries are embedded with and are available in [src/external](https://github.com/raysan5/raylib/tree/master/src/external) directory. Check [raylib dependencies LICENSES](https://github.com/raysan5/raylib/wiki/raylib-dependencies) on raylib Wiki for details.
|
||||
223
vendor/raylib/v5.5/easings.odin
vendored
Normal file
223
vendor/raylib/v5.5/easings.odin
vendored
Normal file
@@ -0,0 +1,223 @@
|
||||
package raylib
|
||||
|
||||
import "core:math"
|
||||
|
||||
EaseLinearNone :: proc(t, b, c, d: f32) -> f32 { return (c*t/d + b) }
|
||||
EaseLinearIn :: proc(t, b, c, d: f32) -> f32 { return (c*t/d + b) }
|
||||
EaseLinearOut :: proc(t, b, c, d: f32) -> f32 { return (c*t/d + b) }
|
||||
EaseLinearInOut :: proc(t, b, c, d: f32) -> f32 { return (c*t/d + b) }
|
||||
|
||||
// Sine Easing functions
|
||||
EaseSineIn :: proc(t, b, c, d: f32) -> f32 { return (-c*math.cos(t/d*(PI/2.0)) + c + b) }
|
||||
EaseSineOut :: proc(t, b, c, d: f32) -> f32 { return (c*math.sin(t/d*(PI/2.0)) + b) }
|
||||
EaseSineInOut :: proc(t, b, c, d: f32) -> f32 { return (-c/2.0*(math.cos(PI*t/d) - 1.0) + b) }
|
||||
|
||||
// Circular Easing functions
|
||||
EaseCircIn :: proc(t, b, c, d: f32) -> f32 {
|
||||
t := t
|
||||
t /= d
|
||||
return -c*(math.sqrt(1.0 - t*t) - 1.0) + b
|
||||
}
|
||||
EaseCircOut :: proc(t, b, c, d: f32) -> f32 {
|
||||
t := t
|
||||
t = t/d - 1.0
|
||||
return c*math.sqrt(1.0 - t*t) + b
|
||||
}
|
||||
EaseCircInOut :: proc(t, b, c, d: f32) -> f32 {
|
||||
t := t
|
||||
t /= d/2.0
|
||||
if t < 1.0 {
|
||||
return -c/2.0*(math.sqrt(1.0 - t*t) - 1.0) + b
|
||||
}
|
||||
t -= 2.0
|
||||
return c/2.0*(math.sqrt(1.0 - t*t) + 1.0) + b
|
||||
}
|
||||
|
||||
// Cubic Easing functions
|
||||
EaseCubicIn :: proc(t, b, c, d: f32) -> f32 {
|
||||
t := t
|
||||
t /= d
|
||||
return c*t*t*t + b
|
||||
}
|
||||
EaseCubicOut :: proc(t, b, c, d: f32) -> f32 {
|
||||
t := t
|
||||
t = t/d - 1.0
|
||||
return c*(t*t*t + 1.0) + b
|
||||
}
|
||||
EaseCubicInOut :: proc(t, b, c, d: f32) -> f32 {
|
||||
t := t
|
||||
t /= d/2.0
|
||||
if t < 1.0 {
|
||||
return c/2.0*t*t*t + b
|
||||
}
|
||||
t -= 2.0
|
||||
return c/2.0*(t*t*t + 2.0) + b
|
||||
}
|
||||
|
||||
// Quadratic Easing functions
|
||||
EaseQuadIn :: proc(t, b, c, d: f32) -> f32 {
|
||||
t := t
|
||||
t /= d
|
||||
return c*t*t + b
|
||||
}
|
||||
EaseQuadOut :: proc(t, b, c, d: f32) -> f32 {
|
||||
t := t
|
||||
t /= d
|
||||
return -c*t*(t - 2.0) + b
|
||||
}
|
||||
EaseQuadInOut :: proc(t, b, c, d: f32) -> f32 {
|
||||
t := t
|
||||
t /= d/2.0
|
||||
if t < 1 {
|
||||
return ((c/2)*(t*t)) + b
|
||||
}
|
||||
return -c/2.0*(((t - 1.0)*(t - 3.0)) - 1.0) + b
|
||||
}
|
||||
|
||||
// Exponential Easing functions
|
||||
EaseExpoIn :: proc(t, b, c, d: f32) -> f32 {
|
||||
return (t == 0.0) ? b : (c*math.pow(2.0, 10.0*(t/d - 1.0)) + b)
|
||||
}
|
||||
EaseExpoOut :: proc(t, b, c, d: f32) -> f32 {
|
||||
return (t == d) ? (b + c) : (c*(-math.pow(2.0, -10.0*t/d) + 1.0) + b)
|
||||
}
|
||||
EaseExpoInOut :: proc(t, b, c, d: f32) -> f32 {
|
||||
if t == 0.0 {
|
||||
return b
|
||||
}
|
||||
if t == d {
|
||||
return b + c
|
||||
}
|
||||
t := t
|
||||
t /= d/2.0
|
||||
if t < 1.0 {
|
||||
return c/2.0*math.pow(2.0, 10.0*(t - 1.0)) + b
|
||||
}
|
||||
|
||||
return c/2.0*(-math.pow(2.0, -10.0*(t - 1.0)) + 2.0) + b
|
||||
}
|
||||
|
||||
// Back Easing functions
|
||||
EaseBackIn :: proc(t, b, c, d: f32) -> f32 {
|
||||
s :: 1.70158
|
||||
t := t
|
||||
t /= d
|
||||
postFix := t
|
||||
return (c*(postFix)*t*((s + 1.0)*t - s) + b)
|
||||
}
|
||||
|
||||
EaseBackOut :: proc(t, b, c, d: f32) -> f32 {
|
||||
t := t
|
||||
s :: 1.70158
|
||||
t = t/d - 1.0
|
||||
return (c*(t*t*((s + 1.0)*t + s) + 1.0) + b)
|
||||
}
|
||||
|
||||
EaseBackInOut :: proc(t, b, c, d: f32) -> f32 {
|
||||
t := t
|
||||
s := f32(1.70158)
|
||||
t /= d/2
|
||||
if t < 1.0 {
|
||||
s *= 1.525
|
||||
return (c/2.0*(t*t*((s + 1.0)*t - s)) + b)
|
||||
}
|
||||
|
||||
t -= 2
|
||||
postFix := t
|
||||
s *= 1.525
|
||||
return (c/2.0*((postFix)*t*((s + 1.0)*t + s) + 2.0) + b)
|
||||
}
|
||||
|
||||
// Bounce Easing functions
|
||||
EaseBounceOut :: proc(t, b, c, d: f32) -> f32 {
|
||||
t := t
|
||||
t /= d
|
||||
switch {
|
||||
case t < 1.0/2.75:
|
||||
return (c*(7.5625*t*t) + b)
|
||||
case t < 2.0/2.75:
|
||||
t -= 1.5/2.75
|
||||
postFix := t
|
||||
return (c*(7.5625*(postFix)*t + 0.75) + b)
|
||||
case t < 2.5/2.75:
|
||||
t -= 2.25/2.75
|
||||
postFix := t
|
||||
return (c*(7.5625*(postFix)*t + 0.9375) + b)
|
||||
case:
|
||||
t -= 2.625/2.75
|
||||
postFix := t
|
||||
return (c*(7.5625*(postFix)*t + 0.984375) + b)
|
||||
}
|
||||
}
|
||||
|
||||
EaseBounceIn :: proc(t, b, c, d: f32) -> f32 {
|
||||
return c - EaseBounceOut(d - t, 0.0, c, d) + b
|
||||
}
|
||||
EaseBounceInOut :: proc(t, b, c, d: f32) -> f32 {
|
||||
if t < d/2.0 {
|
||||
return EaseBounceIn(t*2.0, 0.0, c, d)*0.5 + b
|
||||
} else {
|
||||
return EaseBounceOut(t*2.0 - d, 0.0, c, d)*0.5 + c*0.5 + b
|
||||
}
|
||||
}
|
||||
|
||||
// Elastic Easing functions
|
||||
EaseElasticIn :: proc(t, b, c, d: f32) -> f32 {
|
||||
if t == 0.0 {
|
||||
return b
|
||||
}
|
||||
t := t
|
||||
t /= d
|
||||
if t == 1.0 {
|
||||
return b + c
|
||||
}
|
||||
|
||||
p := d*0.3
|
||||
a := c
|
||||
s := p/4.0
|
||||
t -= 1
|
||||
postFix := a*math.pow(2.0, 10.0*t)
|
||||
|
||||
return -(postFix*math.sin((t*d-s)*(2.0*PI)/p )) + b
|
||||
}
|
||||
|
||||
EaseElasticOut :: proc(t, b, c, d: f32) -> f32 {
|
||||
if t == 0.0 {
|
||||
return b
|
||||
}
|
||||
t := t
|
||||
t /= d
|
||||
if t == 1.0 {
|
||||
return b + c
|
||||
}
|
||||
|
||||
p := d*0.3
|
||||
a := c
|
||||
s := p/4.0
|
||||
|
||||
return a*math.pow(2.0,-10.0*t)*math.sin((t*d-s)*(2.0*PI)/p) + c + b
|
||||
}
|
||||
|
||||
EaseElasticInOut :: proc(t, b, c, d: f32) -> f32 {
|
||||
if t == 0.0 {
|
||||
return b
|
||||
}
|
||||
t := t
|
||||
t /= d/2.0
|
||||
if t == 2.0 {
|
||||
return b + c
|
||||
}
|
||||
|
||||
p := d*(0.3*1.5)
|
||||
a := c
|
||||
s := p/4.0
|
||||
|
||||
t -= 1
|
||||
if t < 1.0 {
|
||||
postFix := a*math.pow(2.0, 10.0*t)
|
||||
return -0.5*(postFix*math.sin((t*d-s)*(2.0*PI)/p)) + b
|
||||
}
|
||||
|
||||
postFix := a*math.pow(2.0, -10.0*t)
|
||||
return (postFix*math.sin((t*d-s)*(2.0*PI)/p)*0.5 + c + b)
|
||||
}
|
||||
0
vendor/raylib/linux/libraylib.so → vendor/raylib/v5.5/linux/libraylib.so
vendored
Executable file → Normal file
0
vendor/raylib/linux/libraylib.so → vendor/raylib/v5.5/linux/libraylib.so
vendored
Executable file → Normal file
0
vendor/raylib/linux/libraylib.so.5.5.0 → vendor/raylib/v5.5/linux/libraylib.so.5.5.0
vendored
Executable file → Normal file
0
vendor/raylib/linux/libraylib.so.5.5.0 → vendor/raylib/v5.5/linux/libraylib.so.5.5.0
vendored
Executable file → Normal file
0
vendor/raylib/linux/libraylib.so.550 → vendor/raylib/v5.5/linux/libraylib.so.550
vendored
Executable file → Normal file
0
vendor/raylib/linux/libraylib.so.550 → vendor/raylib/v5.5/linux/libraylib.so.550
vendored
Executable file → Normal file
0
vendor/raylib/macos/libraylib.5.5.0.dylib → vendor/raylib/v5.5/macos/libraylib.5.5.0.dylib
vendored
Executable file → Normal file
0
vendor/raylib/macos/libraylib.5.5.0.dylib → vendor/raylib/v5.5/macos/libraylib.5.5.0.dylib
vendored
Executable file → Normal file
0
vendor/raylib/macos/libraylib.550.dylib → vendor/raylib/v5.5/macos/libraylib.550.dylib
vendored
Executable file → Normal file
0
vendor/raylib/macos/libraylib.550.dylib → vendor/raylib/v5.5/macos/libraylib.550.dylib
vendored
Executable file → Normal file
0
vendor/raylib/macos/libraylib.dylib → vendor/raylib/v5.5/macos/libraylib.dylib
vendored
Executable file → Normal file
0
vendor/raylib/macos/libraylib.dylib → vendor/raylib/v5.5/macos/libraylib.dylib
vendored
Executable file → Normal file
566
vendor/raylib/v5.5/raygui.odin
vendored
Normal file
566
vendor/raylib/v5.5/raygui.odin
vendored
Normal file
@@ -0,0 +1,566 @@
|
||||
package raylib
|
||||
|
||||
import "core:c"
|
||||
|
||||
RAYGUI_SHARED :: #config(RAYGUI_SHARED, false)
|
||||
RAYGUI_WASM_LIB :: #config(RAYGUI_WASM_LIB, "wasm/libraygui.a")
|
||||
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib {
|
||||
"windows/rayguidll.lib" when RAYGUI_SHARED else "windows/raygui.lib",
|
||||
}
|
||||
} else when ODIN_OS == .Linux {
|
||||
foreign import lib {
|
||||
"linux/libraygui.so" when RAYGUI_SHARED else "linux/libraygui.a",
|
||||
}
|
||||
} else when ODIN_OS == .Darwin {
|
||||
when ODIN_ARCH == .arm64 {
|
||||
foreign import lib {
|
||||
"macos-arm64/libraygui.dylib" when RAYGUI_SHARED else "macos-arm64/libraygui.a",
|
||||
}
|
||||
} else {
|
||||
foreign import lib {
|
||||
"macos/libraygui.dylib" when RAYGUI_SHARED else "macos/libraygui.a",
|
||||
}
|
||||
}
|
||||
} else when ODIN_ARCH == .wasm32 || ODIN_ARCH == .wasm64p32 {
|
||||
foreign import lib {
|
||||
RAYGUI_WASM_LIB,
|
||||
}
|
||||
} else {
|
||||
foreign import lib "system:raygui"
|
||||
}
|
||||
|
||||
RAYGUI_VERSION :: "4.0"
|
||||
|
||||
// Gui control state
|
||||
GuiState :: enum c.int {
|
||||
STATE_NORMAL = 0,
|
||||
STATE_FOCUSED,
|
||||
STATE_PRESSED,
|
||||
STATE_DISABLED,
|
||||
}
|
||||
|
||||
// Gui control text alignment
|
||||
GuiTextAlignment :: enum c.int {
|
||||
TEXT_ALIGN_LEFT = 0,
|
||||
TEXT_ALIGN_CENTER,
|
||||
TEXT_ALIGN_RIGHT,
|
||||
}
|
||||
|
||||
GuiTextAlignmentVertical :: enum c.int {
|
||||
TEXT_ALIGN_TOP = 0,
|
||||
TEXT_ALIGN_MIDDLE,
|
||||
TEXT_ALIGN_BOTTOM,
|
||||
}
|
||||
|
||||
GuiTextWrapMode :: enum c.int {
|
||||
TEXT_WRAP_NONE = 0,
|
||||
TEXT_WRAP_CHAR,
|
||||
TEXT_WRAP_WORD,
|
||||
}
|
||||
|
||||
// Gui controls
|
||||
GuiControl :: enum c.int {
|
||||
// Default -> populates to all controls when set
|
||||
DEFAULT = 0,
|
||||
// Basic controls
|
||||
LABEL, // Used also for: LABELBUTTON
|
||||
BUTTON,
|
||||
TOGGLE, // Used also for: TOGGLEGROUP
|
||||
SLIDER, // Used also for: SLIDERBAR
|
||||
PROGRESSBAR,
|
||||
CHECKBOX,
|
||||
COMBOBOX,
|
||||
DROPDOWNBOX,
|
||||
TEXTBOX, // Used also for: TEXTBOXMULTI
|
||||
VALUEBOX,
|
||||
SPINNER, // Uses: BUTTON, VALUEBOX
|
||||
LISTVIEW,
|
||||
COLORPICKER,
|
||||
SCROLLBAR,
|
||||
STATUSBAR,
|
||||
}
|
||||
|
||||
// Gui base properties for every control
|
||||
// NOTE: RAYGUI_MAX_PROPS_BASE properties (by default 16 properties)
|
||||
GuiControlProperty :: enum c.int {
|
||||
BORDER_COLOR_NORMAL = 0,
|
||||
BASE_COLOR_NORMAL,
|
||||
TEXT_COLOR_NORMAL,
|
||||
BORDER_COLOR_FOCUSED,
|
||||
BASE_COLOR_FOCUSED,
|
||||
TEXT_COLOR_FOCUSED,
|
||||
BORDER_COLOR_PRESSED,
|
||||
BASE_COLOR_PRESSED,
|
||||
TEXT_COLOR_PRESSED,
|
||||
BORDER_COLOR_DISABLED,
|
||||
BASE_COLOR_DISABLED,
|
||||
TEXT_COLOR_DISABLED,
|
||||
BORDER_WIDTH,
|
||||
TEXT_PADDING,
|
||||
TEXT_ALIGNMENT,
|
||||
RESERVED,
|
||||
}
|
||||
|
||||
// Gui extended properties depend on control
|
||||
// NOTE: RAYGUI_MAX_PROPS_EXTENDED properties (by default, max 8 properties)
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// DEFAULT extended properties
|
||||
// NOTE: Those properties are common to all controls or global
|
||||
GuiDefaultProperty :: enum c.int {
|
||||
TEXT_SIZE = 16, // Text size (glyphs max height)
|
||||
TEXT_SPACING, // Text spacing between glyphs
|
||||
LINE_COLOR, // Line control color
|
||||
BACKGROUND_COLOR, // Background color
|
||||
TEXT_LINE_SPACING, // Text spacing between lines
|
||||
TEXT_ALIGNMENT_VERTICAL, // Text vertical alignment inside text bounds (after border and padding)
|
||||
TEXT_WRAP_MODE, // Text wrap-mode inside text bounds
|
||||
}
|
||||
|
||||
// Label
|
||||
//GuiLabelProperty :: enum c.int { }
|
||||
|
||||
// Button/Spinner
|
||||
//GuiButtonProperty :: enum c.int { }
|
||||
|
||||
// Toggle/ToggleGroup
|
||||
GuiToggleProperty :: enum c.int {
|
||||
GROUP_PADDING = 16, // ToggleGroup separation between toggles
|
||||
}
|
||||
|
||||
// Slider/SliderBar
|
||||
GuiSliderProperty :: enum c.int {
|
||||
SLIDER_WIDTH = 16, // Slider size of internal bar
|
||||
SLIDER_PADDING, // Slider/SliderBar internal bar padding
|
||||
}
|
||||
|
||||
// ProgressBar
|
||||
GuiProgressBarProperty :: enum c.int {
|
||||
PROGRESS_PADDING = 16, // ProgressBar internal padding
|
||||
}
|
||||
|
||||
// ScrollBar
|
||||
GuiScrollBarProperty :: enum c.int {
|
||||
ARROWS_SIZE = 16,
|
||||
ARROWS_VISIBLE,
|
||||
SCROLL_SLIDER_PADDING, // (SLIDERBAR, SLIDER_PADDING)
|
||||
SCROLL_SLIDER_SIZE,
|
||||
SCROLL_PADDING,
|
||||
SCROLL_SPEED,
|
||||
}
|
||||
|
||||
// CheckBox
|
||||
GuiCheckBoxProperty :: enum c.int {
|
||||
CHECK_PADDING = 16, // CheckBox internal check padding
|
||||
}
|
||||
|
||||
// ComboBox
|
||||
GuiComboBoxProperty :: enum c.int {
|
||||
COMBO_BUTTON_WIDTH = 16, // ComboBox right button width
|
||||
COMBO_BUTTON_SPACING, // ComboBox button separation
|
||||
}
|
||||
|
||||
// DropdownBox
|
||||
GuiDropdownBoxProperty :: enum c.int {
|
||||
ARROW_PADDING = 16, // DropdownBox arrow separation from border and items
|
||||
DROPDOWN_ITEMS_SPACING, // DropdownBox items separation
|
||||
}
|
||||
|
||||
// TextBox/TextBoxMulti/ValueBox/Spinner
|
||||
GuiTextBoxProperty :: enum c.int {
|
||||
TEXT_READONLY = 16, // TextBox in read-only mode: 0-text editable, 1-text no-editable
|
||||
}
|
||||
|
||||
// Spinner
|
||||
GuiSpinnerProperty :: enum c.int {
|
||||
SPIN_BUTTON_WIDTH = 16, // Spinner left/right buttons width
|
||||
SPIN_BUTTON_SPACING, // Spinner buttons separation
|
||||
}
|
||||
|
||||
// ListView
|
||||
GuiListViewProperty :: enum c.int {
|
||||
LIST_ITEMS_HEIGHT = 16, // ListView items height
|
||||
LIST_ITEMS_SPACING, // ListView items separation
|
||||
SCROLLBAR_WIDTH, // ListView scrollbar size (usually width)
|
||||
SCROLLBAR_SIDE, // ListView scrollbar side (0-left, 1-right)
|
||||
}
|
||||
|
||||
// ColorPicker
|
||||
GuiColorPickerProperty :: enum c.int {
|
||||
COLOR_SELECTOR_SIZE = 16,
|
||||
HUEBAR_WIDTH, // ColorPicker right hue bar width
|
||||
HUEBAR_PADDING, // ColorPicker right hue bar separation from panel
|
||||
HUEBAR_SELECTOR_HEIGHT, // ColorPicker right hue bar selector height
|
||||
HUEBAR_SELECTOR_OVERFLOW, // ColorPicker right hue bar selector overflow
|
||||
}
|
||||
|
||||
SCROLLBAR_LEFT_SIDE :: 0
|
||||
SCROLLBAR_RIGHT_SIDE :: 1
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Global Variables Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
// ...
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Declaration
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
@(default_calling_convention="c")
|
||||
foreign lib {
|
||||
// WASM does not have foreign variable declarations.
|
||||
when ODIN_ARCH != .wasm32 && ODIN_ARCH != .wasm64p32 {
|
||||
@(link_name="raylib_version") version: cstring
|
||||
}
|
||||
// Global gui state control functions
|
||||
|
||||
GuiEnable :: proc() --- // Enable gui controls (global state)
|
||||
GuiLock :: proc() --- // Lock gui controls (global state)
|
||||
GuiDisable :: proc() --- // Disable gui controls (global state)
|
||||
GuiUnlock :: proc() --- // Unlock gui controls (global state)
|
||||
GuiIsLocked :: proc() -> bool --- // Check if gui is locked (global state)
|
||||
GuiSetAlpha :: proc(alpha: f32) --- // Set gui controls alpha (global state), alpha goes from 0.0f to 1.0f
|
||||
GuiSetState :: proc(state: c.int) --- // Set gui state (global state)
|
||||
GuiGetState :: proc() -> c.int --- // Get gui state (global state)
|
||||
|
||||
// Font set/get functions
|
||||
|
||||
GuiSetFont :: proc(font: Font) --- // Set gui custom font (global state)
|
||||
GuiGetFont :: proc() -> Font --- // Get gui custom font (global state)
|
||||
|
||||
// Style set/get functions
|
||||
|
||||
GuiSetStyle :: proc(control: GuiControl, property: c.int, value: c.int) --- // Set one style property
|
||||
GuiGetStyle :: proc(control: GuiControl, property: c.int) -> c.int --- // Get one style property
|
||||
|
||||
// Styles loading functions
|
||||
|
||||
GuiLoadStyle :: proc(fileName: cstring) --- // Load style file over global style variable (.rgs)
|
||||
GuiLoadStyleDefault :: proc() --- // Load style default over global style
|
||||
|
||||
// Tooltips management functions
|
||||
|
||||
GuiEnableTooltip :: proc() --- // Enable gui tooltips (global state)
|
||||
GuiDisableTooltip :: proc() --- // Disable gui tooltips (global state)
|
||||
GuiSetTooltip :: proc(tooltip: cstring) --- // Set tooltip string
|
||||
|
||||
// Icons functionality
|
||||
|
||||
GuiIconText :: proc(iconId: GuiIconName, text: cstring) -> cstring --- // Get text with icon id prepended (if supported)
|
||||
GuiSetIconScale :: proc(scale: c.int) --- // Set default icon drawing size
|
||||
GuiGetIcons :: proc() -> [^]u32 --- // Get raygui icons data pointer
|
||||
GuiLoadIcons :: proc(fileName: cstring, loadIconsName: bool) -> [^]cstring --- // Load raygui icons file (.rgi) into internal icons data
|
||||
GuiDrawIcon :: proc(iconId: GuiIconName, posX, posY: c.int, pixelSize: c.int, color: Color) --- // Draw icon using pixel size at specified position
|
||||
|
||||
|
||||
// Controls
|
||||
//----------------------------------------------------------------------------------------------------------
|
||||
// Container/separator controls, useful for controls organization
|
||||
|
||||
GuiWindowBox :: proc(bounds: Rectangle, title: cstring) -> c.int --- // Window Box control, shows a window that can be closed
|
||||
GuiGroupBox :: proc(bounds: Rectangle, text: cstring) -> c.int --- // Group Box control with text name
|
||||
GuiLine :: proc(bounds: Rectangle, text: cstring) -> c.int --- // Line separator control, could contain text
|
||||
GuiPanel :: proc(bounds: Rectangle, text: cstring) -> c.int --- // Panel control, useful to group controls
|
||||
GuiTabBar :: proc(bounds: Rectangle, text: [^]cstring, count: c.int, active: ^c.int) -> c.int --- // Tab Bar control, returns TAB to be closed or -1
|
||||
GuiScrollPanel :: proc(bounds: Rectangle, text: cstring, content: Rectangle, scroll: ^Vector2, view: ^Rectangle) -> c.int --- // Scroll Panel control
|
||||
|
||||
// Basic controls set
|
||||
|
||||
GuiLabel :: proc(bounds: Rectangle, text: cstring) -> c.int --- // Label control, shows text
|
||||
GuiButton :: proc(bounds: Rectangle, text: cstring) -> bool --- // Button control, returns true when clicked
|
||||
GuiLabelButton :: proc(bounds: Rectangle, text: cstring) -> bool --- // Label button control, show true when clicked
|
||||
GuiToggle :: proc(bounds: Rectangle, text: cstring, active: ^bool) -> c.int --- // Toggle Button control, returns true when active
|
||||
GuiToggleGroup :: proc(bounds: Rectangle, text: cstring, active: ^c.int) -> c.int --- // Toggle Group control, returns active toggle index
|
||||
GuiToggleSlider :: proc(bounds: Rectangle, text: cstring, active: ^c.int) -> c.int ---
|
||||
GuiCheckBox :: proc(bounds: Rectangle, text: cstring, checked: ^bool) -> bool --- // Check Box control, returns true when active
|
||||
GuiComboBox :: proc(bounds: Rectangle, text: cstring, active: ^c.int) -> c.int --- // Combo Box control, returns selected item index
|
||||
|
||||
GuiDropdownBox :: proc(bounds: Rectangle, text: cstring, active: ^c.int, editMode: bool) -> bool --- // Dropdown Box control, returns selected item
|
||||
GuiSpinner :: proc(bounds: Rectangle, text: cstring, value: ^c.int, minValue, maxValue: c.int, editMode: bool) -> c.int --- // Spinner control, returns selected value
|
||||
GuiValueBox :: proc(bounds: Rectangle, text: cstring, value: ^c.int, minValue, maxValue: c.int, editMode: bool) -> c.int --- // Value Box control, updates input text with numbers
|
||||
GuiTextBox :: proc(bounds: Rectangle, text: cstring, textSize: c.int, editMode: bool) -> bool --- // Text Box control, updates input text
|
||||
|
||||
GuiSlider :: proc(bounds: Rectangle, textLeft: cstring, textRight: cstring, value: ^f32, minValue: f32, maxValue: f32) -> c.int --- // Slider control, returns selected value
|
||||
GuiSliderBar :: proc(bounds: Rectangle, textLeft: cstring, textRight: cstring, value: ^f32, minValue: f32, maxValue: f32) -> c.int --- // Slider Bar control, returns selected value
|
||||
GuiProgressBar :: proc(bounds: Rectangle, textLeft: cstring, textRight: cstring, value: ^f32, minValue: f32, maxValue: f32) -> c.int --- // Progress Bar control, shows current progress value
|
||||
GuiStatusBar :: proc(bounds: Rectangle, text: cstring) -> c.int --- // Status Bar control, shows info text
|
||||
GuiDummyRec :: proc(bounds: Rectangle, text: cstring) -> c.int --- // Dummy control for placeholders
|
||||
GuiGrid :: proc(bounds: Rectangle, text: cstring, spacing: f32, subdivs: c.int, mouseCell: ^Vector2) -> c.int --- // Grid control, returns mouse cell position
|
||||
|
||||
// Advance controls set
|
||||
GuiListView :: proc(bounds: Rectangle, text: cstring, scrollIndex: ^c.int, active: ^c.int) -> c.int --- // List View control, returns selected list item index
|
||||
GuiListViewEx :: proc(bounds: Rectangle, text:[^]cstring, count: c.int, scrollIndex: ^c.int, active: ^c.int, focus: ^c.int) -> c.int --- // List View with extended parameters
|
||||
GuiMessageBox :: proc(bounds: Rectangle, title: cstring, message: cstring, buttons: cstring) -> c.int --- // Message Box control, displays a message
|
||||
GuiTextInputBox :: proc(bounds: Rectangle, title: cstring, message: cstring, buttons: cstring, text: cstring, textMaxSize: c.int, secretViewActive: ^bool) -> c.int --- // Text Input Box control, ask for text, supports secret
|
||||
GuiColorPicker :: proc(bounds: Rectangle, text: cstring, color: ^Color) -> c.int --- // Color Picker control (multiple color controls)
|
||||
GuiColorPanel :: proc(bounds: Rectangle, text: cstring, color: ^Color) -> c.int --- // Color Panel control
|
||||
GuiColorBarAlpha :: proc(bounds: Rectangle, text: cstring, alpha: ^f32) -> c.int --- // Color Bar Alpha control
|
||||
GuiColorBarHue :: proc(bounds: Rectangle, text: cstring, value: ^f32) -> c.int --- // Color Bar Hue control
|
||||
GuiColorPickerHSV :: proc(bounds: Rectangle, text: cstring, colorHsv: ^Vector3) -> c.int --- // Color Picker control that avoids conversion to RGB on each call (multiple color controls)
|
||||
GuiColorPanelHSV :: proc(bounds: Rectangle, text: cstring, colorHsv: ^Vector3) -> c.int --- // Color Panel control that returns HSV color value, used by GuiColorPickerHSV()
|
||||
//----------------------------------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Icons enumeration
|
||||
//----------------------------------------------------------------------------------
|
||||
GuiIconName :: enum c.int {
|
||||
ICON_NONE = 0,
|
||||
ICON_FOLDER_FILE_OPEN = 1,
|
||||
ICON_FILE_SAVE_CLASSIC = 2,
|
||||
ICON_FOLDER_OPEN = 3,
|
||||
ICON_FOLDER_SAVE = 4,
|
||||
ICON_FILE_OPEN = 5,
|
||||
ICON_FILE_SAVE = 6,
|
||||
ICON_FILE_EXPORT = 7,
|
||||
ICON_FILE_ADD = 8,
|
||||
ICON_FILE_DELETE = 9,
|
||||
ICON_FILETYPE_TEXT = 10,
|
||||
ICON_FILETYPE_AUDIO = 11,
|
||||
ICON_FILETYPE_IMAGE = 12,
|
||||
ICON_FILETYPE_PLAY = 13,
|
||||
ICON_FILETYPE_VIDEO = 14,
|
||||
ICON_FILETYPE_INFO = 15,
|
||||
ICON_FILE_COPY = 16,
|
||||
ICON_FILE_CUT = 17,
|
||||
ICON_FILE_PASTE = 18,
|
||||
ICON_CURSOR_HAND = 19,
|
||||
ICON_CURSOR_POINTER = 20,
|
||||
ICON_CURSOR_CLASSIC = 21,
|
||||
ICON_PENCIL = 22,
|
||||
ICON_PENCIL_BIG = 23,
|
||||
ICON_BRUSH_CLASSIC = 24,
|
||||
ICON_BRUSH_PAINTER = 25,
|
||||
ICON_WATER_DROP = 26,
|
||||
ICON_COLOR_PICKER = 27,
|
||||
ICON_RUBBER = 28,
|
||||
ICON_COLOR_BUCKET = 29,
|
||||
ICON_TEXT_T = 30,
|
||||
ICON_TEXT_A = 31,
|
||||
ICON_SCALE = 32,
|
||||
ICON_RESIZE = 33,
|
||||
ICON_FILTER_POINT = 34,
|
||||
ICON_FILTER_BILINEAR = 35,
|
||||
ICON_CROP = 36,
|
||||
ICON_CROP_ALPHA = 37,
|
||||
ICON_SQUARE_TOGGLE = 38,
|
||||
ICON_SYMMETRY = 39,
|
||||
ICON_SYMMETRY_HORIZONTAL = 40,
|
||||
ICON_SYMMETRY_VERTICAL = 41,
|
||||
ICON_LENS = 42,
|
||||
ICON_LENS_BIG = 43,
|
||||
ICON_EYE_ON = 44,
|
||||
ICON_EYE_OFF = 45,
|
||||
ICON_FILTER_TOP = 46,
|
||||
ICON_FILTER = 47,
|
||||
ICON_TARGET_POINT = 48,
|
||||
ICON_TARGET_SMALL = 49,
|
||||
ICON_TARGET_BIG = 50,
|
||||
ICON_TARGET_MOVE = 51,
|
||||
ICON_CURSOR_MOVE = 52,
|
||||
ICON_CURSOR_SCALE = 53,
|
||||
ICON_CURSOR_SCALE_RIGHT = 54,
|
||||
ICON_CURSOR_SCALE_LEFT = 55,
|
||||
ICON_UNDO = 56,
|
||||
ICON_REDO = 57,
|
||||
ICON_REREDO = 58,
|
||||
ICON_MUTATE = 59,
|
||||
ICON_ROTATE = 60,
|
||||
ICON_REPEAT = 61,
|
||||
ICON_SHUFFLE = 62,
|
||||
ICON_EMPTYBOX = 63,
|
||||
ICON_TARGET = 64,
|
||||
ICON_TARGET_SMALL_FILL = 65,
|
||||
ICON_TARGET_BIG_FILL = 66,
|
||||
ICON_TARGET_MOVE_FILL = 67,
|
||||
ICON_CURSOR_MOVE_FILL = 68,
|
||||
ICON_CURSOR_SCALE_FILL = 69,
|
||||
ICON_CURSOR_SCALE_RIGHT_FILL = 70,
|
||||
ICON_CURSOR_SCALE_LEFT_FILL = 71,
|
||||
ICON_UNDO_FILL = 72,
|
||||
ICON_REDO_FILL = 73,
|
||||
ICON_REREDO_FILL = 74,
|
||||
ICON_MUTATE_FILL = 75,
|
||||
ICON_ROTATE_FILL = 76,
|
||||
ICON_REPEAT_FILL = 77,
|
||||
ICON_SHUFFLE_FILL = 78,
|
||||
ICON_EMPTYBOX_SMALL = 79,
|
||||
ICON_BOX = 80,
|
||||
ICON_BOX_TOP = 81,
|
||||
ICON_BOX_TOP_RIGHT = 82,
|
||||
ICON_BOX_RIGHT = 83,
|
||||
ICON_BOX_BOTTOM_RIGHT = 84,
|
||||
ICON_BOX_BOTTOM = 85,
|
||||
ICON_BOX_BOTTOM_LEFT = 86,
|
||||
ICON_BOX_LEFT = 87,
|
||||
ICON_BOX_TOP_LEFT = 88,
|
||||
ICON_BOX_CENTER = 89,
|
||||
ICON_BOX_CIRCLE_MASK = 90,
|
||||
ICON_POT = 91,
|
||||
ICON_ALPHA_MULTIPLY = 92,
|
||||
ICON_ALPHA_CLEAR = 93,
|
||||
ICON_DITHERING = 94,
|
||||
ICON_MIPMAPS = 95,
|
||||
ICON_BOX_GRID = 96,
|
||||
ICON_GRID = 97,
|
||||
ICON_BOX_CORNERS_SMALL = 98,
|
||||
ICON_BOX_CORNERS_BIG = 99,
|
||||
ICON_FOUR_BOXES = 100,
|
||||
ICON_GRID_FILL = 101,
|
||||
ICON_BOX_MULTISIZE = 102,
|
||||
ICON_ZOOM_SMALL = 103,
|
||||
ICON_ZOOM_MEDIUM = 104,
|
||||
ICON_ZOOM_BIG = 105,
|
||||
ICON_ZOOM_ALL = 106,
|
||||
ICON_ZOOM_CENTER = 107,
|
||||
ICON_BOX_DOTS_SMALL = 108,
|
||||
ICON_BOX_DOTS_BIG = 109,
|
||||
ICON_BOX_CONCENTRIC = 110,
|
||||
ICON_BOX_GRID_BIG = 111,
|
||||
ICON_OK_TICK = 112,
|
||||
ICON_CROSS = 113,
|
||||
ICON_ARROW_LEFT = 114,
|
||||
ICON_ARROW_RIGHT = 115,
|
||||
ICON_ARROW_DOWN = 116,
|
||||
ICON_ARROW_UP = 117,
|
||||
ICON_ARROW_LEFT_FILL = 118,
|
||||
ICON_ARROW_RIGHT_FILL = 119,
|
||||
ICON_ARROW_DOWN_FILL = 120,
|
||||
ICON_ARROW_UP_FILL = 121,
|
||||
ICON_AUDIO = 122,
|
||||
ICON_FX = 123,
|
||||
ICON_WAVE = 124,
|
||||
ICON_WAVE_SINUS = 125,
|
||||
ICON_WAVE_SQUARE = 126,
|
||||
ICON_WAVE_TRIANGULAR = 127,
|
||||
ICON_CROSS_SMALL = 128,
|
||||
ICON_PLAYER_PREVIOUS = 129,
|
||||
ICON_PLAYER_PLAY_BACK = 130,
|
||||
ICON_PLAYER_PLAY = 131,
|
||||
ICON_PLAYER_PAUSE = 132,
|
||||
ICON_PLAYER_STOP = 133,
|
||||
ICON_PLAYER_NEXT = 134,
|
||||
ICON_PLAYER_RECORD = 135,
|
||||
ICON_MAGNET = 136,
|
||||
ICON_LOCK_CLOSE = 137,
|
||||
ICON_LOCK_OPEN = 138,
|
||||
ICON_CLOCK = 139,
|
||||
ICON_TOOLS = 140,
|
||||
ICON_GEAR = 141,
|
||||
ICON_GEAR_BIG = 142,
|
||||
ICON_BIN = 143,
|
||||
ICON_HAND_POINTER = 144,
|
||||
ICON_LASER = 145,
|
||||
ICON_COIN = 146,
|
||||
ICON_EXPLOSION = 147,
|
||||
ICON_1UP = 148,
|
||||
ICON_PLAYER = 149,
|
||||
ICON_PLAYER_JUMP = 150,
|
||||
ICON_KEY = 151,
|
||||
ICON_DEMON = 152,
|
||||
ICON_TEXT_POPUP = 153,
|
||||
ICON_GEAR_EX = 154,
|
||||
ICON_CRACK = 155,
|
||||
ICON_CRACK_POINTS = 156,
|
||||
ICON_STAR = 157,
|
||||
ICON_DOOR = 158,
|
||||
ICON_EXIT = 159,
|
||||
ICON_MODE_2D = 160,
|
||||
ICON_MODE_3D = 161,
|
||||
ICON_CUBE = 162,
|
||||
ICON_CUBE_FACE_TOP = 163,
|
||||
ICON_CUBE_FACE_LEFT = 164,
|
||||
ICON_CUBE_FACE_FRONT = 165,
|
||||
ICON_CUBE_FACE_BOTTOM = 166,
|
||||
ICON_CUBE_FACE_RIGHT = 167,
|
||||
ICON_CUBE_FACE_BACK = 168,
|
||||
ICON_CAMERA = 169,
|
||||
ICON_SPECIAL = 170,
|
||||
ICON_LINK_NET = 171,
|
||||
ICON_LINK_BOXES = 172,
|
||||
ICON_LINK_MULTI = 173,
|
||||
ICON_LINK = 174,
|
||||
ICON_LINK_BROKE = 175,
|
||||
ICON_TEXT_NOTES = 176,
|
||||
ICON_NOTEBOOK = 177,
|
||||
ICON_SUITCASE = 178,
|
||||
ICON_SUITCASE_ZIP = 179,
|
||||
ICON_MAILBOX = 180,
|
||||
ICON_MONITOR = 181,
|
||||
ICON_PRINTER = 182,
|
||||
ICON_PHOTO_CAMERA = 183,
|
||||
ICON_PHOTO_CAMERA_FLASH = 184,
|
||||
ICON_HOUSE = 185,
|
||||
ICON_HEART = 186,
|
||||
ICON_CORNER = 187,
|
||||
ICON_VERTICAL_BARS = 188,
|
||||
ICON_VERTICAL_BARS_FILL = 189,
|
||||
ICON_LIFE_BARS = 190,
|
||||
ICON_INFO = 191,
|
||||
ICON_CROSSLINE = 192,
|
||||
ICON_HELP = 193,
|
||||
ICON_FILETYPE_ALPHA = 194,
|
||||
ICON_FILETYPE_HOME = 195,
|
||||
ICON_LAYERS_VISIBLE = 196,
|
||||
ICON_LAYERS = 197,
|
||||
ICON_WINDOW = 198,
|
||||
ICON_HIDPI = 199,
|
||||
ICON_FILETYPE_BINARY = 200,
|
||||
ICON_HEX = 201,
|
||||
ICON_SHIELD = 202,
|
||||
ICON_FILE_NEW = 203,
|
||||
ICON_FOLDER_ADD = 204,
|
||||
ICON_ALARM = 205,
|
||||
ICON_CPU = 206,
|
||||
ICON_ROM = 207,
|
||||
ICON_STEP_OVER = 208,
|
||||
ICON_STEP_INTO = 209,
|
||||
ICON_STEP_OUT = 210,
|
||||
ICON_RESTART = 211,
|
||||
ICON_BREAKPOINT_ON = 212,
|
||||
ICON_BREAKPOINT_OFF = 213,
|
||||
ICON_BURGER_MENU = 214,
|
||||
ICON_CASE_SENSITIVE = 215,
|
||||
ICON_REG_EXP = 216,
|
||||
ICON_FOLDER = 217,
|
||||
ICON_FILE = 218,
|
||||
ICON_SAND_TIMER = 219,
|
||||
ICON_220 = 220,
|
||||
ICON_221 = 221,
|
||||
ICON_222 = 222,
|
||||
ICON_223 = 223,
|
||||
ICON_224 = 224,
|
||||
ICON_225 = 225,
|
||||
ICON_226 = 226,
|
||||
ICON_227 = 227,
|
||||
ICON_228 = 228,
|
||||
ICON_229 = 229,
|
||||
ICON_230 = 230,
|
||||
ICON_231 = 231,
|
||||
ICON_232 = 232,
|
||||
ICON_233 = 233,
|
||||
ICON_234 = 234,
|
||||
ICON_235 = 235,
|
||||
ICON_236 = 236,
|
||||
ICON_237 = 237,
|
||||
ICON_238 = 238,
|
||||
ICON_239 = 239,
|
||||
ICON_240 = 240,
|
||||
ICON_241 = 241,
|
||||
ICON_242 = 242,
|
||||
ICON_243 = 243,
|
||||
ICON_244 = 244,
|
||||
ICON_245 = 245,
|
||||
ICON_246 = 246,
|
||||
ICON_247 = 247,
|
||||
ICON_248 = 248,
|
||||
ICON_249 = 249,
|
||||
ICON_250 = 250,
|
||||
ICON_251 = 251,
|
||||
ICON_252 = 252,
|
||||
ICON_253 = 253,
|
||||
ICON_254 = 254,
|
||||
ICON_255 = 255,
|
||||
}
|
||||
1813
vendor/raylib/v5.5/raylib.odin
vendored
Normal file
1813
vendor/raylib/v5.5/raylib.odin
vendored
Normal file
File diff suppressed because it is too large
Load Diff
839
vendor/raylib/v5.5/raymath.odin
vendored
Normal file
839
vendor/raylib/v5.5/raymath.odin
vendored
Normal file
@@ -0,0 +1,839 @@
|
||||
package raylib
|
||||
|
||||
import "core:math"
|
||||
import "core:math/linalg"
|
||||
|
||||
EPSILON :: 0.000001
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Definition - Utils math
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// Clamp float value
|
||||
@(require_results)
|
||||
Clamp :: proc "c" (value: f32, min, max: f32) -> f32 {
|
||||
return clamp(value, min, max)
|
||||
}
|
||||
|
||||
// Calculate linear interpolation between two floats
|
||||
@(require_results)
|
||||
Lerp :: proc "c" (start, end: f32, amount: f32) -> f32 {
|
||||
return start*(1-amount) + end*amount
|
||||
}
|
||||
|
||||
// Normalize input value within input range
|
||||
@(require_results)
|
||||
Normalize :: proc "c" (value: f32, start, end: f32) -> f32 {
|
||||
return (value - start) / (end - start)
|
||||
}
|
||||
|
||||
// Remap input value within input range to output range
|
||||
@(require_results)
|
||||
Remap :: proc "c" (value: f32, inputStart, inputEnd: f32, outputStart, outputEnd: f32) -> f32 {
|
||||
return (value - inputStart)/(inputEnd - inputStart)*(outputEnd - outputStart) + outputStart
|
||||
}
|
||||
|
||||
// Wrap input value from min to max
|
||||
@(require_results)
|
||||
Wrap :: proc "c" (value: f32, min, max: f32) -> f32 {
|
||||
return value - (max - min)*math.floor((value - min)/(max - min))
|
||||
}
|
||||
|
||||
// Check whether two given floats are almost equal
|
||||
@(require_results)
|
||||
FloatEquals :: proc "c" (x, y: f32) -> bool {
|
||||
return abs(x - y) <= EPSILON*fmaxf(1.0, fmaxf(abs(x), abs(y)))
|
||||
}
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Definition - Vector2 math
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// Vector with components value 0.0
|
||||
@(require_results, deprecated="Prefer Vector2(0)")
|
||||
Vector2Zero :: proc "c" () -> Vector2 {
|
||||
return Vector2(0)
|
||||
}
|
||||
// Vector with components value 1.0
|
||||
@(require_results, deprecated="Prefer Vector2(1)")
|
||||
Vector2One :: proc "c" () -> Vector2 {
|
||||
return Vector2(1)
|
||||
}
|
||||
// Add two vectors (v1 + v2)
|
||||
@(require_results, deprecated="Prefer v1 + v2")
|
||||
Vector2Add :: proc "c" (v1, v2: Vector2) -> Vector2 {
|
||||
return v1 + v2
|
||||
}
|
||||
// Add vector and float value
|
||||
@(require_results, deprecated="Prefer v + value")
|
||||
Vector2AddValue :: proc "c" (v: Vector2, value: f32) -> Vector2 {
|
||||
return v + value
|
||||
}
|
||||
// Subtract two vectors (v1 - v2)
|
||||
@(require_results, deprecated="Prefer a - b")
|
||||
Vector2Subtract :: proc "c" (a, b: Vector2) -> Vector2 {
|
||||
return a - b
|
||||
}
|
||||
// Subtract vector by float value
|
||||
@(require_results, deprecated="Prefer v + value")
|
||||
Vector2SubtractValue :: proc "c" (v: Vector2, value: f32) -> Vector2 {
|
||||
return v - value
|
||||
}
|
||||
// Calculate vector length
|
||||
@(require_results)
|
||||
Vector2Length :: proc "c" (v: Vector2) -> f32 {
|
||||
return linalg.length(v)
|
||||
}
|
||||
// Calculate vector square length
|
||||
@(require_results)
|
||||
Vector2LengthSqr :: proc "c" (v: Vector2) -> f32 {
|
||||
return linalg.length2(v)
|
||||
}
|
||||
// Calculate two vectors dot product
|
||||
@(require_results)
|
||||
Vector2DotProduct :: proc "c" (v1, v2: Vector2) -> f32 {
|
||||
return linalg.dot(v1, v2)
|
||||
}
|
||||
// Calculate distance between two vectors
|
||||
@(require_results)
|
||||
Vector2Distance :: proc "c" (v1, v2: Vector2) -> f32 {
|
||||
return linalg.distance(v1, v2)
|
||||
}
|
||||
// Calculate square distance between two vectors
|
||||
@(require_results)
|
||||
Vector2DistanceSqrt :: proc "c" (v1, v2: Vector2) -> f32 {
|
||||
return linalg.length2(v2-v1)
|
||||
}
|
||||
// Calculate angle between two vectors
|
||||
// NOTE: Angle is calculated from origin point (0, 0)
|
||||
@(require_results)
|
||||
Vector2Angle :: proc "c" (v1, v2: Vector2) -> f32 {
|
||||
return linalg.angle_between(v1, v2)
|
||||
}
|
||||
|
||||
// Calculate angle defined by a two vectors line
|
||||
// NOTE: Parameters need to be normalized
|
||||
// Current implementation should be aligned with glm::angle
|
||||
@(require_results)
|
||||
Vector2LineAngle :: proc "c" (start, end: Vector2) -> f32 {
|
||||
// TODO(10/9/2023): Currently angles move clockwise, determine if this is wanted behavior
|
||||
return -math.atan2(end.y - start.y, end.x - start.x)
|
||||
}
|
||||
|
||||
// Scale vector (multiply by value)
|
||||
@(require_results, deprecated="Prefer v * scale")
|
||||
Vector2Scale :: proc "c" (v: Vector2, scale: f32) -> Vector2 {
|
||||
return v * scale
|
||||
}
|
||||
// Multiply vector by vector
|
||||
@(require_results, deprecated="Prefer v1 * v2")
|
||||
Vector2Multiply :: proc "c" (v1, v2: Vector2) -> Vector2 {
|
||||
return v1 * v2
|
||||
}
|
||||
// Negate vector
|
||||
@(require_results, deprecated="Prefer -v")
|
||||
Vector2Negate :: proc "c" (v: Vector2) -> Vector2 {
|
||||
return -v
|
||||
}
|
||||
// Divide vector by vector
|
||||
@(require_results, deprecated="Prefer v1 / v2")
|
||||
Vector2Divide :: proc "c" (v1, v2: Vector2) -> Vector2 {
|
||||
return v1 / v2
|
||||
}
|
||||
// Normalize provided vector
|
||||
@(require_results)
|
||||
Vector2Normalize :: proc "c" (v: Vector2) -> Vector2 {
|
||||
return linalg.normalize0(v)
|
||||
}
|
||||
// Transforms a Vector2 by a given Matrix
|
||||
@(require_results)
|
||||
Vector2Transform :: proc "c" (v: Vector2, m: Matrix) -> Vector2 {
|
||||
v4 := Vector4{v.x, v.y, 0, 1}
|
||||
return (m * v4).xy
|
||||
}
|
||||
// Calculate linear interpolation between two vectors
|
||||
@(require_results, deprecated="Prefer = linalg.lerp(v1, v2, amount)")
|
||||
Vector2Lerp :: proc "c" (v1, v2: Vector2, amount: f32) -> Vector2 {
|
||||
return linalg.lerp(v1, v2, Vector2(amount))
|
||||
}
|
||||
// Calculate reflected vector to normal
|
||||
@(require_results, deprecated="Prefer = linalg.reflect(v, normal)")
|
||||
Vector2Reflect :: proc "c" (v, normal: Vector2) -> Vector2 {
|
||||
return linalg.reflect(v, normal)
|
||||
}
|
||||
// Rotate vector by angle
|
||||
@(require_results)
|
||||
Vector2Rotate :: proc "c" (v: Vector2, angle: f32) -> Vector2 {
|
||||
c, s := math.cos(angle), math.sin(angle)
|
||||
|
||||
return Vector2{
|
||||
v.x*c - v.y*s,
|
||||
v.x*s + v.y*c,
|
||||
}
|
||||
}
|
||||
|
||||
// Move Vector towards target
|
||||
@(require_results)
|
||||
Vector2MoveTowards :: proc "c" (v, target: Vector2, maxDistance: f32) -> Vector2 {
|
||||
dv := target - v
|
||||
value := linalg.dot(dv, dv)
|
||||
|
||||
if value == 0 || (maxDistance >= 0 && value <= maxDistance*maxDistance) {
|
||||
return target
|
||||
}
|
||||
|
||||
dist := math.sqrt(value)
|
||||
return v + dv/dist*maxDistance
|
||||
}
|
||||
|
||||
// Invert the given vector
|
||||
@(require_results, deprecated="Prefer 1.0/v")
|
||||
Vector2Invert :: proc "c" (v: Vector2) -> Vector2 {
|
||||
return 1.0/v
|
||||
}
|
||||
|
||||
// Clamp the components of the vector between
|
||||
// min and max values specified by the given vectors
|
||||
@(require_results)
|
||||
Vector2Clamp :: proc "c" (v: Vector2, min, max: Vector2) -> Vector2 {
|
||||
return Vector2{
|
||||
clamp(v.x, min.x, max.x),
|
||||
clamp(v.y, min.y, max.y),
|
||||
}
|
||||
}
|
||||
|
||||
// Clamp the magnitude of the vector between two min and max values
|
||||
@(require_results)
|
||||
Vector2ClampValue :: proc "c" (v: Vector2, min, max: f32) -> Vector2 {
|
||||
result := v
|
||||
|
||||
length := linalg.dot(v, v)
|
||||
if length > 0 {
|
||||
length = math.sqrt(length)
|
||||
scale := f32(1)
|
||||
if length < min {
|
||||
scale = min/length
|
||||
} else if length > max {
|
||||
scale = max/length
|
||||
}
|
||||
result = v*scale
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
@(require_results)
|
||||
Vector2Equals :: proc "c" (p, q: Vector2) -> bool {
|
||||
return FloatEquals(p.x, q.x) &&
|
||||
FloatEquals(p.y, q.y)
|
||||
}
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Definition - Vector3 math
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// Vector with components value 0.0
|
||||
@(require_results, deprecated="Prefer Vector3(0)")
|
||||
Vector3Zero :: proc "c" () -> Vector3 {
|
||||
return Vector3(0)
|
||||
}
|
||||
// Vector with components value 1.0
|
||||
@(require_results, deprecated="Prefer Vector3(1)")
|
||||
Vector3One :: proc "c" () -> Vector3 {
|
||||
return Vector3(1)
|
||||
}
|
||||
// Add two vectors (v1 + v2)
|
||||
@(require_results, deprecated="Prefer v1 + v2")
|
||||
Vector3Add :: proc "c" (v1, v2: Vector3) -> Vector3 {
|
||||
return v1 + v2
|
||||
}
|
||||
// Add vector and float value
|
||||
@(require_results, deprecated="Prefer v + value")
|
||||
Vector3AddValue :: proc "c" (v: Vector3, value: f32) -> Vector3 {
|
||||
return v + value
|
||||
}
|
||||
// Subtract two vectors (v1 - v2)
|
||||
@(require_results, deprecated="Prefer a - b")
|
||||
Vector3Subtract :: proc "c" (a, b: Vector3) -> Vector3 {
|
||||
return a - b
|
||||
}
|
||||
// Subtract vector by float value
|
||||
@(require_results, deprecated="Prefer v + value")
|
||||
Vector3SubtractValue :: proc "c" (v: Vector3, value: f32) -> Vector3 {
|
||||
return v - value
|
||||
}
|
||||
// Calculate vector length
|
||||
@(require_results)
|
||||
Vector3Length :: proc "c" (v: Vector3) -> f32 {
|
||||
return linalg.length(v)
|
||||
}
|
||||
// Calculate vector square length
|
||||
@(require_results)
|
||||
Vector3LengthSqr :: proc "c" (v: Vector3) -> f32 {
|
||||
return linalg.length2(v)
|
||||
}
|
||||
// Calculate two vectors dot product
|
||||
@(require_results)
|
||||
Vector3DotProduct :: proc "c" (v1, v2: Vector3) -> f32 {
|
||||
return linalg.dot(v1, v2)
|
||||
}
|
||||
// Calculate two vectors dot product
|
||||
@(require_results)
|
||||
Vector3CrossProduct :: proc "c" (v1, v2: Vector3) -> Vector3 {
|
||||
return linalg.cross(v1, v2)
|
||||
}
|
||||
// Calculate distance between two vectors
|
||||
@(require_results)
|
||||
Vector3Distance :: proc "c" (v1, v2: Vector3) -> f32 {
|
||||
return linalg.distance(v1, v2)
|
||||
}
|
||||
// Calculate square distance between two vectors
|
||||
@(require_results)
|
||||
Vector3DistanceSqrt :: proc "c" (v1, v2: Vector3) -> f32 {
|
||||
return linalg.length2(v2-v1)
|
||||
}
|
||||
// Calculate angle between two vectors
|
||||
// NOTE: Angle is calculated from origin point (0, 0)
|
||||
@(require_results)
|
||||
Vector3Angle :: proc "c" (v1, v2: Vector3) -> f32 {
|
||||
return linalg.angle_between(v1, v2)
|
||||
}
|
||||
|
||||
// Calculate angle defined by a two vectors line
|
||||
// NOTE: Parameters need to be normalized
|
||||
// Current implementation should be aligned with glm::angle
|
||||
@(require_results)
|
||||
Vector3LineAngle :: proc "c" (start, end: Vector3) -> f32 {
|
||||
// TODO(10/9/2023): Currently angles move clockwise, determine if this is wanted behavior
|
||||
return -math.atan2(end.y - start.y, end.x - start.x)
|
||||
}
|
||||
|
||||
// Scale vector (multiply by value)
|
||||
@(require_results, deprecated="Prefer v * scale")
|
||||
Vector3Scale :: proc "c" (v: Vector3, scale: f32) -> Vector3 {
|
||||
return v * scale
|
||||
}
|
||||
// Multiply vector by vector
|
||||
@(require_results, deprecated="Prefer v1 * v2")
|
||||
Vector3Multiply :: proc "c" (v1, v2: Vector3) -> Vector3 {
|
||||
return v1 * v2
|
||||
}
|
||||
// Negate vector
|
||||
@(require_results, deprecated="Prefer -v")
|
||||
Vector3Negate :: proc "c" (v: Vector3) -> Vector3 {
|
||||
return -v
|
||||
}
|
||||
// Divide vector by vector
|
||||
@(require_results, deprecated="Prefer v1 / v2")
|
||||
Vector3Divide :: proc "c" (v1, v2: Vector3) -> Vector3 {
|
||||
return v1 / v2
|
||||
}
|
||||
// Normalize provided vector
|
||||
@(require_results)
|
||||
Vector3Normalize :: proc "c" (v: Vector3) -> Vector3 {
|
||||
return linalg.normalize0(v)
|
||||
}
|
||||
|
||||
// Calculate the projection of the vector v1 on to v2
|
||||
@(require_results)
|
||||
Vector3Project :: proc "c" (v1, v2: Vector3) -> Vector3 {
|
||||
return linalg.projection(v1, v2)
|
||||
}
|
||||
|
||||
// Calculate the rejection of the vector v1 on to v2
|
||||
@(require_results)
|
||||
Vector3Reject :: proc "c" (v1, v2: Vector3) -> Vector3 {
|
||||
mag := linalg.dot(v1, v2)/linalg.dot(v2, v2)
|
||||
return v1 - v2*mag
|
||||
}
|
||||
|
||||
// Orthonormalize provided vectors
|
||||
// Makes vectors normalized and orthogonal to each other
|
||||
// Gram-Schmidt function implementation
|
||||
Vector3OrthoNormalize :: proc "c" (v1, v2: ^Vector3) {
|
||||
v1^ = linalg.normalize0(v1^)
|
||||
v3 := linalg.normalize0(linalg.cross(v1^, v2^))
|
||||
v2^ = linalg.cross(v3, v1^)
|
||||
}
|
||||
|
||||
// Transform a vector by quaternion rotation
|
||||
@(require_results)
|
||||
Vector3RotateByQuaternion :: proc "c" (v: Vector3, q: Quaternion) -> Vector3 {
|
||||
return linalg.mul(q, v)
|
||||
}
|
||||
|
||||
// Rotates a vector around an axis
|
||||
@(require_results)
|
||||
Vector3RotateByAxisAngle :: proc "c" (v: Vector3, axis: Vector3, angle: f32) -> Vector3 {
|
||||
axis, angle := axis, angle
|
||||
|
||||
axis = linalg.normalize0(axis)
|
||||
|
||||
angle *= 0.5
|
||||
a := math.sin(angle)
|
||||
b := axis.x*a
|
||||
c := axis.y*a
|
||||
d := axis.z*a
|
||||
a = math.cos(angle)
|
||||
w := Vector3{b, c, d}
|
||||
|
||||
wv := linalg.cross(w, v)
|
||||
wwv := linalg.cross(w, wv)
|
||||
|
||||
a *= 2
|
||||
wv *= a
|
||||
|
||||
wwv *= 2
|
||||
|
||||
return v + wv + wwv
|
||||
|
||||
}
|
||||
|
||||
// Transforms a Vector3 by a given Matrix
|
||||
@(require_results)
|
||||
Vector3Transform :: proc "c" (v: Vector3, m: Matrix) -> Vector3 {
|
||||
v4 := Vector4{v.x, v.y, v.z, 1}
|
||||
return (m * v4).xyz
|
||||
}
|
||||
// Calculate linear interpolation between two vectors
|
||||
@(require_results, deprecated="Prefer = linalg.lerp(v1, v2, amount)")
|
||||
Vector3Lerp :: proc "c" (v1, v2: Vector3, amount: f32) -> Vector3 {
|
||||
return linalg.lerp(v1, v2, Vector3(amount))
|
||||
}
|
||||
// Calculate reflected vector to normal
|
||||
@(require_results, deprecated="Prefer = linalg.reflect(v, normal)")
|
||||
Vector3Reflect :: proc "c" (v, normal: Vector3) -> Vector3 {
|
||||
return linalg.reflect(v, normal)
|
||||
}
|
||||
// Compute the direction of a refracted ray
|
||||
// v: normalized direction of the incoming ray
|
||||
// n: normalized normal vector of the interface of two optical media
|
||||
// r: ratio of the refractive index of the medium from where the ray comes
|
||||
// to the refractive index of the medium on the other side of the surface
|
||||
@(require_results, deprecated="Prefer = linalg.refract(v, n, r)")
|
||||
Vector3Refract :: proc "c" (v, n: Vector3, r: f32) -> Vector3 {
|
||||
return linalg.refract(v, n, r)
|
||||
}
|
||||
|
||||
// Move Vector towards target
|
||||
@(require_results)
|
||||
Vector3MoveTowards :: proc "c" (v, target: Vector3, maxDistance: f32) -> Vector3 {
|
||||
dv := target - v
|
||||
value := linalg.dot(dv, dv)
|
||||
|
||||
if value == 0 || (maxDistance >= 0 && value <= maxDistance*maxDistance) {
|
||||
return target
|
||||
}
|
||||
|
||||
dist := math.sqrt(value)
|
||||
return v + dv/dist*maxDistance
|
||||
}
|
||||
|
||||
// Invert the given vector
|
||||
@(require_results, deprecated="Prefer 1.0/v")
|
||||
Vector3Invert :: proc "c" (v: Vector3) -> Vector3 {
|
||||
return 1.0/v
|
||||
}
|
||||
|
||||
// Clamp the components of the vector between
|
||||
// min and max values specified by the given vectors
|
||||
@(require_results)
|
||||
Vector3Clamp :: proc "c" (v: Vector3, min, max: Vector3) -> Vector3 {
|
||||
return Vector3{
|
||||
clamp(v.x, min.x, max.x),
|
||||
clamp(v.y, min.y, max.y),
|
||||
clamp(v.z, min.z, max.z),
|
||||
}
|
||||
}
|
||||
|
||||
// Clamp the magnitude of the vector between two min and max values
|
||||
@(require_results)
|
||||
Vector3ClampValue :: proc "c" (v: Vector3, min, max: f32) -> Vector3 {
|
||||
result := v
|
||||
|
||||
length := linalg.dot(v, v)
|
||||
if length > 0 {
|
||||
length = math.sqrt(length)
|
||||
scale := f32(1)
|
||||
if length < min {
|
||||
scale = min/length
|
||||
} else if length > max {
|
||||
scale = max/length
|
||||
}
|
||||
result = v*scale
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
@(require_results)
|
||||
Vector3Equals :: proc "c" (p, q: Vector3) -> bool {
|
||||
return FloatEquals(p.x, q.x) &&
|
||||
FloatEquals(p.y, q.y) &&
|
||||
FloatEquals(p.z, q.z)
|
||||
}
|
||||
|
||||
|
||||
@(require_results)
|
||||
Vector3Min :: proc "c" (v1, v2: Vector3) -> Vector3 {
|
||||
return linalg.min(v1, v2)
|
||||
}
|
||||
|
||||
@(require_results)
|
||||
Vector3Max :: proc "c" (v1, v2: Vector3) -> Vector3 {
|
||||
return linalg.max(v1, v2)
|
||||
}
|
||||
|
||||
|
||||
// Compute barycenter coordinates (u, v, w) for point p with respect to triangle (a, b, c)
|
||||
// NOTE: Assumes P is on the plane of the triangle
|
||||
@(require_results)
|
||||
Vector3Barycenter :: proc "c" (p: Vector3, a, b, c: Vector3) -> (result: Vector3) {
|
||||
v0 := b - a
|
||||
v1 := c - a
|
||||
v2 := p - a
|
||||
d00 := linalg.dot(v0, v0)
|
||||
d01 := linalg.dot(v0, v1)
|
||||
d11 := linalg.dot(v1, v1)
|
||||
d20 := linalg.dot(v2, v0)
|
||||
d21 := linalg.dot(v2, v1)
|
||||
|
||||
denom := d00*d11 - d01*d01
|
||||
|
||||
result.y = (d11*d20 - d01*d21)/denom
|
||||
result.z = (d00*d21 - d01*d20)/denom
|
||||
result.x = 1 - (result.z + result.y)
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
// Projects a Vector3 from screen space into object space
|
||||
@(require_results)
|
||||
Vector3Unproject :: proc "c" (source: Vector3, projection: Matrix, view: Matrix) -> Vector3 {
|
||||
matViewProj := view * projection
|
||||
|
||||
matViewProjInv := linalg.inverse(matViewProj)
|
||||
|
||||
quat: Quaternion
|
||||
quat.x = source.x
|
||||
quat.y = source.y
|
||||
quat.z = source.z
|
||||
quat.w = 1
|
||||
|
||||
qtransformed := QuaternionTransform(quat, matViewProjInv)
|
||||
|
||||
return Vector3{qtransformed.x/qtransformed.w, qtransformed.y/qtransformed.w, qtransformed.z/qtransformed.w}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Definition - Matrix math
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Compute matrix determinant
|
||||
@(require_results)
|
||||
MatrixDeterminant :: proc "c" (mat: Matrix) -> f32 {
|
||||
return linalg.determinant(mat)
|
||||
}
|
||||
|
||||
// Get the trace of the matrix (sum of the values along the diagonal)
|
||||
@(require_results)
|
||||
MatrixTrace :: proc "c" (mat: Matrix) -> f32 {
|
||||
return linalg.trace(mat)
|
||||
}
|
||||
|
||||
// Transposes provided matrix
|
||||
@(require_results)
|
||||
MatrixTranspose :: proc "c" (mat: Matrix) -> Matrix {
|
||||
return linalg.transpose(mat)
|
||||
}
|
||||
|
||||
// Invert provided matrix
|
||||
@(require_results)
|
||||
MatrixInvert :: proc "c" (mat: Matrix) -> Matrix {
|
||||
return linalg.inverse(mat)
|
||||
}
|
||||
|
||||
// Get identity matrix
|
||||
@(require_results, deprecated="Prefer Matrix(1)")
|
||||
MatrixIdentity :: proc "c" () -> Matrix {
|
||||
return Matrix(1)
|
||||
}
|
||||
|
||||
// Add two matrices
|
||||
@(require_results, deprecated="Prefer left + right")
|
||||
MatrixAdd :: proc "c" (left, right: Matrix) -> Matrix {
|
||||
return left + right
|
||||
}
|
||||
|
||||
// Subtract two matrices (left - right)
|
||||
@(require_results, deprecated="Prefer left - right")
|
||||
MatrixSubtract :: proc "c" (left, right: Matrix) -> Matrix {
|
||||
return left - right
|
||||
}
|
||||
|
||||
// Get two matrix multiplication
|
||||
// NOTE: When multiplying matrices... the order matters!
|
||||
@(require_results, deprecated="Prefer left * right")
|
||||
MatrixMultiply :: proc "c" (left, right: Matrix) -> Matrix {
|
||||
return left * right
|
||||
}
|
||||
|
||||
// Get translation matrix
|
||||
@(require_results)
|
||||
MatrixTranslate :: proc "c" (x, y, z: f32) -> Matrix {
|
||||
return {
|
||||
1, 0, 0, x,
|
||||
0, 1, 0, y,
|
||||
0, 0, 1, z,
|
||||
0, 0, 0, 1,
|
||||
}
|
||||
}
|
||||
|
||||
// Create rotation matrix from axis and angle
|
||||
// NOTE: Angle should be provided in radians
|
||||
@(require_results)
|
||||
MatrixRotate :: proc "c" (axis: Vector3, angle: f32) -> Matrix {
|
||||
return auto_cast linalg.matrix4_rotate(angle, axis)
|
||||
}
|
||||
|
||||
// Get x-rotation matrix
|
||||
// NOTE: Angle must be provided in radians
|
||||
@(require_results)
|
||||
MatrixRotateX :: proc "c" (angle: f32) -> Matrix {
|
||||
return auto_cast linalg.matrix4_rotate(angle, Vector3{1, 0, 0})
|
||||
}
|
||||
|
||||
// Get y-rotation matrix
|
||||
// NOTE: Angle must be provided in radians
|
||||
@(require_results)
|
||||
MatrixRotateY :: proc "c" (angle: f32) -> Matrix {
|
||||
return auto_cast linalg.matrix4_rotate(angle, Vector3{0, 1, 0})
|
||||
}
|
||||
|
||||
// Get z-rotation matrix
|
||||
// NOTE: Angle must be provided in radians
|
||||
@(require_results)
|
||||
MatrixRotateZ :: proc "c" (angle: f32) -> Matrix {
|
||||
return auto_cast linalg.matrix4_rotate(angle, Vector3{0, 0, 1})
|
||||
}
|
||||
|
||||
// Get xyz-rotation matrix
|
||||
// NOTE: Angle must be provided in radians
|
||||
@(require_results)
|
||||
MatrixRotateXYZ :: proc "c" (angle: Vector3) -> Matrix {
|
||||
return auto_cast linalg.matrix4_from_euler_angles_xyz(angle.x, angle.y, angle.z)
|
||||
}
|
||||
|
||||
// Get zyx-rotation matrix
|
||||
// NOTE: Angle must be provided in radians
|
||||
@(require_results)
|
||||
MatrixRotateZYX :: proc "c" (angle: Vector3) -> Matrix {
|
||||
return auto_cast linalg.matrix4_from_euler_angles_zyx(angle.x, angle.y, angle.z)
|
||||
}
|
||||
|
||||
|
||||
// Get scaling matrix
|
||||
@(require_results)
|
||||
MatrixScale :: proc "c" (x, y, z: f32) -> Matrix {
|
||||
return auto_cast linalg.matrix4_scale(Vector3{x, y, z})
|
||||
}
|
||||
|
||||
// Get orthographic projection matrix
|
||||
@(require_results)
|
||||
MatrixOrtho :: proc "c" (left, right, bottom, top, near, far: f32) -> Matrix {
|
||||
return auto_cast linalg.matrix_ortho3d(left, right, bottom, top, near, far)
|
||||
}
|
||||
|
||||
// Get perspective projection matrix
|
||||
// NOTE: Fovy angle must be provided in radians
|
||||
@(require_results)
|
||||
MatrixPerspective :: proc "c" (fovY, aspect, nearPlane, farPlane: f32) -> Matrix {
|
||||
return auto_cast linalg.matrix4_perspective(fovY, aspect, nearPlane, farPlane)
|
||||
}
|
||||
// Get camera look-at matrix (view matrix)
|
||||
@(require_results)
|
||||
MatrixLookAt :: proc "c" (eye, target, up: Vector3) -> Matrix {
|
||||
return auto_cast linalg.matrix4_look_at(eye, target, up)
|
||||
}
|
||||
|
||||
// Get float array of matrix data
|
||||
@(require_results)
|
||||
MatrixToFloatV :: proc "c" (mat: Matrix) -> [16]f32 {
|
||||
return transmute([16]f32)linalg.transpose(mat)
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Definition - Quaternion math
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// Add two quaternions
|
||||
@(require_results, deprecated="Prefer q1 + q2")
|
||||
QuaternionAdd :: proc "c" (q1, q2: Quaternion) -> Quaternion {
|
||||
return q1 + q2
|
||||
}
|
||||
// Add quaternion and float value
|
||||
@(require_results)
|
||||
QuaternionAddValue :: proc "c" (q: Quaternion, add: f32) -> Quaternion {
|
||||
return q + Quaternion(add)
|
||||
}
|
||||
// Subtract two quaternions
|
||||
@(require_results, deprecated="Prefer q1 - q2")
|
||||
QuaternionSubtract :: proc "c" (q1, q2: Quaternion) -> Quaternion {
|
||||
return q1 - q2
|
||||
}
|
||||
// Subtract quaternion and float value
|
||||
@(require_results)
|
||||
QuaternionSubtractValue :: proc "c" (q: Quaternion, sub: f32) -> Quaternion {
|
||||
return q - Quaternion(sub)
|
||||
}
|
||||
// Get identity quaternion
|
||||
@(require_results, deprecated="Prefer Quaternion(1)")
|
||||
QuaternionIdentity :: proc "c" () -> Quaternion {
|
||||
return 1
|
||||
}
|
||||
// Computes the length of a quaternion
|
||||
@(require_results, deprecated="Prefer abs(q)")
|
||||
QuaternionLength :: proc "c" (q: Quaternion) -> f32 {
|
||||
return abs(q)
|
||||
}
|
||||
// Normalize provided quaternion
|
||||
@(require_results)
|
||||
QuaternionNormalize :: proc "c" (q: Quaternion) -> Quaternion {
|
||||
return linalg.normalize0(q)
|
||||
}
|
||||
// Invert provided quaternion
|
||||
@(require_results, deprecated="Prefer 1/q")
|
||||
QuaternionInvert :: proc "c" (q: Quaternion) -> Quaternion {
|
||||
return 1/q
|
||||
}
|
||||
// Calculate two quaternion multiplication
|
||||
@(require_results, deprecated="Prefer q1 * q2")
|
||||
QuaternionMultiply :: proc "c" (q1, q2: Quaternion) -> Quaternion {
|
||||
return q1 * q2
|
||||
}
|
||||
// Scale quaternion by float value
|
||||
@(require_results)
|
||||
QuaternionScale :: proc "c" (q: Quaternion, mul: f32) -> Quaternion {
|
||||
return q * Quaternion(mul)
|
||||
}
|
||||
// Divide two quaternions
|
||||
@(require_results, deprecated="Prefer q1 / q2")
|
||||
QuaternionDivide :: proc "c" (q1, q2: Quaternion) -> Quaternion {
|
||||
return q1 / q2
|
||||
}
|
||||
// Calculate linear interpolation between two quaternions
|
||||
@(require_results)
|
||||
QuaternionLerp :: proc "c" (q1, q2: Quaternion, amount: f32) -> (q3: Quaternion) {
|
||||
q3.x = q1.x + (q2.x-q1.x)*amount
|
||||
q3.y = q1.y + (q2.y-q1.y)*amount
|
||||
q3.z = q1.z + (q2.z-q1.z)*amount
|
||||
q3.w = q1.w + (q2.w-q1.w)*amount
|
||||
return
|
||||
}
|
||||
// Calculate slerp-optimized interpolation between two quaternions
|
||||
@(require_results)
|
||||
QuaternionNlerp :: proc "c" (q1, q2: Quaternion, amount: f32) -> Quaternion {
|
||||
return linalg.quaternion_nlerp(q1, q2, amount)
|
||||
}
|
||||
// Calculates spherical linear interpolation between two quaternions
|
||||
@(require_results)
|
||||
QuaternionSlerp :: proc "c" (q1, q2: Quaternion, amount: f32) -> Quaternion {
|
||||
return linalg.quaternion_slerp(q1, q2, amount)
|
||||
}
|
||||
// Calculate quaternion based on the rotation from one vector to another
|
||||
@(require_results)
|
||||
QuaternionFromVector3ToVector3 :: proc "c" (from, to: Vector3) -> Quaternion {
|
||||
return linalg.quaternion_between_two_vector3(from, to)
|
||||
}
|
||||
// Get a quaternion for a given rotation matrix
|
||||
@(require_results)
|
||||
QuaternionFromMatrix :: proc "c" (mat: Matrix) -> Quaternion {
|
||||
return linalg.quaternion_from_matrix4(linalg.Matrix4f32(mat))
|
||||
}
|
||||
// Get a matrix for a given quaternion
|
||||
@(require_results)
|
||||
QuaternionToMatrix :: proc "c" (q: Quaternion) -> Matrix {
|
||||
return auto_cast linalg.matrix4_from_quaternion(q)
|
||||
}
|
||||
// Get rotation quaternion for an angle and axis NOTE: Angle must be provided in radians
|
||||
@(require_results)
|
||||
QuaternionFromAxisAngle :: proc "c" (axis: Vector3, angle: f32) -> Quaternion {
|
||||
return linalg.quaternion_angle_axis(angle, axis)
|
||||
}
|
||||
// Get the rotation angle and axis for a given quaternion
|
||||
@(require_results)
|
||||
QuaternionToAxisAngle :: proc "c" (q: Quaternion) -> (outAxis: Vector3, outAngle: f32) {
|
||||
outAngle, outAxis = linalg.angle_axis_from_quaternion(q)
|
||||
return
|
||||
}
|
||||
// Get the quaternion equivalent to Euler angles NOTE: Rotation order is ZYX
|
||||
@(require_results)
|
||||
QuaternionFromEuler :: proc "c" (pitch, yaw, roll: f32) -> Quaternion {
|
||||
return linalg.quaternion_from_pitch_yaw_roll(pitch, yaw, roll)
|
||||
}
|
||||
// Get the Euler angles equivalent to quaternion (roll, pitch, yaw) NOTE: Angles are returned in a Vector3 struct in radians
|
||||
@(require_results)
|
||||
QuaternionToEuler :: proc "c" (q: Quaternion) -> Vector3 {
|
||||
result: Vector3
|
||||
|
||||
// Roll (x-axis rotation)
|
||||
x0 := 2.0*(q.w*q.x + q.y*q.z)
|
||||
x1 := 1.0 - 2.0*(q.x*q.x + q.y*q.y)
|
||||
result.x = math.atan2(x0, x1)
|
||||
|
||||
// Pitch (y-axis rotation)
|
||||
y0 := 2.0*(q.w*q.y - q.z*q.x)
|
||||
y0 = 1.0 if y0 > 1.0 else y0
|
||||
y0 = -1.0 if y0 < -1.0 else y0
|
||||
result.y = math.asin(y0)
|
||||
|
||||
// Yaw (z-axis rotation)
|
||||
z0 := 2.0*(q.w*q.z + q.x*q.y)
|
||||
z1 := 1.0 - 2.0*(q.y*q.y + q.z*q.z)
|
||||
result.z = math.atan2(z0, z1)
|
||||
|
||||
return result
|
||||
}
|
||||
// Transform a quaternion given a transformation matrix
|
||||
@(require_results)
|
||||
QuaternionTransform :: proc "c" (q: Quaternion, mat: Matrix) -> Quaternion {
|
||||
v := mat * transmute(Vector4)q
|
||||
return transmute(Quaternion)v
|
||||
}
|
||||
// Check whether two given quaternions are almost equal
|
||||
@(require_results)
|
||||
QuaternionEquals :: proc "c" (p, q: Quaternion) -> bool {
|
||||
return FloatEquals(p.x, q.x) &&
|
||||
FloatEquals(p.y, q.y) &&
|
||||
FloatEquals(p.z, q.z) &&
|
||||
FloatEquals(p.w, q.w)
|
||||
}
|
||||
|
||||
@(private, require_results)
|
||||
fmaxf :: proc "contextless" (x, y: f32) -> f32 {
|
||||
if math.is_nan(x) {
|
||||
return y
|
||||
}
|
||||
|
||||
if math.is_nan(y) {
|
||||
return x
|
||||
}
|
||||
|
||||
if math.sign_bit(x) != math.sign_bit(y) {
|
||||
return y if math.sign_bit(x) else x
|
||||
}
|
||||
|
||||
return y if x < y else x
|
||||
}
|
||||
588
vendor/raylib/v5.5/rlgl/rlgl.odin
vendored
Normal file
588
vendor/raylib/v5.5/rlgl/rlgl.odin
vendored
Normal file
@@ -0,0 +1,588 @@
|
||||
/**********************************************************************************************
|
||||
*
|
||||
* rlgl v5.0 - A multi-OpenGL abstraction layer with an immediate-mode style API
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* An abstraction layer for multiple OpenGL versions (1.1, 2.1, 3.3 Core, 4.3 Core, ES 2.0)
|
||||
* that provides a pseudo-OpenGL 1.1 immediate-mode style API (rlVertex, rlTranslate, rlRotate...)
|
||||
*
|
||||
* ADDITIONAL NOTES:
|
||||
* When choosing an OpenGL backend different than OpenGL 1.1, some internal buffer are
|
||||
* initialized on rlglInit() to accumulate vertex data.
|
||||
*
|
||||
* When an internal state change is required all the stored vertex data is renderer in batch,
|
||||
* additionally, rlDrawRenderBatchActive() could be called to force flushing of the batch.
|
||||
*
|
||||
* Some resources are also loaded for convenience, here the complete list:
|
||||
* - Default batch (RLGL.defaultBatch): RenderBatch system to accumulate vertex data
|
||||
* - Default texture (RLGL.defaultTextureId): 1x1 white pixel R8G8B8A8
|
||||
* - Default shader (RLGL.State.defaultShaderId, RLGL.State.defaultShaderLocs)
|
||||
*
|
||||
* Internal buffer (and resources) must be manually unloaded calling rlglClose().
|
||||
*
|
||||
* CONFIGURATION:
|
||||
* #define GRAPHICS_API_OPENGL_11
|
||||
* #define GRAPHICS_API_OPENGL_21
|
||||
* #define GRAPHICS_API_OPENGL_33
|
||||
* #define GRAPHICS_API_OPENGL_43
|
||||
* #define GRAPHICS_API_OPENGL_ES2
|
||||
* #define GRAPHICS_API_OPENGL_ES3
|
||||
* Use selected OpenGL graphics backend, should be supported by platform
|
||||
* Those preprocessor defines are only used on rlgl module, if OpenGL version is
|
||||
* required by any other module, use rlGetVersion() to check it
|
||||
*
|
||||
* #define RLGL_IMPLEMENTATION
|
||||
* Generates the implementation of the library into the included file.
|
||||
* If not defined, the library is in header only mode and can be included in other headers
|
||||
* or source files without problems. But only ONE file should hold the implementation.
|
||||
*
|
||||
* #define RLGL_RENDER_TEXTURES_HINT
|
||||
* Enable framebuffer objects (fbo) support (enabled by default)
|
||||
* Some GPUs could not support them despite the OpenGL version
|
||||
*
|
||||
* #define RLGL_SHOW_GL_DETAILS_INFO
|
||||
* Show OpenGL extensions and capabilities detailed logs on init
|
||||
*
|
||||
* #define RLGL_ENABLE_OPENGL_DEBUG_CONTEXT
|
||||
* Enable debug context (only available on OpenGL 4.3)
|
||||
*
|
||||
* rlgl capabilities could be customized just defining some internal
|
||||
* values before library inclusion (default values listed):
|
||||
*
|
||||
* #define RL_DEFAULT_BATCH_BUFFER_ELEMENTS 8192 // Default internal render batch elements limits
|
||||
* #define RL_DEFAULT_BATCH_BUFFERS 1 // Default number of batch buffers (multi-buffering)
|
||||
* #define RL_DEFAULT_BATCH_DRAWCALLS 256 // Default number of batch draw calls (by state changes: mode, texture)
|
||||
* #define RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS 4 // Maximum number of textures units that can be activated on batch drawing (SetShaderValueTexture())
|
||||
*
|
||||
* #define RL_MAX_MATRIX_STACK_SIZE 32 // Maximum size of internal Matrix stack
|
||||
* #define RL_MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported
|
||||
* #define RL_CULL_DISTANCE_NEAR 0.01 // Default projection matrix near cull distance
|
||||
* #define RL_CULL_DISTANCE_FAR 1000.0 // Default projection matrix far cull distance
|
||||
*
|
||||
* When loading a shader, the following vertex attributes and uniform
|
||||
* location names are tried to be set automatically:
|
||||
*
|
||||
* #define RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION "vertexPosition" // Bound by default to shader location: 0
|
||||
* #define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD "vertexTexCoord" // Bound by default to shader location: 1
|
||||
* #define RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL "vertexNormal" // Bound by default to shader location: 2
|
||||
* #define RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR "vertexColor" // Bound by default to shader location: 3
|
||||
* #define RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT "vertexTangent" // Bound by default to shader location: 4
|
||||
* #define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2 "vertexTexCoord2" // Bound by default to shader location: 5
|
||||
* #define RL_DEFAULT_SHADER_UNIFORM_NAME_MVP "mvp" // model-view-projection matrix
|
||||
* #define RL_DEFAULT_SHADER_UNIFORM_NAME_VIEW "matView" // view matrix
|
||||
* #define RL_DEFAULT_SHADER_UNIFORM_NAME_PROJECTION "matProjection" // projection matrix
|
||||
* #define RL_DEFAULT_SHADER_UNIFORM_NAME_MODEL "matModel" // model matrix
|
||||
* #define RL_DEFAULT_SHADER_UNIFORM_NAME_NORMAL "matNormal" // normal matrix (transpose(inverse(matModelView))
|
||||
* #define RL_DEFAULT_SHADER_UNIFORM_NAME_COLOR "colDiffuse" // color diffuse (base tint color, multiplied by texture color)
|
||||
* #define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE0 "texture0" // texture0 (texture slot active 0)
|
||||
* #define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE1 "texture1" // texture1 (texture slot active 1)
|
||||
* #define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE2 "texture2" // texture2 (texture slot active 2)
|
||||
*
|
||||
* DEPENDENCIES:
|
||||
* - OpenGL libraries (depending on platform and OpenGL version selected)
|
||||
* - GLAD OpenGL extensions loading library (only for OpenGL 3.3 Core, 4.3 Core)
|
||||
*
|
||||
*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* Copyright (c) 2014-2023 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*
|
||||
**********************************************************************************************/
|
||||
|
||||
|
||||
package rlgl
|
||||
|
||||
import "core:c"
|
||||
import rl "../."
|
||||
|
||||
VERSION :: "5.0"
|
||||
|
||||
RAYLIB_SHARED :: #config(RAYLIB_SHARED, false)
|
||||
RAYLIB_WASM_LIB :: #config(RAYLIB_WASM_LIB, "../wasm/libraylib.a")
|
||||
|
||||
// Note: We pull in the full raylib library. If you want a truly stand-alone rlgl, then:
|
||||
// - Compile a separate rlgl library and use that in the foreign import blocks below.
|
||||
// - Remove the `import rl "../."` line
|
||||
// - Copy the code from raylib.odin for any types we alias from that package (see PixelFormat etc)
|
||||
|
||||
when ODIN_OS == .Windows {
|
||||
@(extra_linker_flags="/NODEFAULTLIB:" + ("msvcrt" when RAYLIB_SHARED else "libcmt"))
|
||||
foreign import lib {
|
||||
"../windows/raylibdll.lib" when RAYLIB_SHARED else "../windows/raylib.lib" ,
|
||||
"system:Winmm.lib",
|
||||
"system:Gdi32.lib",
|
||||
"system:User32.lib",
|
||||
"system:Shell32.lib",
|
||||
}
|
||||
} else when ODIN_OS == .Linux {
|
||||
foreign import lib {
|
||||
// Note(bumbread): I'm not sure why in `linux/` folder there are
|
||||
// multiple copies of raylib.so, but since these bindings are for
|
||||
// particular version of the library, I better specify it. Ideally,
|
||||
// though, it's best specified in terms of major (.so.4)
|
||||
"../linux/libraylib.so.550" when RAYLIB_SHARED else "../linux/libraylib.a",
|
||||
"system:dl",
|
||||
"system:pthread",
|
||||
}
|
||||
} else when ODIN_OS == .Darwin {
|
||||
foreign import lib {
|
||||
"../macos/libraylib.550.dylib" when RAYLIB_SHARED else "../macos/libraylib.a",
|
||||
"system:Cocoa.framework",
|
||||
"system:OpenGL.framework",
|
||||
"system:IOKit.framework",
|
||||
}
|
||||
} else when ODIN_ARCH == .wasm32 || ODIN_ARCH == .wasm64p32 {
|
||||
foreign import lib {
|
||||
RAYLIB_WASM_LIB,
|
||||
}
|
||||
} else {
|
||||
foreign import lib "system:raylib"
|
||||
}
|
||||
|
||||
GRAPHICS_API_OPENGL_11 :: false
|
||||
GRAPHICS_API_OPENGL_21 :: true
|
||||
GRAPHICS_API_OPENGL_33 :: GRAPHICS_API_OPENGL_21 // default currently
|
||||
GRAPHICS_API_OPENGL_ES2 :: false
|
||||
GRAPHICS_API_OPENGL_43 :: false
|
||||
GRAPHICS_API_OPENGL_ES3 :: false
|
||||
|
||||
when GRAPHICS_API_OPENGL_ES3 {
|
||||
GRAPHICS_API_OPENGL_ES2 :: true
|
||||
}
|
||||
|
||||
when !GRAPHICS_API_OPENGL_ES2 {
|
||||
// This is the maximum amount of elements (quads) per batch
|
||||
// NOTE: Be careful with text, every letter maps to a quad
|
||||
DEFAULT_BATCH_BUFFER_ELEMENTS :: 8192
|
||||
} else {
|
||||
// We reduce memory sizes for embedded systems (RPI and HTML5)
|
||||
// NOTE: On HTML5 (emscripten) this is allocated on heap,
|
||||
// by default it's only 16MB!...just take care...
|
||||
DEFAULT_BATCH_BUFFER_ELEMENTS :: 2048
|
||||
}
|
||||
|
||||
DEFAULT_BATCH_BUFFERS :: 1 // Default number of batch buffers (multi-buffering)
|
||||
DEFAULT_BATCH_DRAWCALLS :: 256 // Default number of batch draw calls (by state changes: mode, texture)
|
||||
DEFAULT_BATCH_MAX_TEXTURE_UNITS :: 4 // Maximum number of additional textures that can be activated on batch drawing (SetShaderValueTexture())
|
||||
|
||||
// Internal Matrix stack
|
||||
MAX_MATRIX_STACK_SIZE :: 32 // Maximum size of Matrix stack
|
||||
|
||||
// Shader limits
|
||||
MAX_SHADER_LOCATIONS :: 32 // Maximum number of shader locations supported
|
||||
|
||||
// Projection matrix culling
|
||||
CULL_DISTANCE_NEAR :: 0.01 // Default near cull distance
|
||||
CULL_DISTANCE_FAR :: 1000.0 // Default far cull distance
|
||||
|
||||
// Texture parameters (equivalent to OpenGL defines)
|
||||
TEXTURE_WRAP_S :: 0x2802 // GL_TEXTURE_WRAP_S
|
||||
TEXTURE_WRAP_T :: 0x2803 // GL_TEXTURE_WRAP_T
|
||||
TEXTURE_MAG_FILTER :: 0x2800 // GL_TEXTURE_MAG_FILTER
|
||||
TEXTURE_MIN_FILTER :: 0x2801 // GL_TEXTURE_MIN_FILTER
|
||||
|
||||
TEXTURE_FILTER_NEAREST :: 0x2600 // GL_NEAREST
|
||||
TEXTURE_FILTER_LINEAR :: 0x2601 // GL_LINEAR
|
||||
TEXTURE_FILTER_MIP_NEAREST :: 0x2700 // GL_NEAREST_MIPMAP_NEAREST
|
||||
TEXTURE_FILTER_NEAREST_MIP_LINEAR :: 0x2702 // GL_NEAREST_MIPMAP_LINEAR
|
||||
TEXTURE_FILTER_LINEAR_MIP_NEAREST :: 0x2701 // GL_LINEAR_MIPMAP_NEAREST
|
||||
TEXTURE_FILTER_MIP_LINEAR :: 0x2703 // GL_LINEAR_MIPMAP_LINEAR
|
||||
TEXTURE_FILTER_ANISOTROPIC :: 0x3000 // Anisotropic filter (custom identifier)
|
||||
|
||||
TEXTURE_WRAP_REPEAT :: 0x2901 // GL_REPEAT
|
||||
TEXTURE_WRAP_CLAMP :: 0x812F // GL_CLAMP_TO_EDGE
|
||||
TEXTURE_WRAP_MIRROR_REPEAT :: 0x8370 // GL_MIRRORED_REPEAT
|
||||
TEXTURE_WRAP_MIRROR_CLAMP :: 0x8742 // GL_MIRROR_CLAMP_EXT
|
||||
|
||||
// Matrix modes (equivalent to OpenGL)
|
||||
MODELVIEW :: 0x1700 // GL_MODELVIEW
|
||||
PROJECTION :: 0x1701 // GL_PROJECTION
|
||||
TEXTURE :: 0x1702 // GL_TEXTURE
|
||||
|
||||
// Primitive assembly draw modes
|
||||
LINES :: 0x0001 // GL_LINES
|
||||
TRIANGLES :: 0x0004 // GL_TRIANGLES
|
||||
QUADS :: 0x0007 // GL_QUADS
|
||||
|
||||
// GL equivalent data types
|
||||
UNSIGNED_BYTE :: 0x1401 // GL_UNSIGNED_BYTE
|
||||
FLOAT :: 0x1406 // GL_FLOAT
|
||||
|
||||
// Buffer usage hint
|
||||
STREAM_DRAW :: 0x88E0 // GL_STREAM_DRAW
|
||||
STREAM_READ :: 0x88E1 // GL_STREAM_READ
|
||||
STREAM_COPY :: 0x88E2 // GL_STREAM_COPY
|
||||
STATIC_DRAW :: 0x88E4 // GL_STATIC_DRAW
|
||||
STATIC_READ :: 0x88E5 // GL_STATIC_READ
|
||||
STATIC_COPY :: 0x88E6 // GL_STATIC_COPY
|
||||
DYNAMIC_DRAW :: 0x88E8 // GL_DYNAMIC_DRAW
|
||||
DYNAMIC_READ :: 0x88E9 // GL_DYNAMIC_READ
|
||||
DYNAMIC_COPY :: 0x88EA // GL_DYNAMIC_COPY
|
||||
|
||||
// GL Shader type
|
||||
FRAGMENT_SHADER :: 0x8B30 // GL_FRAGMENT_SHADER
|
||||
VERTEX_SHADER :: 0x8B31 // GL_VERTEX_SHADER
|
||||
COMPUTE_SHADER :: 0x91B9 // GL_COMPUTE_SHADER
|
||||
|
||||
// GL blending factors
|
||||
ZERO :: 0 // GL_ZERO
|
||||
ONE :: 1 // GL_ONE
|
||||
SRC_COLOR :: 0x0300 // GL_SRC_COLOR
|
||||
ONE_MINUS_SRC_COLOR :: 0x0301 // GL_ONE_MINUS_SRC_COLOR
|
||||
SRC_ALPHA :: 0x0302 // GL_SRC_ALPHA
|
||||
ONE_MINUS_SRC_ALPHA :: 0x0303 // GL_ONE_MINUS_SRC_ALPHA
|
||||
DST_ALPHA :: 0x0304 // GL_DST_ALPHA
|
||||
ONE_MINUS_DST_ALPHA :: 0x0305 // GL_ONE_MINUS_DST_ALPHA
|
||||
DST_COLOR :: 0x0306 // GL_DST_COLOR
|
||||
ONE_MINUS_DST_COLOR :: 0x0307 // GL_ONE_MINUS_DST_COLOR
|
||||
SRC_ALPHA_SATURATE :: 0x0308 // GL_SRC_ALPHA_SATURATE
|
||||
CONSTANT_COLOR :: 0x8001 // GL_CONSTANT_COLOR
|
||||
ONE_MINUS_CONSTANT_COLOR :: 0x8002 // GL_ONE_MINUS_CONSTANT_COLOR
|
||||
CONSTANT_ALPHA :: 0x8003 // GL_CONSTANT_ALPHA
|
||||
ONE_MINUS_CONSTANT_ALPHA :: 0x8004 // GL_ONE_MINUS_CONSTANT_ALPHA
|
||||
|
||||
// GL blending functions/equations
|
||||
FUNC_ADD :: 0x8006 // GL_FUNC_ADD
|
||||
MIN :: 0x8007 // GL_MIN
|
||||
MAX :: 0x8008 // GL_MAX
|
||||
FUNC_SUBTRACT :: 0x800A // GL_FUNC_SUBTRACT
|
||||
FUNC_REVERSE_SUBTRACT :: 0x800B // GL_FUNC_REVERSE_SUBTRACT
|
||||
BLEND_EQUATION :: 0x8009 // GL_BLEND_EQUATION
|
||||
BLEND_EQUATION_RGB :: 0x8009 // GL_BLEND_EQUATION_RGB // (Same as BLEND_EQUATION)
|
||||
BLEND_EQUATION_ALPHA :: 0x883D // GL_BLEND_EQUATION_ALPHA
|
||||
BLEND_DST_RGB :: 0x80C8 // GL_BLEND_DST_RGB
|
||||
BLEND_SRC_RGB :: 0x80C9 // GL_BLEND_SRC_RGB
|
||||
BLEND_DST_ALPHA :: 0x80CA // GL_BLEND_DST_ALPHA
|
||||
BLEND_SRC_ALPHA :: 0x80CB // GL_BLEND_SRC_ALPHA
|
||||
BLEND_COLOR :: 0x8005 // GL_BLEND_COLOR
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Types and Structures Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
|
||||
VertexBufferIndexType :: c.ushort when GRAPHICS_API_OPENGL_ES2 else c.uint
|
||||
|
||||
// Dynamic vertex buffers (position + texcoords + colors + indices arrays)
|
||||
VertexBuffer :: struct {
|
||||
elementCount: c.int, // Number of elements in the buffer (QUADS)
|
||||
|
||||
vertices: [^]f32, // Vertex position (XYZ - 3 components per vertex) (shader-location = 0)
|
||||
texcoords: [^]f32, // Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1)
|
||||
colors: [^]u8, // Vertex colors (RGBA - 4 components per vertex) (shader-location = 3)
|
||||
indices: [^]VertexBufferIndexType, // Vertex indices (in case vertex data comes indexed) (6 indices per quad)
|
||||
vaoId: c.uint, // OpenGL Vertex Array Object id
|
||||
vboId: [4]c.uint, // OpenGL Vertex Buffer Objects id (4 types of vertex data)
|
||||
}
|
||||
|
||||
// Draw call type
|
||||
// NOTE: Only texture changes register a new draw, other state-change-related elements are not
|
||||
// used at this moment (vaoId, shaderId, matrices), raylib just forces a batch draw call if any
|
||||
// of those state-change happens (this is done in core module)
|
||||
DrawCall :: struct {
|
||||
mode: c.int, // Drawing mode: LINES, TRIANGLES, QUADS
|
||||
vertexCount: c.int, // Number of vertex of the draw
|
||||
vertexAlignment: c.int, // Number of vertex required for index alignment (LINES, TRIANGLES)
|
||||
textureId: c.uint, // Texture id to be used on the draw -> Use to create new draw call if changes
|
||||
}
|
||||
|
||||
// RenderBatch type
|
||||
RenderBatch :: struct {
|
||||
bufferCount: c.int, // Number of vertex buffers (multi-buffering support)
|
||||
currentBuffer: c.int, // Current buffer tracking in case of multi-buffering
|
||||
vertexBuffer: [^]VertexBuffer, // Dynamic buffer(s) for vertex data
|
||||
|
||||
draws: [^]DrawCall, // Draw calls array, depends on textureId
|
||||
drawCounter: c.int, // Draw calls counter
|
||||
currentDepth: f32, // Current depth value for next draw
|
||||
}
|
||||
|
||||
// OpenGL version
|
||||
GlVersion :: enum c.int {
|
||||
OPENGL_11 = 1, // OpenGL 1.1
|
||||
OPENGL_21, // OpenGL 2.1 (GLSL 120)
|
||||
OPENGL_33, // OpenGL 3.3 (GLSL 330)
|
||||
OPENGL_43, // OpenGL 4.3 (using GLSL 330)
|
||||
OPENGL_ES_20, // OpenGL ES 2.0 (GLSL 100)
|
||||
OPENGL_ES_30, // OpenGL ES 3.0 (GLSL 300 es)
|
||||
}
|
||||
|
||||
PixelFormat :: rl.PixelFormat
|
||||
TextureFilter :: rl.TextureFilter
|
||||
BlendMode :: rl.BlendMode
|
||||
ShaderLocationIndex :: rl.ShaderLocationIndex
|
||||
ShaderUniformDataType :: rl.ShaderUniformDataType
|
||||
|
||||
// Shader attribute data types
|
||||
ShaderAttributeDataType :: enum c.int {
|
||||
FLOAT = 0, // Shader attribute type: float
|
||||
VEC2, // Shader attribute type: vec2 (2 float)
|
||||
VEC3, // Shader attribute type: vec3 (3 float)
|
||||
VEC4, // Shader attribute type: vec4 (4 float)
|
||||
}
|
||||
|
||||
// Framebuffer attachment type
|
||||
// NOTE: By default up to 8 color channels defined, but it can be more
|
||||
FramebufferAttachType :: enum c.int {
|
||||
COLOR_CHANNEL0 = 0, // Framebuffer attachment type: color 0
|
||||
COLOR_CHANNEL1 = 1, // Framebuffer attachment type: color 1
|
||||
COLOR_CHANNEL2 = 2, // Framebuffer attachment type: color 2
|
||||
COLOR_CHANNEL3 = 3, // Framebuffer attachment type: color 3
|
||||
COLOR_CHANNEL4 = 4, // Framebuffer attachment type: color 4
|
||||
COLOR_CHANNEL5 = 5, // Framebuffer attachment type: color 5
|
||||
COLOR_CHANNEL6 = 6, // Framebuffer attachment type: color 6
|
||||
COLOR_CHANNEL7 = 7, // Framebuffer attachment type: color 7
|
||||
DEPTH = 100, // Framebuffer attachment type: depth
|
||||
STENCIL = 200, // Framebuffer attachment type: stencil
|
||||
}
|
||||
|
||||
// Framebuffer texture attachment type
|
||||
FramebufferAttachTextureType :: enum c.int {
|
||||
CUBEMAP_POSITIVE_X = 0, // Framebuffer texture attachment type: cubemap, +X side
|
||||
CUBEMAP_NEGATIVE_X = 1, // Framebuffer texture attachment type: cubemap, -X side
|
||||
CUBEMAP_POSITIVE_Y = 2, // Framebuffer texture attachment type: cubemap, +Y side
|
||||
CUBEMAP_NEGATIVE_Y = 3, // Framebuffer texture attachment type: cubemap, -Y side
|
||||
CUBEMAP_POSITIVE_Z = 4, // Framebuffer texture attachment type: cubemap, +Z side
|
||||
CUBEMAP_NEGATIVE_Z = 5, // Framebuffer texture attachment type: cubemap, -Z side
|
||||
TEXTURE2D = 100, // Framebuffer texture attachment type: texture2d
|
||||
RENDERBUFFER = 200, // Framebuffer texture attachment type: renderbuffer
|
||||
}
|
||||
|
||||
CullMode :: enum c.int {
|
||||
FRONT = 0,
|
||||
BACK,
|
||||
}
|
||||
|
||||
Matrix :: rl.Matrix
|
||||
|
||||
@(default_calling_convention="c", link_prefix="rl")
|
||||
foreign lib {
|
||||
//------------------------------------------------------------------------------------
|
||||
// Functions Declaration - Matrix operations
|
||||
//------------------------------------------------------------------------------------
|
||||
MatrixMode :: proc(mode: c.int) --- // Choose the current matrix to be transformed
|
||||
PushMatrix :: proc() --- // Push the current matrix to stack
|
||||
PopMatrix :: proc() --- // Pop lattest inserted matrix from stack
|
||||
LoadIdentity :: proc() --- // Reset current matrix to identity matrix
|
||||
Translatef :: proc(x, y, z: f32) --- // Multiply the current matrix by a translation matrix
|
||||
Rotatef :: proc(angleDeg: f32, x, y, z: f32) --- // Multiply the current matrix by a rotation matrix
|
||||
Scalef :: proc(x, y, z: f32) --- // Multiply the current matrix by a scaling matrix
|
||||
MultMatrixf :: proc(matf: [^]f32) --- // Multiply the current matrix by another matrix
|
||||
Frustum :: proc(left, right, bottom, top, znear, zfar: f64) ---
|
||||
Ortho :: proc(left, right, bottom, top, znear, zfar: f64) ---
|
||||
Viewport :: proc(x, y, width, height: c.int) --- // Set the viewport area
|
||||
SetClipPlanes :: proc(near, far: f64) --- // Set clip planes distances
|
||||
GetCullDistanceNear :: proc() -> f64 --- // Get cull plane distance near
|
||||
GetCullDistanceFar :: proc() -> f64 --- // Get cull plane distance far
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Functions Declaration - Vertex level operations
|
||||
//------------------------------------------------------------------------------------
|
||||
Begin :: proc(mode: c.int) --- // Initialize drawing mode (how to organize vertex)
|
||||
End :: proc() --- // Finish vertex providing
|
||||
Vertex2i :: proc(x, y: c.int) --- // Define one vertex (position) - 2 int
|
||||
Vertex2f :: proc(x, y: f32) --- // Define one vertex (position) - 2 f32
|
||||
Vertex3f :: proc(x, y, z: f32) --- // Define one vertex (position) - 3 f32
|
||||
TexCoord2f :: proc(x, y: f32) --- // Define one vertex (texture coordinate) - 2 f32
|
||||
Normal3f :: proc(x, y, z: f32) --- // Define one vertex (normal) - 3 f32
|
||||
Color4ub :: proc(r, g, b, a: u8) --- // Define one vertex (color) - 4 byte
|
||||
Color3f :: proc(x, y, z: f32) --- // Define one vertex (color) - 3 f32
|
||||
Color4f :: proc(x, y, z, w: f32) --- // Define one vertex (color) - 4 f32
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Functions Declaration - OpenGL style functions (common to 1.1, 3.3+, ES2)
|
||||
// NOTE: This functions are used to completely abstract raylib code from OpenGL layer,
|
||||
// some of them are direct wrappers over OpenGL calls, some others are custom
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Vertex buffers state
|
||||
EnableVertexArray :: proc(vaoId: c.uint) -> bool --- // Enable vertex array (VAO, if supported)
|
||||
DisableVertexArray :: proc() --- // Disable vertex array (VAO, if supported)
|
||||
EnableVertexBuffer :: proc(id: c.uint) --- // Enable vertex buffer (VBO)
|
||||
DisableVertexBuffer :: proc() --- // Disable vertex buffer (VBO)
|
||||
EnableVertexBufferElement :: proc(id: c.uint) --- // Enable vertex buffer element (VBO element)
|
||||
DisableVertexBufferElement :: proc() --- // Disable vertex buffer element (VBO element)
|
||||
EnableVertexAttribute :: proc(index: c.uint) --- // Enable vertex attribute index
|
||||
DisableVertexAttribute :: proc(index: c.uint) --- // Disable vertex attribute index
|
||||
when GRAPHICS_API_OPENGL_11 {
|
||||
EnableStatePointer :: proc(vertexAttribType: c.int, buffer: rawptr) ---
|
||||
DisableStatePointer :: proc(vertexAttribType: c.int) ---
|
||||
}
|
||||
|
||||
// Textures state
|
||||
ActiveTextureSlot :: proc(slot: c.int) --- // Select and active a texture slot
|
||||
EnableTexture :: proc(id: c.uint) --- // Enable texture
|
||||
DisableTexture :: proc() --- // Disable texture
|
||||
EnableTextureCubemap :: proc(id: c.uint) --- // Enable texture cubemap
|
||||
DisableTextureCubemap :: proc() --- // Disable texture cubemap
|
||||
TextureParameters :: proc(id: c.uint, param: c.int, value: c.int) --- // Set texture parameters (filter, wrap)
|
||||
CubemapParameters :: proc(id: i32, param: c.int, value: c.int) --- // Set cubemap parameters (filter, wrap)
|
||||
|
||||
// Shader state
|
||||
EnableShader :: proc(id: c.uint) --- // Enable shader program
|
||||
DisableShader :: proc() --- // Disable shader program
|
||||
|
||||
// Framebuffer state
|
||||
EnableFramebuffer :: proc(id: c.uint) --- // Enable render texture (fbo)
|
||||
DisableFramebuffer :: proc() --- // Disable render texture (fbo), return to default framebuffer
|
||||
ActiveDrawBuffers :: proc(count: c.int) --- // Activate multiple draw color buffers
|
||||
BlitFramebuffer :: proc(srcX, srcY, srcWidth, srcHeight, dstX, dstY, dstWidth, dstHeight, bufferMask: c.int) --- // Blit active framebuffer to main framebuffer
|
||||
|
||||
// General render state
|
||||
EnableColorBlend :: proc() --- // Enable color blending
|
||||
DisableColorBlend :: proc() --- // Disable color blending
|
||||
EnableDepthTest :: proc() --- // Enable depth test
|
||||
DisableDepthTest :: proc() --- // Disable depth test
|
||||
EnableDepthMask :: proc() --- // Enable depth write
|
||||
DisableDepthMask :: proc() --- // Disable depth write
|
||||
EnableBackfaceCulling :: proc() --- // Enable backface culling
|
||||
DisableBackfaceCulling :: proc() --- // Disable backface culling
|
||||
SetCullFace :: proc(mode: CullMode) --- // Set face culling mode
|
||||
EnableScissorTest :: proc() --- // Enable scissor test
|
||||
DisableScissorTest :: proc() --- // Disable scissor test
|
||||
Scissor :: proc(x, y, width, height: c.int) --- // Scissor test
|
||||
EnableWireMode :: proc() --- // Enable wire mode
|
||||
EnablePointMode :: proc() --- // Enable point mode
|
||||
DisableWireMode :: proc() --- // Disable wire and point modes
|
||||
SetLineWidth :: proc(width: f32) --- // Set the line drawing width
|
||||
GetLineWidth :: proc() -> f32 --- // Get the line drawing width
|
||||
EnableSmoothLines :: proc() --- // Enable line aliasing
|
||||
DisableSmoothLines :: proc() --- // Disable line aliasing
|
||||
EnableStereoRender :: proc() --- // Enable stereo rendering
|
||||
DisableStereoRender :: proc() --- // Disable stereo rendering
|
||||
IsStereoRenderEnabled :: proc() -> bool --- // Check if stereo render is enabled
|
||||
|
||||
|
||||
ClearColor :: proc(r, g, b, a: u8) --- // Clear color buffer with color
|
||||
ClearScreenBuffers :: proc() --- // Clear used screen buffers (color and depth)
|
||||
CheckErrors :: proc() --- // Check and log OpenGL error codes
|
||||
SetBlendMode :: proc(mode: c.int) --- // Set blending mode
|
||||
SetBlendFactors :: proc(glSrcFactor, glDstFactor, glEquation: c.int) --- // Set blending mode factor and equation (using OpenGL factors)
|
||||
SetBlendFactorsSeparate :: proc(glSrcRGB, glDstRGB, glSrcAlpha, glDstAlpha, glEqRGB, glEqAlpha: c.int) --- // Set blending mode factors and equations separately (using OpenGL factors)
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Functions Declaration - rlgl functionality
|
||||
//------------------------------------------------------------------------------------
|
||||
// rlgl initialization functions
|
||||
@(link_prefix="rlgl")
|
||||
Init :: proc(width, height: c.int) --- // Initialize rlgl (buffers, shaders, textures, states)
|
||||
@(link_prefix="rlgl")
|
||||
Close :: proc() --- // De-initialize rlgl (buffers, shaders, textures)
|
||||
LoadExtensions :: proc(loader: rawptr) --- // Load OpenGL extensions (loader function required)
|
||||
GetVersion :: proc() -> GlVersion --- // Get current OpenGL version
|
||||
SetFramebufferWidth :: proc(width: c.int) --- // Set current framebuffer width
|
||||
GetFramebufferWidth :: proc() -> c.int --- // Get default framebuffer width
|
||||
SetFramebufferHeight :: proc(height: c.int) --- // Set current framebuffer height
|
||||
GetFramebufferHeight :: proc() -> c.int --- // Get default framebuffer height
|
||||
|
||||
|
||||
GetTextureIdDefault :: proc() -> c.uint --- // Get default texture id
|
||||
GetShaderIdDefault :: proc() -> c.uint --- // Get default shader id
|
||||
GetShaderLocsDefault :: proc() -> [^]c.int --- // Get default shader locations
|
||||
|
||||
// Render batch management
|
||||
// NOTE: rlgl provides a default render batch to behave like OpenGL 1.1 immediate mode
|
||||
// but this render batch API is exposed in case of custom batches are required
|
||||
LoadRenderBatch :: proc(numBuffers, bufferElements: c.int) -> RenderBatch --- // Load a render batch system
|
||||
UnloadRenderBatch :: proc(batch: RenderBatch) --- // Unload render batch system
|
||||
DrawRenderBatch :: proc(batch: ^RenderBatch) --- // Draw render batch data (Update->Draw->Reset)
|
||||
SetRenderBatchActive :: proc(batch: ^RenderBatch) --- // Set the active render batch for rlgl (NULL for default internal)
|
||||
DrawRenderBatchActive :: proc() --- // Update and draw internal render batch
|
||||
CheckRenderBatchLimit :: proc(vCount: c.int) -> c.int --- // Check internal buffer overflow for a given number of vertex
|
||||
|
||||
SetTexture :: proc(id: c.uint) --- // Set current texture for render batch and check buffers limits
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
// Vertex buffers management
|
||||
LoadVertexArray :: proc() -> c.uint --- // Load vertex array (vao) if supported
|
||||
LoadVertexBuffer :: proc(buffer: rawptr, size: c.int, is_dynamic: bool) -> c.uint --- // Load a vertex buffer attribute
|
||||
LoadVertexBufferElement :: proc(buffer: rawptr, size: c.int, is_dynamic: bool) -> c.uint --- // Load a new attributes element buffer
|
||||
UpdateVertexBuffer :: proc(bufferId: c.uint, data: rawptr, dataSize: c.int, offset: c.int) --- // Update GPU buffer with new data
|
||||
UpdateVertexBufferElements :: proc(id: c.uint, data: rawptr, dataSize: c.int, offset: c.int) --- // Update vertex buffer elements with new data
|
||||
UnloadVertexArray :: proc(vaoId: c.uint) ---
|
||||
UnloadVertexBuffer :: proc(vboId: c.uint) ---
|
||||
SetVertexAttribute :: proc(index: c.uint, compSize: c.int, type: c.int, normalized: bool, stride: c.int, offset: c.int) ---
|
||||
SetVertexAttributeDivisor :: proc(index: c.uint, divisor: c.int) ---
|
||||
SetVertexAttributeDefault :: proc(locIndex: c.int, value: rawptr, attribType: c.int, count: c.int) --- // Set vertex attribute default value
|
||||
DrawVertexArray :: proc(offset: c.int, count: c.int) ---
|
||||
DrawVertexArrayElements :: proc(offset: c.int, count: c.int, buffer: rawptr) ---
|
||||
DrawVertexArrayInstanced :: proc(offset: c.int, count: c.int, instances: c.int) ---
|
||||
DrawVertexArrayElementsInstanced :: proc(offset: c.int, count: c.int, buffer: rawptr, instances: c.int) ---
|
||||
|
||||
// Textures management
|
||||
LoadTexture :: proc(data: rawptr, width, height: c.int, format: c.int, mipmapCount: c.int) -> c.uint --- // Load texture in GPU
|
||||
LoadTextureDepth :: proc(width, height: c.int, useRenderBuffer: bool) -> c.uint --- // Load depth texture/renderbuffer (to be attached to fbo)
|
||||
LoadTextureCubemap :: proc(data: rawptr, size: c.int, format: c.int) -> c.uint --- // Load texture cubemap
|
||||
UpdateTexture :: proc(id: c.uint, offsetX, offsetY: c.int, width, height: c.int, format: c.int, data: rawptr) --- // Update GPU texture with new data
|
||||
GetGlTextureFormats :: proc(format: c.int, glInternalFormat, glFormat, glType: ^c.uint) --- // Get OpenGL internal formats
|
||||
GetPixelFormatName :: proc(format: c.uint) -> cstring --- // Get name string for pixel format
|
||||
UnloadTexture :: proc(id: c.uint) --- // Unload texture from GPU memory
|
||||
GenTextureMipmaps :: proc(id: c.uint, width, height: c.int, format: c.int, mipmaps: ^c.int) --- // Generate mipmap data for selected texture
|
||||
ReadTexturePixels :: proc(id: c.uint, width, height: c.int, format: c.int) -> rawptr --- // Read texture pixel data
|
||||
ReadScreenPixels :: proc(width, height: c.int) -> [^]byte --- // Read screen pixel data (color buffer)
|
||||
|
||||
// Framebuffer management (fbo)
|
||||
LoadFramebuffer :: proc() -> c.uint --- // Load an empty framebuffer
|
||||
FramebufferAttach :: proc(fboId, texId: c.uint, attachType: c.int, texType: c.int, mipLevel: c.int) --- // Attach texture/renderbuffer to a framebuffer
|
||||
FramebufferComplete :: proc(id: c.uint) -> bool --- // Verify framebuffer is complete
|
||||
UnloadFramebuffer :: proc(id: c.uint) --- // Delete framebuffer from GPU
|
||||
|
||||
// Shaders management
|
||||
LoadShaderCode :: proc(vsCode, fsCode: cstring) -> c.uint --- // Load shader from code strings
|
||||
CompileShader :: proc(shaderCode: cstring, type: c.int) -> c.uint --- // Compile custom shader and return shader id (type: VERTEX_SHADER, FRAGMENT_SHADER, COMPUTE_SHADER)
|
||||
LoadShaderProgram :: proc(vShaderId, fShaderId: c.uint) -> c.uint --- // Load custom shader program
|
||||
UnloadShaderProgram :: proc(id: c.uint) --- // Unload shader program
|
||||
GetLocationUniform :: proc(shaderId: c.uint, uniformName: cstring) -> c.int --- // Get shader location uniform
|
||||
GetLocationAttrib :: proc(shaderId: c.uint, attribName: cstring) -> c.int --- // Get shader location attribute
|
||||
SetUniform :: proc(locIndex: c.int, value: rawptr, uniformType: c.int, count: c.int) --- // Set shader value uniform
|
||||
SetUniformMatrix :: proc(locIndex: c.int, mat: Matrix) --- // Set shader value matrix
|
||||
SetUniformSampler :: proc(locIndex: c.int, textureId: c.uint) --- // Set shader value sampler
|
||||
SetShader :: proc(id: c.uint, locs: [^]c.int) --- // Set shader currently active (id and locations)
|
||||
|
||||
// Compute shader management
|
||||
LoadComputeShaderProgram :: proc(shaderId: c.uint) -> c.uint --- // Load compute shader program
|
||||
ComputeShaderDispatch :: proc(groupX, groupY, groupZ: c.uint) --- // Dispatch compute shader (equivalent to *draw* for graphics pipeline)
|
||||
|
||||
// Shader buffer storage object management (ssbo)
|
||||
LoadShaderBuffer :: proc(size: c.uint, data: rawptr, usageHint: c.int) -> c.uint --- // Load shader storage buffer object (SSBO)
|
||||
UnloadShaderBuffer :: proc(ssboId: c.uint) --- // Unload shader storage buffer object (SSBO)
|
||||
UpdateShaderBuffer :: proc(id: c.uint, data: rawptr, dataSize: c.uint, offset: c.uint) --- // Update SSBO buffer data
|
||||
BindShaderBuffer :: proc(id: c.uint, index: c.uint) --- // Bind SSBO buffer
|
||||
ReadShaderBuffer :: proc(id: c.uint, dest: rawptr, count: c.uint, offset: c.uint) --- // Read SSBO buffer data (GPU->CPU)
|
||||
CopyShaderBuffer :: proc(destId, srcId: c.uint, destOffset, srcOffset: c.uint, count: c.uint) --- // Copy SSBO data between buffers
|
||||
GetShaderBufferSize :: proc(id: c.uint) -> c.uint --- // Get SSBO buffer size
|
||||
|
||||
// Buffer management
|
||||
BindImageTexture :: proc(id: c.uint, index: c.uint, format: c.int, readonly: bool) --- // Bind image texture
|
||||
|
||||
// Matrix state management
|
||||
GetMatrixModelview :: proc() -> Matrix --- // Get internal modelview matrix
|
||||
GetMatrixProjection :: proc() -> Matrix --- // Get internal projection matrix
|
||||
GetMatrixTransform :: proc() -> Matrix --- // Get internal accumulated transform matrix
|
||||
GetMatrixProjectionStereo :: proc(eye: c.int) -> Matrix --- // Get internal projection matrix for stereo render (selected eye)
|
||||
GetMatrixViewOffsetStereo :: proc(eye: c.int) -> Matrix --- // Get internal view offset matrix for stereo render (selected eye)
|
||||
SetMatrixProjection :: proc(proj: Matrix) --- // Set a custom projection matrix (replaces internal projection matrix)
|
||||
SetMatrixModelview :: proc(view: Matrix) --- // Set a custom modelview matrix (replaces internal modelview matrix)
|
||||
SetMatrixProjectionStereo :: proc(right, left: Matrix) --- // Set eyes projection matrices for stereo rendering
|
||||
SetMatrixViewOffsetStereo :: proc(right, left: Matrix) --- // Set eyes view offsets matrices for stereo rendering
|
||||
|
||||
// Quick and dirty cube/quad buffers load->draw->unload
|
||||
LoadDrawCube :: proc() --- // Load and draw a cube
|
||||
LoadDrawQuad :: proc() --- // Load and draw a quad
|
||||
}
|
||||
BIN
vendor/raylib/wasm/libraygui.a
vendored
BIN
vendor/raylib/wasm/libraygui.a
vendored
Binary file not shown.
BIN
vendor/raylib/wasm/libraylib.a
vendored
BIN
vendor/raylib/wasm/libraylib.a
vendored
Binary file not shown.
Reference in New Issue
Block a user