From c994145e2b8cdc4e890c00176185743b5df5dc93 Mon Sep 17 00:00:00 2001 From: ChrisDill Date: Sun, 19 Mar 2023 14:57:25 +0000 Subject: [PATCH] Update bindings to raylib 4.5 --- Raylib-cs/interop/Raylib.cs | 308 +++++++++++++++++++------------- Raylib-cs/interop/Raymath.cs | 13 +- Raylib-cs/interop/Rlgl.cs | 82 +++++++-- Raylib-cs/types/Core.cs | 9 +- Raylib-cs/types/Input.cs | 2 +- Raylib-cs/types/Ray.cs | 4 +- Raylib-cs/types/Raylib.Utils.cs | 20 +-- Raylib-cs/types/Texture2D.cs | 2 +- 8 files changed, 279 insertions(+), 161 deletions(-) diff --git a/Raylib-cs/interop/Raylib.cs b/Raylib-cs/interop/Raylib.cs index 81ad262..b371b66 100644 --- a/Raylib-cs/interop/Raylib.cs +++ b/Raylib-cs/interop/Raylib.cs @@ -13,7 +13,7 @@ namespace Raylib_cs /// public const string nativeLibName = "raylib"; - public const string RAYLIB_VERSION = "4.2"; + public const string RAYLIB_VERSION = "4.5"; public const float DEG2RAD = MathF.PI / 180.0f; public const float RAD2DEG = 180.0f / MathF.PI; @@ -98,10 +98,14 @@ namespace Raylib_cs [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void RestoreWindow(); - /// Set icon for window (only PLATFORM_DESKTOP) + /// Set icon for window (single image, RGBA 32bit, only PLATFORM_DESKTOP) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void SetWindowIcon(Image image); + /// Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP) + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SetWindowIcons(Image* images, int count); + /// Set title for window (only PLATFORM_DESKTOP) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void SetWindowTitle(sbyte* title); @@ -342,6 +346,10 @@ namespace Raylib_cs [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern Shader LoadShaderFromMemory(sbyte* vsCode, sbyte* fsCode); + /// Check if a shader is ready + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsShaderReady(Shader shader); + /// Get shader uniform location [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern int GetShaderLocation(Shader shader, sbyte* uniformName); @@ -352,19 +360,19 @@ namespace Raylib_cs /// Set shader uniform value [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetShaderValue(Shader shader, int uniformLoc, void* value, ShaderUniformDataType uniformType); + public static extern void SetShaderValue(Shader shader, int locIndex, void* value, ShaderUniformDataType uniformType); /// Set shader uniform value vector [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetShaderValueV(Shader shader, int uniformLoc, void* value, ShaderUniformDataType uniformType, int count); + public static extern void SetShaderValueV(Shader shader, int locIndex, void* value, ShaderUniformDataType uniformType, int count); /// Set shader uniform value (matrix 4x4) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix4x4 mat); + public static extern void SetShaderValueMatrix(Shader shader, int locIndex, Matrix4x4 mat); - /// Set shader uniform value for texture + /// Set shader uniform value for texture (sampler2d) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetShaderValueTexture(Shader shader, int uniformLoc, Texture2D texture); + public static extern void SetShaderValueTexture(Shader shader, int locIndex, Texture2D texture); /// Unload shader from GPU memory (VRAM) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] @@ -500,7 +508,7 @@ namespace Raylib_cs /// Export data to code (.h), returns true on success [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool ExportDataAsCode(sbyte* data, uint size, sbyte* fileName); + public static extern CBool ExportDataAsCode(byte* data, uint size, sbyte* fileName); // Load text data from file (read), returns a '\0' terminated string [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] @@ -558,11 +566,15 @@ namespace Raylib_cs [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern sbyte* GetApplicationDirectory(); - /// Get filenames in a directory path (memory should be freed) + /// Load directory filepaths [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern FilePathList LoadDirectoryFiles(sbyte* dirPath, int* count); - /// Clear directory files paths buffers (free memory) + /// Load directory filepaths with extension filtering and recursive directory scan + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern FilePathList LoadDirectoryFilesEx(sbyte* basePath, sbyte* filter, CBool scanSubdirs); + + /// Unload filepaths [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void UnloadDirectoryFiles(FilePathList files); @@ -639,11 +651,11 @@ namespace Raylib_cs [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void SetExitKey(KeyboardKey key); - /// Get key pressed (keycode), call it multiple times for keys queued + /// Get key pressed (keycode), call it multiple times for keys queued, returns 0 when the queue is empty [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern int GetKeyPressed(); - /// Get char pressed (unicode), call it multiple times for chars queued + /// Get char pressed (unicode), call it multiple times for chars queued, returns 0 when the queue is empty [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern int GetCharPressed(); @@ -823,23 +835,11 @@ namespace Raylib_cs /// Update camera position for selected mode [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UpdateCamera(Camera3D* camera); + public static extern void UpdateCamera(Camera3D* camera, CameraMode mode); - /// Set camera pan key to combine with mouse movement (free camera) + /// Update camera movement/rotation [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetCameraPanControl(KeyboardKey panKey); - - /// Set camera alt key to combine with mouse movement (free camera) - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetCameraAltControl(KeyboardKey altKey); - - /// Set camera smooth zoom key to combine with mouse (free camera) - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetCameraSmoothZoomControl(KeyboardKey szKey); - - /// Set camera move controls (1st person and 3rd person cameras) - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetCameraMoveControls(KeyboardKey frontKey, KeyboardKey backKey, KeyboardKey rightKey, KeyboardKey leftKey, KeyboardKey upKey, KeyboardKey downKey); + public static extern void UpdateCameraPro(Camera3D* camera, Vector3 movement, Vector3 rotation, float zoom); //------------------------------------------------------------------------------------ // Basic Shapes Drawing Functions (Module: shapes) @@ -1030,6 +1030,10 @@ namespace Raylib_cs [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern CBool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Vector2 p3); + /// Check if point is within a polygon described by array of vertices + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool CheckCollisionPointPoly(Vector2 point, Vector2* points, int pointCount); + /// Check the collision between two lines defined by two points each, returns collision point by reference [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern CBool CheckCollisionLines(Vector2 startPos1, Vector2 endPos1, Vector2 startPos2, Vector2 endPos2, Vector2* collisionPoint); @@ -1074,6 +1078,10 @@ namespace Raylib_cs [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern Image LoadImageFromScreen(); + /// Check if an image is ready + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsImageReady(Image image); + /// Unload image from CPU memory (RAM) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void UnloadImage(Image image); @@ -1113,10 +1121,18 @@ namespace Raylib_cs [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern Image GenImageWhiteNoise(int width, int height, float factor); + /// Generate image: perlin noise + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Image GenImagePerlinNoise(int width, int height, int offsetX, int offsetY, float scale); + /// Generate image: cellular algorithm, bigger tileSize means bigger cells [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern Image GenImageCellular(int width, int height, int tileSize); + /// Generate image: grayscale image from text data + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Image GenImageText(int width, int height, int tileSize); + // Image manipulation functions @@ -1136,33 +1152,37 @@ namespace Raylib_cs [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern Image ImageTextEx(Font font, sbyte* text, float fontSize, float spacing, Color tint); - /// Convert image to POT (power-of-two) - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageToPOT(Image* image, Color fill); - /// Convert image data to desired format [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void ImageFormat(Image* image, PixelFormat newFormat); - /// Apply alpha mask to image + /// Convert image to POT (power-of-two) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageAlphaMask(Image* image, Image alphaMask); + public static extern void ImageToPOT(Image* image, Color fill); - /// Clear alpha channel to desired color + /// Crop an image to a defined rectangle [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageAlphaClear(Image* image, Color color, float threshold); + public static extern void ImageCrop(Image* image, Rectangle crop); /// Crop image depending on alpha value [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void ImageAlphaCrop(Image* image, float threshold); + /// Clear alpha channel to desired color + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void ImageAlphaClear(Image* image, Color color, float threshold); + + /// Apply alpha mask to image + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void ImageAlphaMask(Image* image, Image alphaMask); + /// Premultiply alpha channel [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void ImageAlphaPremultiply(Image* image); - /// Crop an image to a defined rectangle + /// Apply Gaussian blur using a box blur approximation [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageCrop(Image* image, Rectangle crop); + public static extern void ImageBlurGaussian(Image* image, int blurSize); /// Resize image (Bicubic scaling algorithm) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] @@ -1280,6 +1300,14 @@ namespace Raylib_cs [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void ImageDrawCircleV(Image* dst, Vector2 center, int radius, Color color); + /// Draw circle outline within an image + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void ImageDrawCircleLines(Image* dst, int centerX, int centerY, int radius, Color color); + + /// Draw circle outline within an image (Vector version) + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void ImageDrawCircleLinesV(Image* dst, Vector2 center, int radius, Color color); + /// Draw rectangle within an image [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void ImageDrawRectangle(Image* dst, int posX, int posY, int width, int height, Color color); @@ -1328,10 +1356,18 @@ namespace Raylib_cs [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern RenderTexture2D LoadRenderTexture(int width, int height); + /// Check if a texture is ready + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsTextureReady(Texture2D texture); + /// Unload texture from GPU memory (VRAM) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void UnloadTexture(Texture2D texture); + /// Check if a render texture is ready + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsRenderTextureReady(RenderTexture2D target); + /// Unload render texture from GPU memory (VRAM) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void UnloadRenderTexture(RenderTexture2D target); @@ -1378,14 +1414,6 @@ namespace Raylib_cs [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void DrawTextureRec(Texture2D texture, Rectangle source, Vector2 position, Color tint); - /// Draw texture quad with tiling and offset parameters - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawTextureQuad(Texture2D texture, Vector2 tiling, Vector2 offset, Rectangle quad, Color tint); - - /// Draw part of a texture (defined by a rectangle) with rotation and scale tiled into dest - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawTextureTiled(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, float scale, Color tint); - /// Draw a part of a texture defined by a rectangle with 'pro' parameters [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void DrawTexturePro(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, Color tint); @@ -1394,10 +1422,6 @@ namespace Raylib_cs [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle dest, Vector2 origin, float rotation, Color tint); - /// Draw a textured polygon - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawTexturePoly(Texture2D texture, Vector2 center, Vector2* points, Vector2* texcoords, int pointsCount, Color tint); - // Color/pixel related functions @@ -1421,6 +1445,18 @@ namespace Raylib_cs [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern Color ColorFromHSV(float hue, float saturation, float value); + /// Get color multiplied with another color + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Color ColorTint(Color color, Color tint); + + /// Get color with brightness correction, brightness factor goes from -1.0f to 1.0f + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Color ColorBrightness(Color color, float factor); + + /// Get color with contrast correction, contrast values between -1.0f and 1.0f + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Color ColorContrast(Color color, float contrast); + /// Get color with alpha applied, alpha goes from 0.0f to 1.0f [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern Color ColorAlpha(Color color, float alpha); @@ -1475,6 +1511,10 @@ namespace Raylib_cs [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern Font LoadFontFromMemory(sbyte* fileType, byte* fileData, int dataSize, int fontSize, int* fontChars, int glyphCount); + /// Check if a font is ready + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsFontReady(Font font); + /// Load font data for further use [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern GlyphInfo* LoadFontData(byte* fileData, int dataSize, int fontSize, int* fontChars, int glyphCount, FontType type); @@ -1547,7 +1587,15 @@ namespace Raylib_cs // Text codepoints management functions (unicode characters) - /// Get all codepoints in a string, codepoints count returned by parameters + /// Load UTF-8 text encoded from codepoints array + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern sbyte* LoadUTF8(int* codepoints, int length); + + /// Unload UTF-8 text encoded from codepoints array + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void UnloadUTF8(int* text); + + /// Load all codepoints from a UTF-8 text string, codepoints count returned by parameter [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern int* LoadCodepoints(sbyte* text, int* count); @@ -1559,17 +1607,21 @@ namespace Raylib_cs [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern int GetCodepointCount(sbyte* text); - /// Get next codepoint in a UTF8 encoded string; 0x3f('?') is returned on failure + /// Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int GetCodepoint(sbyte* text, int* bytesProcessed); + public static extern int GetCodepoint(sbyte* text, int* codepointSize); - /// Encode codepoint into utf8 text (char array length returned as parameter) + /// Get next codepoint in a UTF-8 encoded string; 0x3f('?') is returned on failure [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* CodepointToUTF8(int codepoint, int* byteSize); + public static extern int GetCodepointNext(sbyte* text, int* codepointSize); - /// Encode text as codepoints array into UTF-8 text string (WARNING: memory must be freed!) + /// Get previous codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* TextCodepointsToUTF8(int* codepoints, int length); + public static extern int GetCodepointPrevious(sbyte* text, int* codepointSize); + + /// Encode one codepoint into UTF-8 byte array (array length returned as parameter) + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern sbyte* CodepointToUTF8(int codepoint, int* utf8Size); // Text strings management functions (no UTF-8 strings, only byte chars) @@ -1678,14 +1730,6 @@ namespace Raylib_cs [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void DrawCubeWiresV(Vector3 position, Vector3 size, Color color); - /// Draw cube textured - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float height, float length, Color color); - - /// Draw cube with a region of a texture - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawCubeTextureRec(Texture2D texture, Vector3 position, float width, float height, float length, Color color); - /// Draw sphere [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void DrawSphere(Vector3 centerPos, float radius, Color color); @@ -1714,6 +1758,14 @@ namespace Raylib_cs [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void DrawCylinderWiresEx(Vector3 startPos, Vector3 endPos, float startRadius, float endRadius, int sides, Color color); + /// Draw a capsule with the center of its sphere caps at startPos and endPos + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawCapsule(Vector3 startPos, Vector3 endPos, float radius, int slices, int rings, Color color); + + /// Draw capsule wireframe with the center of its sphere caps at startPos and endPos + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawCapsuleWires(Vector3 startPos, Vector3 endPos, float radius, int slices, int rings, Color color); + /// Draw a plane XZ [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void DrawPlane(Vector3 centerPos, Vector2 size, Color color); @@ -1731,7 +1783,7 @@ namespace Raylib_cs // Model 3d Loading and Drawing Functions (Module: models) //------------------------------------------------------------------------------------ - // Model loading/unloading functions + // Model management functions /// Load model from files (meshes and materials) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] @@ -1741,19 +1793,55 @@ namespace Raylib_cs [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern Model LoadModelFromMesh(Mesh mesh); + /// Check if a model is ready + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsModelReady(Model model); + /// Unload model from memory (RAM and/or VRAM) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void UnloadModel(Model model); - /// Unload model (but not meshes) from memory (RAM and/or VRAM) - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadModelKeepMeshes(Model model); - /// Compute model bounding box limits (considers all meshes) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern BoundingBox GetModelBoundingBox(Model model); - // Mesh loading/unloading functions + + // Model drawing functions + + /// Draw a model (with texture if set) + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawModel(Model model, Vector3 position, float scale, Color tint); + + /// Draw a model with extended parameters + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint); + + /// Draw a model wires (with texture if set) + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawModelWires(Model model, Vector3 position, float scale, Color tint); + + /// Draw a model wires (with texture if set) with extended parameters + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint); + + /// Draw bounding box (wires) + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawBoundingBox(BoundingBox box, Color color); + + /// Draw a billboard texture + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawBillboard(Camera3D camera, Texture2D texture, Vector3 center, float size, Color tint); + + /// Draw a billboard texture defined by source + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawBillboardRec(Camera3D camera, Texture2D texture, Rectangle source, Vector3 position, Vector2 size, Color tint); + + /// Draw a billboard texture defined by source and rotation + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void DrawBillboardPro(Camera3D camera, Texture2D texture, Rectangle source, Vector3 position, Vector3 up, Vector2 size, Vector2 origin, float rotation, Color tint); + + + // Mesh management functions /// Upload vertex data into GPU and provided VAO/VBO ids [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] @@ -1787,29 +1875,6 @@ namespace Raylib_cs [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void GenMeshTangents(Mesh* mesh); - // Material loading/unloading functions - - //TODO: safe Helper method - /// Load materials from model file - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Material* LoadMaterials(sbyte* fileName, int* materialCount); - - /// Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps) - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Material LoadMaterialDefault(); - - /// Unload material from GPU memory (VRAM) - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadMaterial(Material material); - - /// Set texture for a material map type (MAP_DIFFUSE, MAP_SPECULAR...) - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetMaterialTexture(Material* material, MaterialMapIndex mapType, Texture2D texture); - - /// Set material for a mesh - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetModelMeshMaterial(Model* model, int meshId, int materialId); - // Mesh generation functions @@ -1857,39 +1922,34 @@ namespace Raylib_cs [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize); - // Model drawing functions - /// Draw a model (with texture if set) - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawModel(Model model, Vector3 position, float scale, Color tint); + // Material loading/unloading functions - /// Draw a model with extended parameters + //TODO: safe Helper method + /// Load materials from model file [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint); + public static extern Material* LoadMaterials(sbyte* fileName, int* materialCount); - /// Draw a model wires (with texture if set) + /// Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawModelWires(Model model, Vector3 position, float scale, Color tint); + public static extern Material LoadMaterialDefault(); - /// Draw a model wires (with texture if set) with extended parameters + /// Check if a material is ready [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint); + public static extern CBool IsMaterialReady(); - /// Draw bounding box (wires) + /// Unload material from GPU memory (VRAM) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawBoundingBox(BoundingBox box, Color color); + public static extern void UnloadMaterial(Material material); - /// Draw a billboard texture + /// Set texture for a material map type (MAP_DIFFUSE, MAP_SPECULAR...) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawBillboard(Camera3D camera, Texture2D texture, Vector3 center, float size, Color tint); + public static extern void SetMaterialTexture(Material* material, MaterialMapIndex mapType, Texture2D texture); - /// Draw a billboard texture defined by source + /// Set material for a mesh [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawBillboardRec(Camera3D camera, Texture2D texture, Rectangle source, Vector3 position, Vector2 size, Color tint); + public static extern void SetModelMeshMaterial(Model* model, int meshId, int materialId); - /// Draw a billboard texture defined by source and rotation - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void DrawBillboardPro(Camera3D camera, Texture2D texture, Rectangle source, Vector3 position, Vector3 up, Vector2 size, Vector2 origin, float rotation, Color tint); // Model animations loading/unloading functions @@ -1981,6 +2041,10 @@ namespace Raylib_cs [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern Wave LoadWaveFromMemory(sbyte* fileType, byte* fileData, int dataSize); + /// Checks if wave data is ready + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsWaveReady(Wave wave); + /// Load sound from file [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern Sound LoadSound(sbyte* fileName); @@ -1989,6 +2053,10 @@ namespace Raylib_cs [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern Sound LoadSoundFromWave(Wave wave); + /// Checks if a sound is ready + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsSoundReady(Sound sound); + /// Update sound buffer with new data [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void UpdateSound(Sound sound, void* data, int samplesCount); @@ -2028,14 +2096,6 @@ namespace Raylib_cs [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void ResumeSound(Sound sound); - /// Play a sound (using multichannel buffer pool) - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void PlaySoundMulti(Sound sound); - - /// Stop any sound playing (using multichannel buffer pool) - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void StopSoundMulti(); - /// Get number of sounds playing in the multichannel [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern int GetSoundsPlaying(); @@ -2087,6 +2147,10 @@ namespace Raylib_cs [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern Music LoadMusicStreamFromMemory(sbyte* fileType, byte* data, int dataSize); + /// Checks if a music stream is ready + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsMusicReady(Music music); + /// Unload music stream [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void UnloadMusicStream(Music music); @@ -2146,6 +2210,10 @@ namespace Raylib_cs [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern AudioStream LoadAudioStream(uint sampleRate, uint sampleSize, uint channels); + /// Checks if an audio stream is ready + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern CBool IsAudioStreamReady(AudioStream stream); + /// Unload audio stream and free memory [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void UnloadAudioStream(AudioStream stream); diff --git a/Raylib-cs/interop/Raymath.cs b/Raylib-cs/interop/Raymath.cs index eae874f..dc3ba49 100644 --- a/Raylib-cs/interop/Raymath.cs +++ b/Raylib-cs/interop/Raymath.cs @@ -91,10 +91,21 @@ namespace Raylib_cs [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern float Vector2DistanceSqr(Vector2 v1, Vector2 v2); - /// Calculate angle from two vectors + /// + /// Calculate angle between two vectors + /// NOTE: Angle is calculated from origin point (0, 0) + /// [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern float Vector2Angle(Vector2 v1, Vector2 v2); + /// + /// Calculate angle defined by a two vectors line + /// NOTE: Parameters need to be normalized + /// Current implementation should be aligned with glm::angle + /// + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern float Vector2LineAngle(Vector2 start, Vector2 end); + /// Scale vector (multiply by value) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern Vector2 Vector2Scale(Vector2 v, float scale); diff --git a/Raylib-cs/interop/Rlgl.cs b/Raylib-cs/interop/Rlgl.cs index 5413c39..79286bd 100644 --- a/Raylib-cs/interop/Rlgl.cs +++ b/Raylib-cs/interop/Rlgl.cs @@ -33,13 +33,13 @@ namespace Raylib_cs public const int RL_TEXTURE_FILTER_LINEAR_MIP_NEAREST = 0x2701; public const int RL_TEXTURE_FILTER_MIP_LINEAR = 0x2703; public const int RL_TEXTURE_FILTER_ANISOTROPIC = 0x3000; + public const int RL_TEXTURE_MIPMAP_BIAS_RATIO = 0x4000; public const int RL_TEXTURE_WRAP_REPEAT = 0x2901; public const int RL_TEXTURE_WRAP_CLAMP = 0x812F; public const int RL_TEXTURE_WRAP_MIRROR_REPEAT = 0x8370; public const int RL_TEXTURE_WRAP_MIRROR_CLAMP = 0x8742; - // GL equivalent data types public const int RL_UNSIGNED_BYTE = 0x1401; public const int RL_FLOAT = 0x1406; @@ -55,6 +55,37 @@ namespace Raylib_cs public const int RL_DYNAMIC_READ = 0x88E9; public const int RL_DYNAMIC_COPY = 0x88EA; + // GL blending factors + public const int RL_ZERO = 0; + public const int RL_ONE = 1; + public const int RL_SRC_COLOR = 0x0300; + public const int RL_ONE_MINUS_SRC_COLOR = 0x0301; + public const int RL_SRC_ALPHA = 0x0302; + public const int RL_ONE_MINUS_SRC_ALPHA = 0x0303; + public const int RL_DST_ALPHA = 0x0304; + public const int RL_ONE_MINUS_DST_ALPHA = 0x0305; + public const int RL_DST_COLOR = 0x0306; + public const int RL_ONE_MINUS_DST_COLOR = 0x0307; + public const int RL_SRC_ALPHA_SATURATE = 0x0308; + public const int RL_CONSTANT_COLOR = 0x8001; + public const int RL_ONE_MINUS_CONSTANT_COLOR = 0x8002; + public const int RL_CONSTANT_ALPHA = 0x8003; + public const int RL_ONE_MINUS_CONSTANT_ALPHA = 0x8004; + + // GL blending functions/equations + public const int RL_FUNC_ADD = 0x8006; + public const int RL_MIN = 0x8007; + public const int RL_MAX = 0x8008; + public const int RL_FUNC_SUBTRACT = 0x800A; + public const int RL_FUNC_REVERSE_SUBTRACT = 0x800B; + public const int RL_BLEND_EQUATION = 0x8009; + public const int RL_BLEND_EQUATION_RGB = 0x8009; + public const int RL_BLEND_EQUATION_ALPHA = 0x883D; + public const int RL_BLEND_DST_RGB = 0x80C8; + public const int RL_BLEND_SRC_RGB = 0x80C9; + public const int RL_BLEND_DST_ALPHA = 0x80CA; + public const int RL_BLEND_SRC_ALPHA = 0x80CB; + public const int RL_BLEND_COLOR = 0x8005; // ------------------------------------------------------------------------------------ // Functions Declaration - Matrix operations @@ -245,6 +276,10 @@ namespace Raylib_cs [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void rlTextureParameters(uint id, int param, int value); + /// Set cubemap parameters (filter, wrap) + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void rlCubemapParameters(uint id, int param, int value); + // Shader state @@ -306,6 +341,10 @@ namespace Raylib_cs [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void rlDisableBackfaceCulling(); + /// Set face culling mode + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void rlSetCullFace(int mode); + /// Enable scissor test [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void rlEnableScissorTest(); @@ -374,6 +413,10 @@ namespace Raylib_cs [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void rlSetBlendFactors(int glSrcFactor, int glDstFactor, int glEquation); + /// Set blending mode factors and equations separately (using OpenGL factors) + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void rlSetBlendFactorsSeparate(int glSrcRGB, int glDstRGB, int glSrcAlpha, int glDstAlpha, int glEqRGB, int glEqAlpha); + // ------------------------------------------------------------------------------------ // Functions Declaration - rlgl functionality @@ -558,7 +601,7 @@ namespace Raylib_cs /// Delete framebuffer from GPU [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern CBool rlUnloadFramebuffer(uint id); + public static extern void rlUnloadFramebuffer(uint id); // Shaders management @@ -615,9 +658,12 @@ namespace Raylib_cs [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void rlComputeShaderDispatch(uint groupX, uint groupY, uint groupZ); + + // Shader buffer storage object management (ssbo) + /// Load shader storage buffer object (SSBO) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern uint rlLoadShaderBuffer(ulong size, void* data, int usageHint); + public static extern uint rlLoadShaderBuffer(uint size, void* data, int usageHint); /// Unload shader storage buffer object (SSBO) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] @@ -625,30 +671,30 @@ namespace Raylib_cs /// Update SSBO buffer data [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void rlUpdateShaderBufferElements(uint id, void* data, ulong dataSize, ulong offset); + public static extern void rlUpdateShaderBuffer(uint id, void* data, uint dataSize, uint offset); + + /// Bind SSBO buffer data + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void rlBindShaderBuffer(uint id, uint index); + + /// Read SSBO buffer data (GPU->CPU) + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void rlReadShaderBuffer(uint id, void* dest, uint count, uint offset); + + /// Copy SSBO data between buffers + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void rlCopyShaderBuffer(uint destId, uint srcId, uint destOffset, uint srcOffset, uint count); /// Get SSBO buffer size [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern ulong rlGetShaderBufferSize(uint id, void* dest, ulong count, ulong offset); - - /// Bind SSBO buffer - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void rlReadShaderBufferElements(uint id, void* dest, ulong count, ulong offset); - - /// Copy SSBO buffer data - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void rlBindShaderBuffer(uint id, uint index); + public static extern uint rlGetShaderBufferSize(uint id); // Buffer management - /// Copy SSBO buffer data - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void rlCopyBuffersElements(uint destId, uint srcId, ulong destOffset, ulong srcOffset, ulong count); - /// Bind image texture [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void rlBindImageTexture(uint id, uint index, uint format, int readOnly); + public static extern void rlBindImageTexture(uint id, uint index, int format, CBool readOnly); // Matrix state management diff --git a/Raylib-cs/types/Core.cs b/Raylib-cs/types/Core.cs index 40042c2..9bff4ab 100644 --- a/Raylib-cs/types/Core.cs +++ b/Raylib-cs/types/Core.cs @@ -169,8 +169,13 @@ namespace Raylib_cs BLEND_ALPHA_PREMULTIPLY, /// - /// Blend textures using custom src/dst factors (use rlSetBlendMode()) + /// Blend textures using custom src/dst factors (use rlSetBlendFactors()) /// - BLEND_CUSTOM + BLEND_CUSTOM, + + /// + /// Blend textures using custom src/dst factors (use rlSetBlendFactorsSeparate()) + /// + BLEND_CUSTOM_SEPARATE } } diff --git a/Raylib-cs/types/Input.cs b/Raylib-cs/types/Input.cs index 4bf82d5..3b0f654 100644 --- a/Raylib-cs/types/Input.cs +++ b/Raylib-cs/types/Input.cs @@ -229,7 +229,7 @@ namespace Raylib_cs MOUSE_CURSOR_RESIZE_NESW = 8, /// - /// The omni-directional resize/move cursor shape + /// The omnidirectional resize/move cursor shape /// MOUSE_CURSOR_RESIZE_ALL = 9, diff --git a/Raylib-cs/types/Ray.cs b/Raylib-cs/types/Ray.cs index 93007c7..0641fff 100644 --- a/Raylib-cs/types/Ray.cs +++ b/Raylib-cs/types/Ray.cs @@ -38,12 +38,12 @@ namespace Raylib_cs public CBool hit; /// - /// Distance to nearest hit + /// Distance to the nearest hit /// public float distance; /// - /// Position of nearest hit + /// Point of the nearest hit /// public Vector3 point; diff --git a/Raylib-cs/types/Raylib.Utils.cs b/Raylib-cs/types/Raylib.Utils.cs index 9cc9a14..897c97e 100644 --- a/Raylib-cs/types/Raylib.Utils.cs +++ b/Raylib-cs/types/Raylib.Utils.cs @@ -209,11 +209,11 @@ namespace Raylib_cs } /// Update camera position for selected mode - public static void UpdateCamera(ref Camera3D camera) + public static void UpdateCamera(ref Camera3D camera, CameraMode mode) { fixed (Camera3D* c = &camera) { - UpdateCamera(c); + UpdateCamera(c, mode); } } @@ -706,18 +706,6 @@ namespace Raylib_cs } } - /// Draw a textured polygon - public static void DrawTexturePoly(Texture2D texture, Vector2 center, Vector2[] points, Vector2[] texcoords, int pointsCount, Color tint) - { - fixed (Vector2* p = points) - { - fixed (Vector2* p1 = texcoords) - { - DrawTexturePoly(texture, center, p, p1, pointsCount, tint); - } - } - } - /// Draw text (using default font) public static void DrawText(string text, int posX, int posY, int fontSize, Color color) { @@ -802,7 +790,7 @@ namespace Raylib_cs using var str1 = text.ToUTF8Buffer(); fixed (int* p = &bytesProcessed) { - return GetCodepoint(str1.AsPointer(), p); + return GetCodepointNext(str1.AsPointer(), p); } } @@ -821,7 +809,7 @@ namespace Raylib_cs { fixed (int* c1 = codepoints) { - var ptr = TextCodepointsToUTF8(c1, length); + var ptr = LoadUTF8(c1, length); var text = Utf8StringUtils.GetUTF8String(ptr); MemFree(ptr); return text; diff --git a/Raylib-cs/types/Texture2D.cs b/Raylib-cs/types/Texture2D.cs index 313ea43..93115e2 100644 --- a/Raylib-cs/types/Texture2D.cs +++ b/Raylib-cs/types/Texture2D.cs @@ -82,7 +82,7 @@ namespace Raylib_cs CUBEMAP_LAYOUT_LINE_VERTICAL, /// - /// Layout is defined by an horizontal line with faces + /// Layout is defined by a horizontal line with faces /// CUBEMAP_LAYOUT_LINE_HORIZONTAL,