瀏覽代碼

dstep conversion

Steven Schveighoffer 3 年之前
父節點
當前提交
1a80236769
共有 4 個文件被更改,包括 234 次插入98 次删除
  1. 70 40
      source/raylib.d
  2. 89 24
      source/raymath.d
  3. 4 3
      source/reasings.d
  4. 71 31
      source/rlgl.d

+ 70 - 40
source/raylib.d

@@ -3,14 +3,15 @@ module raylib;
 public
 {
     import rlgl;
-    import easings;
+    import reasings;
     import raymath;
     import raymathext;
     import raylib_types;
 }
+
 /**********************************************************************************************
 *
-*   raylib v4.0 - A simple and easy-to-use library to enjoy videogames programming (www.raylib.com)
+*   raylib v4.2 - A simple and easy-to-use library to enjoy videogames programming (www.raylib.com)
 *
 *   FEATURES:
 *       - NO external dependencies, all required libraries included with raylib
@@ -43,8 +44,8 @@ public
 *
 *   OPTIONAL DEPENDENCIES (included):
 *       [rcore] msf_gif (Miles Fogle) for GIF recording
-*       [rcore] sinfl (Micha Mettke) for DEFLATE decompression algorythm
-*       [rcore] sdefl (Micha Mettke) for DEFLATE compression algorythm
+*       [rcore] sinfl (Micha Mettke) for DEFLATE decompression algorithm
+*       [rcore] sdefl (Micha Mettke) for DEFLATE compression algorithm
 *       [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_resize (Sean Barret) for image resizing algorithms
@@ -66,7 +67,7 @@ public
 *   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-2021 Ramon Santamaria (@raysan5)
+*   Copyright (c) 2013-2022 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.
@@ -84,7 +85,6 @@ public
 *     3. This notice may not be removed or altered from any source distribution.
 *
 **********************************************************************************************/
-
 import core.stdc.config;
 import core.stdc.stdarg;
 
@@ -92,7 +92,7 @@ extern (C) @nogc nothrow:
 
 // Required for: va_list - Only used by TraceLogCallback
 
-enum RAYLIB_VERSION = "4.0";
+enum RAYLIB_VERSION = "4.2";
 
 // Function specifiers in case library is build/used as a shared library (Windows)
 // NOTE: Microsoft specifiers to tell compiler that symbols are imported/exported from a .dll
@@ -112,6 +112,7 @@ enum DEG2RAD = PI / 180.0f;
 enum RAD2DEG = 180.0f / PI;
 
 // Allow custom memory allocators
+// NOTE: Require recompiling raylib sources
 
 // NOTE: MSVC C++ compiler does not support compound literals (C99 feature)
 // Plain structures in C++ (without constructors) can be initialized with { }
@@ -276,7 +277,7 @@ struct Mesh
     // Vertex attributes data
     float* vertices; // Vertex position (XYZ - 3 components per vertex) (shader-location = 0)
     float* texcoords; // Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1)
-    float* texcoords2; // Vertex second texture coordinates (useful for lightmaps) (shader-location = 5)
+    float* texcoords2; // Vertex texture second coordinates (UV - 2 components per vertex) (shader-location = 5)
     float* normals; // Vertex normals (XYZ - 3 components per vertex) (shader-location = 2)
     float* tangents; // Vertex tangents (XYZW - 4 components per vertex) (shader-location = 4)
     ubyte* colors; // Vertex colors (RGBA - 4 components per vertex) (shader-location = 3)
@@ -390,12 +391,16 @@ struct Wave
     void* data; // Buffer data pointer
 }
 
+// Opaque structs declaration
+// NOTE: Actual structs are defined internally in raudio module
 struct rAudioBuffer;
+struct rAudioProcessor;
 
 // AudioStream, custom audio stream
 struct AudioStream
 {
     rAudioBuffer* buffer; // Pointer to internal data used by the audio system
+    rAudioProcessor* processor; // Pointer to internal data processor, useful for audio effects
 
     uint sampleRate; // Frequency (samples per second)
     uint sampleSize; // Bit depth (bits per sample): 8, 16, 32 (24 not supported)
@@ -448,6 +453,14 @@ struct VrStereoConfig
     float[2] scaleIn; // VR distortion scale in
 }
 
+// File path list
+struct FilePathList
+{
+    uint capacity; // Filepaths max entries
+    uint count; // Filepaths entries count
+    char** paths; // Filepaths entries
+}
+
 //----------------------------------------------------------------------------------
 // Enumerators Definition
 //----------------------------------------------------------------------------------
@@ -468,6 +481,7 @@ enum ConfigFlags
     FLAG_WINDOW_ALWAYS_RUN = 0x00000100, // Set to allow windows running while minimized
     FLAG_WINDOW_TRANSPARENT = 0x00000010, // Set to allow transparent framebuffer
     FLAG_WINDOW_HIGHDPI = 0x00002000, // Set to support HighDPI
+    FLAG_WINDOW_MOUSE_PASSTHROUGH = 0x00004000, // Set to support mouse passthrough, only supported when FLAG_WINDOW_UNDECORATED
     FLAG_MSAA_4X_HINT = 0x00000020, // Set to try enabling MSAA 4X
     FLAG_INTERLACED_HINT = 0x00010000 // Set to try enabling interlaced video format (for V3D)
 }
@@ -787,7 +801,7 @@ enum PixelFormat
 // NOTE 2: Filter is accordingly set for minification and magnification
 enum TextureFilter
 {
-    TEXTURE_FILTER_POINT = 0, // No filter, just pixel aproximation
+    TEXTURE_FILTER_POINT = 0, // No filter, just pixel approximation
     TEXTURE_FILTER_BILINEAR = 1, // Linear filtering
     TEXTURE_FILTER_TRILINEAR = 2, // Trilinear filtering (linear with mipmaps)
     TEXTURE_FILTER_ANISOTROPIC_4X = 3, // Anisotropic filtering 4x
@@ -831,7 +845,8 @@ enum BlendMode
     BLEND_MULTIPLIED = 2, // Blend textures multiplying colors
     BLEND_ADD_COLORS = 3, // Blend textures adding colors (alternative)
     BLEND_SUBTRACT_COLORS = 4, // Blend textures subtracting colors (alternative)
-    BLEND_CUSTOM = 5 // Belnd textures using custom src/dst factors (use rlSetBlendMode())
+    BLEND_ALPHA_PREMULTIPLY = 5, // Blend premultiplied textures considering alpha
+    BLEND_CUSTOM = 6 // Blend textures using custom src/dst factors (use rlSetBlendMode())
 }
 
 // Gesture
@@ -907,7 +922,7 @@ bool IsWindowMaximized(); // Check if window is currently maximized (only PLATFO
 bool IsWindowFocused(); // Check if window is currently focused (only PLATFORM_DESKTOP)
 bool IsWindowResized(); // Check if window has been resized last frame
 bool IsWindowState(uint flag); // Check if one specific window flag is enabled
-void SetWindowState(uint flags); // Set window configuration state using flags
+void SetWindowState(uint flags); // Set window configuration state using flags (only PLATFORM_DESKTOP)
 void ClearWindowState(uint flags); // Clear window configuration state flags
 void ToggleFullscreen(); // Toggle window state: fullscreen/windowed (only PLATFORM_DESKTOP)
 void MaximizeWindow(); // Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
@@ -919,14 +934,17 @@ void SetWindowPosition(int x, int y); // Set window position on screen (only PLA
 void SetWindowMonitor(int monitor); // Set monitor for the current window (fullscreen mode)
 void SetWindowMinSize(int width, int height); // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE)
 void SetWindowSize(int width, int height); // Set window dimensions
+void SetWindowOpacity(float opacity); // Set window opacity [0.0f..1.0f] (only PLATFORM_DESKTOP)
 void* GetWindowHandle(); // Get native window handle
 int GetScreenWidth(); // Get current screen width
 int GetScreenHeight(); // Get current screen height
+int GetRenderWidth(); // Get current render width (it considers HiDPI)
+int GetRenderHeight(); // Get current render height (it considers HiDPI)
 int GetMonitorCount(); // Get number of connected monitors
 int GetCurrentMonitor(); // Get current connected monitor
 Vector2 GetMonitorPosition(int monitor); // Get specified monitor position
-int GetMonitorWidth(int monitor); // Get specified monitor width (max available by monitor)
-int GetMonitorHeight(int monitor); // Get specified monitor height (max available by monitor)
+int GetMonitorWidth(int monitor); // Get specified monitor width (current video mode used by monitor)
+int GetMonitorHeight(int monitor); // Get specified monitor height (current video mode used by monitor)
 int GetMonitorPhysicalWidth(int monitor); // Get specified monitor physical width in millimetres
 int GetMonitorPhysicalHeight(int monitor); // Get specified monitor physical height in millimetres
 int GetMonitorRefreshRate(int monitor); // Get specified monitor refresh rate
@@ -935,6 +953,8 @@ Vector2 GetWindowScaleDPI(); // Get window scale DPI factor
 const(char)* GetMonitorName(int monitor); // Get the human-readable, UTF-8 encoded name of the primary monitor
 void SetClipboardText(const(char)* text); // Set clipboard text content
 const(char)* GetClipboardText(); // Get clipboard text content
+void EnableEventWaiting(); // Enable waiting for events on EndDrawing(), no automatic event polling
+void DisableEventWaiting(); // Disable waiting for events on EndDrawing(), automatic events polling
 
 // Custom frame control functions
 // NOTE: Those functions are intended for advance users that want full control over the frame processing
@@ -942,7 +962,7 @@ const(char)* GetClipboardText(); // Get clipboard text content
 // To avoid that behaviour and control frame processes manually, enable in config.h: SUPPORT_CUSTOM_FRAME_CONTROL
 void SwapScreenBuffer(); // Swap back buffer with front buffer (screen drawing)
 void PollInputEvents(); // Register all input events
-void WaitTime(float ms); // Wait for some milliseconds (halt program execution)
+void WaitTime(double seconds); // Wait for some time (halt program execution)
 
 // Cursor-related functions
 void ShowCursor(); // Shows cursor
@@ -992,9 +1012,9 @@ Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Get a ray trace from m
 Matrix GetCameraMatrix(Camera camera); // Get camera transform matrix (view matrix)
 Matrix GetCameraMatrix2D(Camera2D camera); // Get camera 2d transform matrix
 Vector2 GetWorldToScreen(Vector3 position, Camera camera); // Get the screen space position for a 3d world space position
+Vector2 GetScreenToWorld2D(Vector2 position, Camera2D camera); // Get the world space position for a 2d camera screen space position
 Vector2 GetWorldToScreenEx(Vector3 position, Camera camera, int width, int height); // Get size position for a 3d world space position
 Vector2 GetWorldToScreen2D(Vector2 position, Camera2D camera); // Get the screen space position for a 2d camera world space position
-Vector2 GetScreenToWorld2D(Vector2 position, Camera2D camera); // Get the world space position for a 2d camera screen space position
 
 // Timing-related functions
 void SetTargetFPS(int fps); // Set target FPS (maximum)
@@ -1014,6 +1034,8 @@ void* MemAlloc(int size); // Internal memory allocator
 void* MemRealloc(void* ptr, int size); // Internal memory reallocator
 void MemFree(void* ptr); // Internal memory free
 
+void OpenURL(const(char)* url); // Open URL with default system browser (if available)
+
 // Set custom callbacks
 // WARNING: Callbacks setup is intended for advance users
 void SetTraceLogCallback(TraceLogCallback callback); // Set custom trace log
@@ -1026,37 +1048,36 @@ void SetSaveFileTextCallback(SaveFileTextCallback callback); // Set custom file
 ubyte* LoadFileData(const(char)* fileName, uint* bytesRead); // Load file data as byte array (read)
 void UnloadFileData(ubyte* data); // Unload file data allocated by LoadFileData()
 bool SaveFileData(const(char)* fileName, void* data, uint bytesToWrite); // Save data to file from byte array (write), returns true on success
+bool ExportDataAsCode(const(char)* data, uint size, const(char)* fileName); // Export data to code (.h), returns true on success
 char* LoadFileText(const(char)* fileName); // Load text data from file (read), returns a '\0' terminated string
 void UnloadFileText(char* text); // Unload file text data allocated by LoadFileText()
 bool SaveFileText(const(char)* fileName, char* text); // Save text data to file (write), string must be '\0' terminated, returns true on success
 bool FileExists(const(char)* fileName); // Check if file exists
 bool DirectoryExists(const(char)* dirPath); // Check if a directory path exists
 bool IsFileExtension(const(char)* fileName, const(char)* ext); // Check file extension (including point: .png, .wav)
+int GetFileLength(const(char)* fileName); // Get file length in bytes (NOTE: GetFileSize() conflicts with windows.h)
 const(char)* GetFileExtension(const(char)* fileName); // Get pointer to extension for a filename string (includes dot: '.png')
 const(char)* GetFileName(const(char)* filePath); // Get pointer to filename for a path string
 const(char)* GetFileNameWithoutExt(const(char)* filePath); // Get filename string without extension (uses static string)
 const(char)* GetDirectoryPath(const(char)* filePath); // Get full path for a given fileName with path (uses static string)
 const(char)* GetPrevDirectoryPath(const(char)* dirPath); // Get previous directory path for a given path (uses static string)
 const(char)* GetWorkingDirectory(); // Get current working directory (uses static string)
-char** GetDirectoryFiles(const(char)* dirPath, int* count); // Get filenames in a directory path (memory should be freed)
-void ClearDirectoryFiles(); // Clear directory files paths buffers (free memory)
+const(char)* GetApplicationDirectory(); // Get the directory if the running application (uses static string)
 bool ChangeDirectory(const(char)* dir); // Change working directory, return true on success
+bool IsPathFile(const(char)* path); // Check if a given path is a file or a directory
+FilePathList LoadDirectoryFiles(const(char)* dirPath); // Load directory filepaths
+FilePathList LoadDirectoryFilesEx(const(char)* basePath, const(char)* filter, bool scanSubdirs); // Load directory filepaths with extension filtering and recursive directory scan
+void UnloadDirectoryFiles(FilePathList files); // Unload filepaths
 bool IsFileDropped(); // Check if a file has been dropped into window
-char** GetDroppedFiles(int* count); // Get dropped files names (memory should be freed)
-void ClearDroppedFiles(); // Clear dropped files paths buffer (free memory)
+FilePathList LoadDroppedFiles(); // Load dropped filepaths
+void UnloadDroppedFiles(FilePathList files); // Unload dropped filepaths
 c_long GetFileModTime(const(char)* fileName); // Get file modification time (last write time)
 
 // Compression/Encoding functionality
-ubyte* CompressData(ubyte* data, int dataLength, int* compDataLength); // Compress data (DEFLATE algorithm)
-ubyte* DecompressData(ubyte* compData, int compDataLength, int* dataLength); // Decompress data (DEFLATE algorithm)
-char* EncodeDataBase64(const(ubyte)* data, int dataLength, int* outputLength); // Encode data to Base64 string
-ubyte* DecodeDataBase64(ubyte* data, int* outputLength); // Decode Base64 string data
-
-// Persistent storage management
-bool SaveStorageValue(uint position, int value); // Save integer value to storage file (to defined position), returns true on success
-int LoadStorageValue(uint position); // Load integer value from storage file (from defined position)
-
-void OpenURL(const(char)* url); // Open URL with default system browser (if available)
+ubyte* CompressData(const(ubyte)* data, int dataSize, int* compDataSize); // Compress data (DEFLATE algorithm), memory must be MemFree()
+ubyte* DecompressData(const(ubyte)* compData, int compDataSize, int* dataSize); // Decompress data (DEFLATE algorithm), memory must be MemFree()
+char* EncodeDataBase64(const(ubyte)* data, int dataSize, int* outputSize); // Encode data to Base64 string, memory must be MemFree()
+ubyte* DecodeDataBase64(const(ubyte)* data, int* outputSize); // Decode Base64 string data, memory must be MemFree()
 
 //------------------------------------------------------------------------------------
 // Input Handling Functions (Module: core)
@@ -1095,7 +1116,8 @@ Vector2 GetMouseDelta(); // Get mouse delta between frames
 void SetMousePosition(int x, int y); // Set mouse position XY
 void SetMouseOffset(int offsetX, int offsetY); // Set mouse offset
 void SetMouseScale(float scaleX, float scaleY); // Set mouse scaling
-float GetMouseWheelMove(); // Get mouse wheel movement Y
+float GetMouseWheelMove(); // Get mouse wheel movement for X or Y, whichever is larger
+Vector2 GetMouseWheelMoveV(); // Get mouse wheel movement for both X and Y
 void SetMouseCursor(int cursor); // Set mouse cursor
 
 // Input-related functions: touch
@@ -1310,13 +1332,14 @@ int GetPixelDataSize(int width, int height, int format); // Get pixel data size
 // Font loading/unloading functions
 Font GetFontDefault(); // Get the default Font
 Font LoadFont(const(char)* fileName); // Load font from file into GPU memory (VRAM)
-Font LoadFontEx(const(char)* fileName, int fontSize, int* fontChars, int glyphCount); // Load font from file with extended parameters
+Font LoadFontEx(const(char)* fileName, int fontSize, int* fontChars, int glyphCount); // Load font from file with extended parameters, use NULL for fontChars and 0 for glyphCount to load the default character set
 Font LoadFontFromImage(Image image, Color key, int firstChar); // Load font from Image (XNA style)
 Font LoadFontFromMemory(const(char)* fileType, const(ubyte)* fileData, int dataSize, int fontSize, int* fontChars, int glyphCount); // Load font from memory buffer, fileType refers to extension: i.e. '.ttf'
 GlyphInfo* LoadFontData(const(ubyte)* fileData, int dataSize, int fontSize, int* fontChars, int glyphCount, int type); // Load font data for further use
 Image GenImageFontAtlas(const(GlyphInfo)* chars, Rectangle** recs, int glyphCount, int fontSize, int padding, int packMethod); // Generate image font atlas using chars info
 void UnloadFontData(GlyphInfo* chars, int glyphCount); // Unload font chars info data (RAM)
-void UnloadFont(Font font); // Unload Font from GPU memory (VRAM)
+void UnloadFont(Font font); // Unload font from GPU memory (VRAM)
+bool ExportFontAsCode(Font font, const(char)* fileName); // Export font as code file, returns true on success
 
 // Text drawing functions
 void DrawFPS(int posX, int posY); // Draw current FPS
@@ -1324,6 +1347,7 @@ void DrawText(const(char)* text, int posX, int posY, int fontSize, Color color);
 void DrawTextEx(Font font, const(char)* text, Vector2 position, float fontSize, float spacing, Color tint); // Draw text using font and additional parameters
 void DrawTextPro(Font font, const(char)* text, Vector2 position, Vector2 origin, float rotation, float fontSize, float spacing, Color tint); // Draw text using Font and pro parameters (rotation)
 void DrawTextCodepoint(Font font, int codepoint, Vector2 position, float fontSize, Color tint); // Draw one character (codepoint)
+void DrawTextCodepoints(Font font, const(int)* codepoints, int count, Vector2 position, float fontSize, float spacing, Color tint); // Draw multiple character (codepoint)
 
 // Text font info functions
 int MeasureText(const(char)* text, int fontSize); // Measure string width for default font
@@ -1338,7 +1362,7 @@ void UnloadCodepoints(int* codepoints); // Unload codepoints data from memory
 int GetCodepointCount(const(char)* text); // Get total number of codepoints in a UTF-8 encoded string
 int GetCodepoint(const(char)* text, int* bytesProcessed); // Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
 const(char)* CodepointToUTF8(int codepoint, int* byteSize); // Encode one codepoint into UTF-8 byte array (array length returned as parameter)
-char* TextCodepointsToUTF8(int* codepoints, int length); // Encode text as codepoints array into UTF-8 text string (WARNING: memory must be freed!)
+char* TextCodepointsToUTF8(const(int)* codepoints, int length); // Encode text as codepoints array into UTF-8 text string (WARNING: memory must be freed!)
 
 // Text strings management functions (no UTF-8 strings, only byte chars)
 // NOTE: Some strings allocate memory internally for returned strings, just be careful!
@@ -1408,14 +1432,13 @@ void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector
 
 // Mesh management functions
 void UploadMesh(Mesh* mesh, bool dynamic); // Upload mesh vertex data in GPU and provide VAO/VBO ids
-void UpdateMeshBuffer(Mesh mesh, int index, void* data, int dataSize, int offset); // Update mesh vertex data in GPU for a specific buffer index
+void UpdateMeshBuffer(Mesh mesh, int index, const(void)* data, int dataSize, int offset); // Update mesh vertex data in GPU for a specific buffer index
 void UnloadMesh(Mesh mesh); // Unload mesh data from CPU and GPU
 void DrawMesh(Mesh mesh, Material material, Matrix transform); // Draw a 3d mesh with material and transform
-void DrawMeshInstanced(Mesh mesh, Material material, Matrix* transforms, int instances); // Draw multiple mesh instances with material and different transforms
+void DrawMeshInstanced(Mesh mesh, Material material, const(Matrix)* transforms, int instances); // Draw multiple mesh instances with material and different transforms
 bool ExportMesh(Mesh mesh, const(char)* fileName); // Export mesh data to file, returns true on success
 BoundingBox GetMeshBoundingBox(Mesh mesh); // Compute mesh bounding box limits
 void GenMeshTangents(Mesh* mesh); // Compute mesh tangents
-void GenMeshBinormals(Mesh* mesh); // Compute mesh binormals
 
 // Mesh generation functions
 Mesh GenMeshPoly(int sides, float radius); // Generate polygonal mesh
@@ -1450,7 +1473,6 @@ bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); // Check collision
 bool CheckCollisionBoxSphere(BoundingBox box, Vector3 center, float radius); // Check collision between box and sphere
 RayCollision GetRayCollisionSphere(Ray ray, Vector3 center, float radius); // Get collision info between ray and sphere
 RayCollision GetRayCollisionBox(Ray ray, BoundingBox box); // Get collision info between ray and box
-RayCollision GetRayCollisionModel(Ray ray, Model model); // Get collision info between ray and model
 RayCollision GetRayCollisionMesh(Ray ray, Mesh mesh, Matrix transform); // Get collision info between ray and mesh
 RayCollision GetRayCollisionTriangle(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3); // Get collision info between ray and triangle
 RayCollision GetRayCollisionQuad(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4); // Get collision info between ray and quad
@@ -1458,6 +1480,7 @@ RayCollision GetRayCollisionQuad(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3, Ve
 //------------------------------------------------------------------------------------
 // Audio Loading and Playing Functions (Module: audio)
 //------------------------------------------------------------------------------------
+alias AudioCallback = void function(void* bufferData, uint frames);
 
 // Audio device management functions
 void InitAudioDevice(); // Initialize audio device and context
@@ -1487,15 +1510,16 @@ int GetSoundsPlaying(); // Get number of sounds playing in the multichannel
 bool IsSoundPlaying(Sound sound); // Check if a sound is currently playing
 void SetSoundVolume(Sound sound, float volume); // Set volume for a sound (1.0 is max level)
 void SetSoundPitch(Sound sound, float pitch); // Set pitch for a sound (1.0 is base level)
-void WaveFormat(Wave* wave, int sampleRate, int sampleSize, int channels); // Convert wave data to desired format
+void SetSoundPan(Sound sound, float pan); // Set pan for a sound (0.5 is center)
 Wave WaveCopy(Wave wave); // Copy a wave to a new wave
 void WaveCrop(Wave* wave, int initSample, int finalSample); // Crop a wave to defined samples range
-float* LoadWaveSamples(Wave wave); // Load samples data from wave as a floats array
+void WaveFormat(Wave* wave, int sampleRate, int sampleSize, int channels); // Convert wave data to desired format
+float* LoadWaveSamples(Wave wave); // Load samples data from wave as a 32bit float data array
 void UnloadWaveSamples(float* samples); // Unload samples data loaded with LoadWaveSamples()
 
 // Music management functions
 Music LoadMusicStream(const(char)* fileName); // Load music stream from file
-Music LoadMusicStreamFromMemory(const(char)* fileType, ubyte* data, int dataSize); // Load music stream from data
+Music LoadMusicStreamFromMemory(const(char)* fileType, const(ubyte)* data, int dataSize); // Load music stream from data
 void UnloadMusicStream(Music music); // Unload music stream
 void PlayMusicStream(Music music); // Start music playing
 bool IsMusicStreamPlaying(Music music); // Check if music is playing
@@ -1506,6 +1530,7 @@ void ResumeMusicStream(Music music); // Resume playing paused music
 void SeekMusicStream(Music music, float position); // Seek music to a position (in seconds)
 void SetMusicVolume(Music music, float volume); // Set volume for music (1.0 is max level)
 void SetMusicPitch(Music music, float pitch); // Set pitch for a music (1.0 is base level)
+void SetMusicPan(Music music, float pan); // Set pan for a music (0.5 is center)
 float GetMusicTimeLength(Music music); // Get music time length (in seconds)
 float GetMusicTimePlayed(Music music); // Get current music time played (in seconds)
 
@@ -1521,6 +1546,11 @@ bool IsAudioStreamPlaying(AudioStream stream); // Check if audio stream is playi
 void StopAudioStream(AudioStream stream); // Stop audio stream
 void SetAudioStreamVolume(AudioStream stream, float volume); // Set volume for audio stream (1.0 is max level)
 void SetAudioStreamPitch(AudioStream stream, float pitch); // Set pitch for audio stream (1.0 is base level)
+void SetAudioStreamPan(AudioStream stream, float pan); // Set pan for audio stream (0.5 is centered)
 void SetAudioStreamBufferSizeDefault(int size); // Default size for new audio streams
+void SetAudioStreamCallback(AudioStream stream, AudioCallback callback); // Audio thread callback to request new data
+
+void AttachAudioStreamProcessor(AudioStream stream, AudioCallback processor); // Attach audio stream processor to stream
+void DetachAudioStreamProcessor(AudioStream stream, AudioCallback processor); // Detach audio stream processor from stream
 
 // RAYLIB_H

+ 89 - 24
source/raymath.d

@@ -21,14 +21,14 @@ import raylib;
 *     - Functions are always self-contained, no function use another raymath function inside,
 *       required code is directly re-implemented inside
 *     - Functions input parameters are always received by value (2 unavoidable exceptions)
-*     - Functions use always a "result" anmed variable for return
+*     - Functions use always a "result" variable for return
 *     - Functions are always defined inline
 *     - Angles are always in radians (DEG2RAD/RAD2DEG macros provided for convenience)
 *
 *
 *   LICENSE: zlib/libpng
 *
-*   Copyright (c) 2015-2021 Ramon Santamaria (@raysan5)
+*   Copyright (c) 2015-2022 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.
@@ -67,6 +67,8 @@ extern (C) @nogc nothrow:
 
 enum PI = 3.14159265358979323846f;
 
+enum EPSILON = 0.000001f;
+
 enum DEG2RAD = PI / 180.0f;
 
 enum RAD2DEG = 180.0f / PI;
@@ -115,7 +117,7 @@ struct float16
     float[16] v;
 }
 
-// Required for: sinf(), cosf(), tan(), atan2f(), sqrtf(), fminf(), fmaxf(), fabs()
+// Required for: sinf(), cosf(), tan(), atan2f(), sqrtf(), floor(), fminf(), fmaxf(), fabs()
 
 //----------------------------------------------------------------------------------
 // Module Functions Definition - Utils math
@@ -138,6 +140,12 @@ float Remap(
     float outputStart,
     float outputEnd);
 
+// Wrap input value from min to max
+float Wrap(float value, float min, float max);
+
+// Check whether two given floats are almost equal
+int FloatEquals(float x, float y);
+
 //----------------------------------------------------------------------------------
 // Module Functions Definition - Vector2 math
 //----------------------------------------------------------------------------------
@@ -172,7 +180,10 @@ float Vector2DotProduct(Vector2 v1, Vector2 v2);
 // Calculate distance between two vectors
 float Vector2Distance(Vector2 v1, Vector2 v2);
 
-// Calculate angle from two vectors in X-axis
+// Calculate square distance between two vectors
+float Vector2DistanceSqr(Vector2 v1, Vector2 v2);
+
+// Calculate angle from two vectors
 float Vector2Angle(Vector2 v1, Vector2 v2);
 
 // Scale vector (multiply by value)
@@ -190,6 +201,9 @@ Vector2 Vector2Divide(Vector2 v1, Vector2 v2);
 // Normalize provided vector
 Vector2 Vector2Normalize(Vector2 v);
 
+// Transforms a Vector2 by a given Matrix
+Vector2 Vector2Transform(Vector2 v, Matrix mat);
+
 // Calculate linear interpolation between two vectors
 Vector2 Vector2Lerp(Vector2 v1, Vector2 v2, float amount);
 
@@ -204,6 +218,19 @@ Vector2 Vector2Rotate(Vector2 v, float angle);
 // Move Vector towards target
 Vector2 Vector2MoveTowards(Vector2 v, Vector2 target, float maxDistance);
 
+// Invert the given vector
+Vector2 Vector2Invert(Vector2 v);
+
+// Clamp the components of the vector between
+// min and max values specified by the given vectors
+Vector2 Vector2Clamp(Vector2 v, Vector2 min, Vector2 max);
+
+// Clamp the magnitude of the vector between two min and max values
+Vector2 Vector2ClampValue(Vector2 v, float min, float max);
+
+// Check whether two given vectors are almost equal
+int Vector2Equals(Vector2 p, Vector2 q);
+
 //----------------------------------------------------------------------------------
 // Module Functions Definition - Vector3 math
 //----------------------------------------------------------------------------------
@@ -252,11 +279,11 @@ float Vector3DotProduct(Vector3 v1, Vector3 v2);
 // Calculate distance between two vectors
 float Vector3Distance(Vector3 v1, Vector3 v2);
 
-// Calculate angle between two vectors in XY and XZ
+// Calculate square distance between two vectors
+float Vector3DistanceSqr(Vector3 v1, Vector3 v2);
 
-// Angle in XZ
-// Angle in XY
-Vector2 Vector3Angle(Vector3 v1, Vector3 v2);
+// Calculate angle between two vectors
+float Vector3Angle(Vector3 v1, Vector3 v2);
 
 // Negate provided vector (invert direction)
 Vector3 Vector3Negate(Vector3 v);
@@ -286,6 +313,22 @@ Vector3 Vector3Transform(Vector3 v, Matrix mat);
 // Transform a vector by quaternion rotation
 Vector3 Vector3RotateByQuaternion(Vector3 v, Quaternion q);
 
+// Rotates a vector around an axis
+
+// Using Euler-Rodrigues Formula
+// Ref.: https://en.wikipedia.org/w/index.php?title=Euler%E2%80%93Rodrigues_formula
+
+// Vector3Normalize(axis);
+
+// Vector3CrossProduct(w, v)
+
+// Vector3CrossProduct(w, wv)
+
+// Vector3Scale(wv, 2 * a)
+
+// Vector3Scale(wwv, 2)
+Vector3 Vector3RotateByAxisAngle(Vector3 v, Vector3 axis, float angle);
+
 // Calculate linear interpolation between two vectors
 Vector3 Vector3Lerp(Vector3 v1, Vector3 v2, float amount);
 
@@ -337,6 +380,27 @@ Vector3 Vector3Unproject(Vector3 source, Matrix projection, Matrix view);
 // Get Vector3 as float array
 float3 Vector3ToFloatV(Vector3 v);
 
+// Invert the given vector
+Vector3 Vector3Invert(Vector3 v);
+
+// Clamp the components of the vector between
+// min and max values specified by the given vectors
+Vector3 Vector3Clamp(Vector3 v, Vector3 min, Vector3 max);
+
+// Clamp the magnitude of the vector between two values
+Vector3 Vector3ClampValue(Vector3 v, float min, float max);
+
+// Check whether two given vectors are almost equal
+int Vector3Equals(Vector3 p, Vector3 q);
+
+// Compute the direction of a refracted ray where v specifies the
+// normalized direction of the incoming ray, n specifies the
+// normalized normal vector of the interface of two optical media,
+// and r specifies the 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
+Vector3 Vector3Refract(Vector3 v, Vector3 n, float r);
+
 //----------------------------------------------------------------------------------
 // Module Functions Definition - Matrix math
 //----------------------------------------------------------------------------------
@@ -359,13 +423,6 @@ Matrix MatrixTranspose(Matrix mat);
 // Calculate the invert determinant (inlined to avoid double-caching)
 Matrix MatrixInvert(Matrix mat);
 
-// Normalize provided matrix
-
-// Cache the matrix values (speed optimization)
-
-// MatrixDeterminant(mat)
-Matrix MatrixNormalize(Matrix mat);
-
 // Get identity matrix
 Matrix MatrixIdentity();
 
@@ -386,28 +443,33 @@ Matrix MatrixTranslate(float x, float y, float z);
 // NOTE: Angle should be provided in radians
 Matrix MatrixRotate(Vector3 axis, float angle);
 
-// Get x-rotation matrix (angle in radians)
+// Get x-rotation matrix
+// NOTE: Angle must be provided in radians
 
 // MatrixIdentity()
 Matrix MatrixRotateX(float angle);
 
-// Get y-rotation matrix (angle in radians)
+// Get y-rotation matrix
+// NOTE: Angle must be provided in radians
 
 // MatrixIdentity()
 Matrix MatrixRotateY(float angle);
 
-// Get z-rotation matrix (angle in radians)
+// Get z-rotation matrix
+// NOTE: Angle must be provided in radians
 
 // MatrixIdentity()
 Matrix MatrixRotateZ(float angle);
 
-// Get xyz-rotation matrix (angles in radians)
+// Get xyz-rotation matrix
+// NOTE: Angle must be provided in radians
 
 // MatrixIdentity()
-Matrix MatrixRotateXYZ(Vector3 ang);
+Matrix MatrixRotateXYZ(Vector3 angle);
 
-// Get zyx-rotation matrix (angles in radians)
-Matrix MatrixRotateZYX(Vector3 ang);
+// Get zyx-rotation matrix
+// NOTE: Angle must be provided in radians
+Matrix MatrixRotateZYX(Vector3 angle);
 
 // Get scaling matrix
 Matrix MatrixScale(float x, float y, float z);
@@ -422,7 +484,7 @@ Matrix MatrixFrustum(
     double far);
 
 // Get perspective projection matrix
-// NOTE: Angle should be provided in radians
+// NOTE: Fovy angle must be provided in radians
 
 // MatrixFrustum(-right, right, -top, top, near, far);
 Matrix MatrixPerspective(double fovy, double aspect, double near, double far);
@@ -524,7 +586,7 @@ Quaternion QuaternionFromMatrix(Matrix mat);
 Matrix QuaternionToMatrix(Quaternion q);
 
 // Get rotation quaternion for an angle and axis
-// NOTE: angle must be provided in radians
+// NOTE: Angle must be provided in radians
 
 // Vector3Normalize(axis)
 
@@ -556,4 +618,7 @@ Vector3 QuaternionToEuler(Quaternion q);
 // Transform a quaternion given a transformation matrix
 Quaternion QuaternionTransform(Quaternion q, Matrix mat);
 
+// Check whether two given quaternions are almost equal
+int QuaternionEquals(Quaternion p, Quaternion q);
+
 // RAYMATH_H

+ 4 - 3
source/easings.d → source/reasings.d

@@ -1,6 +1,6 @@
 /*******************************************************************************************
 *
-*   raylib easings (header only file)
+*   reasings - raylib easings library, based on Robert Penner library
 *
 *   Useful easing functions for values animation
 *
@@ -60,7 +60,7 @@
 *   OF THE POSSIBILITY OF SUCH DAMAGE.
 *   ---------------------------------------------------------------------------------
 *
-*   Copyright (c) 2015 Ramon Santamaria
+*   Copyright (c) 2015-2022 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.
@@ -78,8 +78,9 @@
 *     3. This notice may not be removed or altered from any source distribution.
 *
 **********************************************************************************************/
+module reasings;
 
-extern (C):
+extern (C) nothrow @nogc:
 pragma(inline, true): // NOTE: By default, compile functions as static inline
 
 import core.stdc.math; // Required for: sinf(), cosf(), sqrt(), pow()

+ 71 - 31
source/rlgl.d

@@ -88,7 +88,7 @@ import raylib;
 *
 *   LICENSE: zlib/libpng
 *
-*   Copyright (c) 2014-2021 Ramon Santamaria (@raysan5)
+*   Copyright (c) 2014-2022 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.
@@ -357,7 +357,7 @@ enum rlPixelFormat
 // NOTE 2: Filter is accordingly set for minification and magnification
 enum rlTextureFilter
 {
-    RL_TEXTURE_FILTER_POINT = 0, // No filter, just pixel aproximation
+    RL_TEXTURE_FILTER_POINT = 0, // No filter, just pixel approximation
     RL_TEXTURE_FILTER_BILINEAR = 1, // Linear filtering
     RL_TEXTURE_FILTER_TRILINEAR = 2, // Trilinear filtering (linear with mipmaps)
     RL_TEXTURE_FILTER_ANISOTROPIC_4X = 3, // Anisotropic filtering 4x
@@ -373,7 +373,8 @@ enum rlBlendMode
     RL_BLEND_MULTIPLIED = 2, // Blend textures multiplying colors
     RL_BLEND_ADD_COLORS = 3, // Blend textures adding colors (alternative)
     RL_BLEND_SUBTRACT_COLORS = 4, // Blend textures subtracting colors (alternative)
-    RL_BLEND_CUSTOM = 5 // Belnd textures using custom src/dst factors (use SetBlendModeCustom())
+    RL_BLEND_ALPHA_PREMULTIPLY = 5, // Blend premultiplied textures considering alpha
+    RL_BLEND_CUSTOM = 6 // Blend textures using custom src/dst factors (use rlSetBlendFactors())
 }
 
 // Shader location point type
@@ -537,7 +538,9 @@ void rlglInit(int width, int height); // Initialize rlgl (buffers, shaders, text
 void rlglClose(); // De-inititialize rlgl (buffers, shaders, textures)
 void rlLoadExtensions(void* loader); // Load OpenGL extensions (loader function required)
 int rlGetVersion(); // Get current OpenGL version
+void rlSetFramebufferWidth(int width); // Set current framebuffer width
 int rlGetFramebufferWidth(); // Get default framebuffer width
+void rlSetFramebufferHeight(int height); // Set current framebuffer height
 int rlGetFramebufferHeight(); // Get default framebuffer height
 
 uint rlGetTextureIdDefault(); // Get default texture id
@@ -559,25 +562,26 @@ void rlSetTexture(uint id); // Set current texture for render batch and check bu
 
 // Vertex buffers management
 uint rlLoadVertexArray(); // Load vertex array (vao) if supported
-uint rlLoadVertexBuffer(void* buffer, int size, bool dynamic); // Load a vertex buffer attribute
-uint rlLoadVertexBufferElement(void* buffer, int size, bool dynamic); // Load a new attributes element buffer
-void rlUpdateVertexBuffer(uint bufferId, void* data, int dataSize, int offset); // Update GPU buffer with new data
+uint rlLoadVertexBuffer(const(void)* buffer, int size, bool dynamic); // Load a vertex buffer attribute
+uint rlLoadVertexBufferElement(const(void)* buffer, int size, bool dynamic); // Load a new attributes element buffer
+void rlUpdateVertexBuffer(uint bufferId, const(void)* data, int dataSize, int offset); // Update GPU buffer with new data
+void rlUpdateVertexBufferElements(uint id, const(void)* data, int dataSize, int offset); // Update vertex buffer elements with new data
 void rlUnloadVertexArray(uint vaoId);
 void rlUnloadVertexBuffer(uint vboId);
-void rlSetVertexAttribute(uint index, int compSize, int type, bool normalized, int stride, void* pointer);
+void rlSetVertexAttribute(uint index, int compSize, int type, bool normalized, int stride, const(void)* pointer);
 void rlSetVertexAttributeDivisor(uint index, int divisor);
 void rlSetVertexAttributeDefault(int locIndex, const(void)* value, int attribType, int count); // Set vertex attribute default value
 void rlDrawVertexArray(int offset, int count);
-void rlDrawVertexArrayElements(int offset, int count, void* buffer);
+void rlDrawVertexArrayElements(int offset, int count, const(void)* buffer);
 void rlDrawVertexArrayInstanced(int offset, int count, int instances);
-void rlDrawVertexArrayElementsInstanced(int offset, int count, void* buffer, int instances);
+void rlDrawVertexArrayElementsInstanced(int offset, int count, const(void)* buffer, int instances);
 
 // Textures management
-uint rlLoadTexture(void* data, int width, int height, int format, int mipmapCount); // Load texture in GPU
+uint rlLoadTexture(const(void)* data, int width, int height, int format, int mipmapCount); // Load texture in GPU
 uint rlLoadTextureDepth(int width, int height, bool useRenderBuffer); // Load depth texture/renderbuffer (to be attached to fbo)
-uint rlLoadTextureCubemap(void* data, int size, int format); // Load texture cubemap
+uint rlLoadTextureCubemap(const(void)* data, int size, int format); // Load texture cubemap
 void rlUpdateTexture(uint id, int offsetX, int offsetY, int width, int height, int format, const(void)* data); // Update GPU texture with new data
-void rlGetGlTextureFormats(int format, int* glInternalFormat, int* glFormat, int* glType); // Get OpenGL internal formats
+void rlGetGlTextureFormats(int format, uint* glInternalFormat, uint* glFormat, uint* glType); // Get OpenGL internal formats
 const(char)* rlGetPixelFormatName(uint format); // Get name string for pixel format
 void rlUnloadTexture(uint id); // Unload texture from GPU memory
 void rlGenTextureMipmaps(uint id, int width, int height, int format, int* mipmaps); // Generate mipmap data for selected texture
@@ -741,8 +745,8 @@ void rlLoadDrawQuad(); // Load and draw a quad
 // Blending destination factor
 // Blending equation
 
-// Default framebuffer width
-// Default framebuffer height
+// Current framebuffer width
+// Current framebuffer height
 
 // Renderer state
 
@@ -845,6 +849,7 @@ void rlLoadDrawQuad(); // Load and draw a quad
 // response to it is platform/compiler dependant
 
 // Set the viewport area (transformation from normalized device coordinates to window coordinates)
+// NOTE: We store current viewport dimensions
 
 //----------------------------------------------------------------------------------
 // Module Functions Definition - Vertex level operations
@@ -935,6 +940,8 @@ void rlLoadDrawQuad(); // Load and draw a quad
 
 // Set texture parameters (wrap mode/filter mode)
 
+// Reset anisotropy filter, in case it was set
+
 // Enable shader program
 
 // Disable shader program
@@ -1012,6 +1019,8 @@ void rlLoadDrawQuad(); // Load and draw a quad
 
 // Set blend mode
 
+// NOTE: Using GL blend src/dst factors and GL equation configured with rlSetBlendFactors()
+
 // Set blending mode factor and equation
 
 //----------------------------------------------------------------------------------
@@ -1171,13 +1180,7 @@ void rlLoadDrawQuad(); // Load and draw a quad
 
 // Show some OpenGL GPU capabilities
 
-/*
-// Following capabilities are only supported by OpenGL 4.3 or greater
-glGetIntegerv(GL_MAX_VERTEX_ATTRIB_BINDINGS, &capability);
-TRACELOG(RL_LOG_INFO, "    GL_MAX_VERTEX_ATTRIB_BINDINGS: %i", capability);
-glGetIntegerv(GL_MAX_UNIFORM_LOCATIONS, &capability);
-TRACELOG(RL_LOG_INFO, "    GL_MAX_UNIFORM_LOCATIONS: %i", capability);
-*/
+// GRAPHICS_API_OPENGL_43
 // RLGL_SHOW_GL_DETAILS_INFO
 
 // Show some basic info about GL supported features
@@ -1190,6 +1193,10 @@ TRACELOG(RL_LOG_INFO, "    GL_MAX_UNIFORM_LOCATIONS: %i", capability);
 
 // NOTE: Force OpenGL 3.3 on OSX
 
+// Set current framebuffer width
+
+// Set current framebuffer height
+
 // Get default framebuffer width
 
 // Get default framebuffer height
@@ -1352,6 +1359,8 @@ TRACELOG(RL_LOG_INFO, "    GL_MAX_UNIFORM_LOCATIONS: %i", capability);
 
 // Unbind shader program
 
+// Restore viewport to default measures
+
 //------------------------------------------------------------------------------------------------------------
 
 // Reset batch buffers
@@ -1489,11 +1498,9 @@ TRACELOG(RL_LOG_INFO, "    GL_MAX_UNIFORM_LOCATIONS: %i", capability);
 
 // Once mipmaps have been generated and data has been uploaded to GPU VRAM, we can discard RAM data
 
-//glHint(GL_GENERATE_MIPMAP_HINT, GL_DONT_CARE);   // Hint for mipmaps generation algorythm: GL_FASTEST, GL_NICEST, GL_DONT_CARE
+//glHint(GL_GENERATE_MIPMAP_HINT, GL_DONT_CARE);   // Hint for mipmaps generation algorithm: GL_FASTEST, GL_NICEST, GL_DONT_CARE
 // Generate mipmaps automatically
 
-// Activate Trilinear filtering for mipmaps
-
 // Read texture pixel data
 
 // NOTE: Using texture id, we can retrieve some texture info (but not on OpenGL ES 2.0)
@@ -1618,16 +1625,48 @@ TRACELOG(RL_LOG_INFO, "    GL_MAX_UNIFORM_LOCATIONS: %i", capability);
 // Load shader from code strings
 // NOTE: If shader string is NULL, using default vertex/fragment shaders
 
-// Detach shader before deletion to make sure memory is freed
+// Compile vertex shader (if provided)
+
+// In case no vertex shader was provided or compilation failed, we use default vertex shader
 
-// Detach shader before deletion to make sure memory is freed
+// Compile fragment shader (if provided)
 
-// Get available shader uniforms
-// NOTE: This information is useful for debug...
+// In case no fragment shader was provided or compilation failed, we use default fragment shader
 
-// Assume no variable names longer than 256
+// In case vertex and fragment shader are the default ones, no need to recompile, we can just assign the default shader program id
 
-// Get the name of the uniforms
+// One of or both shader are new, we need to compile a new shader program
+
+// We can detach and delete vertex/fragment shaders (if not default ones)
+// NOTE: We detach shader before deletion to make sure memory is freed
+
+// In case shader program loading failed, we assign default shader
+
+// In case shader loading fails, we return the default shader
+
+/*
+else
+{
+    // Get available shader uniforms
+    // NOTE: This information is useful for debug...
+    int uniformCount = -1;
+    glGetProgramiv(id, GL_ACTIVE_UNIFORMS, &uniformCount);
+
+    for (int i = 0; i < uniformCount; i++)
+    {
+        int namelen = -1;
+        int num = -1;
+        char name[256] = { 0 };     // Assume no variable names longer than 256
+        GLenum type = GL_ZERO;
+
+        // Get the name of the uniforms
+        glGetActiveUniform(id, i, sizeof(name) - 1, &namelen, &num, &type, name);
+
+        name[namelen] = 0;
+        TRACELOGD("SHADER: [ID %i] Active uniform (%s) set at location: %i", id, name, glGetUniformLocation(id, name));
+    }
+}
+*/
 
 // Compile custom shader and return shader id
 
@@ -1802,7 +1841,8 @@ TRACELOG(RL_LOG_INFO, "    GL_MAX_UNIFORM_LOCATIONS: %i", capability);
 
 // Precision required for OpenGL ES2 (WebGL)
 
-// NOTE: Compiled vertex/fragment shaders are kept for re-use
+// NOTE: Compiled vertex/fragment shaders are not deleted,
+// they are kept for re-use as default shaders in case some shader loading fails
 // Compile default vertex shader
 // Compile default fragment shader