From ed9cead67273638fd594c1c8514d7a4245c87706 Mon Sep 17 00:00:00 2001 From: ChrisDill Date: Thu, 16 Dec 2021 20:13:50 +0000 Subject: [PATCH] Remove ref from raylib bindings --- Raylib-cs/Raylib.cs | 106 ++++++++++++++++++++++---------------------- Raylib-cs/Rlgl.cs | 2 +- 2 files changed, 54 insertions(+), 54 deletions(-) diff --git a/Raylib-cs/Raylib.cs b/Raylib-cs/Raylib.cs index 5e65cbb..f251328 100644 --- a/Raylib-cs/Raylib.cs +++ b/Raylib-cs/Raylib.cs @@ -34,14 +34,14 @@ namespace Raylib_cs /// /// refers to a unsigned char * [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate IntPtr LoadFileDataCallback(string fileName, ref int bytesRead); + public delegate IntPtr LoadFileDataCallback(string fileName, int* bytesRead); /// /// FileIO: Save binary data
/// WARNING: This callback is intended for advance users ///
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate CBool SaveFileDataCallback(string fileName, IntPtr data, ref int bytesToWrite); + public delegate CBool SaveFileDataCallback(string fileName, IntPtr data, int* bytesToWrite); /// /// FileIO: Load text data
@@ -511,7 +511,7 @@ namespace Raylib_cs /// Load file data as byte array (read) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern byte* LoadFileData(string fileName, ref int bytesRead); + public static extern byte* LoadFileData(string fileName, int* bytesRead); /// Unload file data allocated by LoadFileData() [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] @@ -543,11 +543,11 @@ namespace Raylib_cs /// Compress data (DEFLATE algorythm) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern byte* CompressData(byte[] data, int dataLength, ref int compDataLength); + public static extern byte* CompressData(byte[] data, int dataLength, int* compDataLength); /// Decompress data (DEFLATE algorythm) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern byte* DecompressData(byte[] compData, int compDataLength, ref int dataLength); + public static extern byte* DecompressData(byte[] compData, int compDataLength, int* dataLength); // Persistent storage management @@ -770,7 +770,7 @@ namespace Raylib_cs /// Update camera position for selected mode [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UpdateCamera(ref Camera3D camera); + public static extern void UpdateCamera(Camera3D* camera); /// Set camera pan key to combine with mouse movement (free camera) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] @@ -977,7 +977,7 @@ namespace Raylib_cs /// 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, ref Vector2 collisionPoint); + public static extern CBool CheckCollisionLines(Vector2 startPos1, Vector2 endPos1, Vector2 startPos2, Vector2 endPos2, Vector2* collisionPoint); /// Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] @@ -1005,7 +1005,7 @@ namespace Raylib_cs /// Load image sequence from file (frames appended to image.data) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Image LoadImageAnim(string fileName, ref int frames); + public static extern Image LoadImageAnim(string fileName, int* frames); /// Load image from memory buffer, fileType refers to extension: i.e. "png" [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] @@ -1098,91 +1098,91 @@ namespace Raylib_cs /// Convert image to POT (power-of-two) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageToPOT(ref Image image, Color fill); + 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(ref Image image, PixelFormat newFormat); + public static extern void ImageFormat(Image* image, PixelFormat newFormat); /// Apply alpha mask to image [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageAlphaMask(ref Image image, Image alphaMask); + public static extern void ImageAlphaMask(Image* image, Image alphaMask); /// Clear alpha channel to desired color [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageAlphaClear(ref Image image, Color color, float threshold); + public static extern void ImageAlphaClear(Image* image, Color color, float threshold); /// Crop image depending on alpha value [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageAlphaCrop(ref Image image, float threshold); + public static extern void ImageAlphaCrop(Image* image, float threshold); /// Premultiply alpha channel [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageAlphaPremultiply(ref Image image); + public static extern void ImageAlphaPremultiply(Image* image); /// Crop an image to a defined rectangle [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageCrop(ref Image image, Rectangle crop); + public static extern void ImageCrop(Image* image, Rectangle crop); /// Resize image (Bicubic scaling algorithm) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageResize(ref Image image, int newWidth, int newHeight); + public static extern void ImageResize(Image* image, int newWidth, int newHeight); /// Resize image (Nearest-Neighbor scaling algorithm) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageResizeNN(ref Image image, int newWidth, int newHeight); + public static extern void ImageResizeNN(Image* image, int newWidth, int newHeight); /// Resize canvas and fill with color [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageResizeCanvas(ref Image image, int newWidth, int newHeight, int offsetX, int offsetY, Color color); + public static extern void ImageResizeCanvas(Image* image, int newWidth, int newHeight, int offsetX, int offsetY, Color color); /// Generate all mipmap levels for a provided image [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageMipmaps(ref Image image); + public static extern void ImageMipmaps(Image* image); /// Dither image data to 16bpp or lower (Floyd-Steinberg dithering) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDither(ref Image image, int rBpp, int gBpp, int bBpp, int aBpp); + public static extern void ImageDither(Image* image, int rBpp, int gBpp, int bBpp, int aBpp); /// Flip image vertically [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageFlipVertical(ref Image image); + public static extern void ImageFlipVertical(Image* image); /// Flip image horizontally [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageFlipHorizontal(ref Image image); + public static extern void ImageFlipHorizontal(Image* image); /// Rotate image clockwise 90deg [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageRotateCW(ref Image image); + public static extern void ImageRotateCW(Image* image); /// Rotate image counter-clockwise 90deg [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageRotateCCW(ref Image image); + public static extern void ImageRotateCCW(Image* image); /// Modify image color: tint [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageColorTint(ref Image image, Color color); + public static extern void ImageColorTint(Image* image, Color color); /// Modify image color: invert [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageColorInvert(ref Image image); + public static extern void ImageColorInvert(Image* image); /// Modify image color: grayscale [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageColorGrayscale(ref Image image); + public static extern void ImageColorGrayscale(Image* image); /// Modify image color: contrast (-100 to 100) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageColorContrast(ref Image image, float contrast); + public static extern void ImageColorContrast(Image* image, float contrast); /// Modify image color: brightness (-255 to 255) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageColorBrightness(ref Image image, int brightness); + public static extern void ImageColorBrightness(Image* image, int brightness); /// Modify image color: replace color [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageColorReplace(ref Image image, Color color, Color replace); + public static extern void ImageColorReplace(Image* image, Color color, Color replace); /// Load color data from image as a Color array (RGBA - 32bit) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] @@ -1190,7 +1190,7 @@ namespace Raylib_cs /// Load colors palette from image as a Color array (RGBA - 32bit) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Color* LoadImagePalette(Image image, int maxPaletteSize, ref int colorsCount); + public static extern Color* LoadImagePalette(Image image, int maxPaletteSize, int* colorsCount); /// Unload color data loaded with LoadImageColors() [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] @@ -1214,51 +1214,51 @@ namespace Raylib_cs /// Clear image background with given color [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageClearBackground(ref Image dst, Color color); + public static extern void ImageClearBackground(Image* dst, Color color); /// Draw pixel within an image [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDrawPixel(ref Image dst, int posX, int posY, Color color); + public static extern void ImageDrawPixel(Image* dst, int posX, int posY, Color color); /// Draw pixel within an image (Vector version) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDrawPixelV(ref Image dst, Vector2 position, Color color); + public static extern void ImageDrawPixelV(Image* dst, Vector2 position, Color color); /// Draw line within an image [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDrawLine(ref Image dst, int startPosX, int startPosY, int endPosX, int endPosY, Color color); + public static extern void ImageDrawLine(Image* dst, int startPosX, int startPosY, int endPosX, int endPosY, Color color); /// Draw line within an image (Vector version) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDrawLineV(ref Image dst, Vector2 start, Vector2 end, Color color); + public static extern void ImageDrawLineV(Image* dst, Vector2 start, Vector2 end, Color color); /// Draw circle within an image [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDrawCircle(ref Image dst, int centerX, int centerY, int radius, Color color); + public static extern void ImageDrawCircle(Image* dst, int centerX, int centerY, int radius, Color color); /// Draw circle within an image (Vector version) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDrawCircleV(ref Image dst, Vector2 center, int radius, Color color); + public static extern void ImageDrawCircleV(Image* dst, Vector2 center, int radius, Color color); /// Draw rectangle within an image [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDrawRectangle(ref Image dst, int posX, int posY, int width, int height, Color color); + public static extern void ImageDrawRectangle(Image* dst, int posX, int posY, int width, int height, Color color); /// Draw rectangle within an image (Vector version) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDrawRectangleV(ref Image dst, Vector2 position, Vector2 size, Color color); + public static extern void ImageDrawRectangleV(Image* dst, Vector2 position, Vector2 size, Color color); /// Draw rectangle within an image [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDrawRectangleRec(ref Image dst, Rectangle rec, Color color); + public static extern void ImageDrawRectangleRec(Image* dst, Rectangle rec, Color color); /// Draw rectangle lines within an image [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDrawRectangleLines(ref Image dst, Rectangle rec, int thick, Color color); + public static extern void ImageDrawRectangleLines(Image* dst, Rectangle rec, int thick, Color color); /// Draw a source image within a destination image (tint applied to source) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void ImageDraw(ref Image dst, Image src, Rectangle srcRec, Rectangle dstRec, Color tint); + public static extern void ImageDraw(Image* dst, Image src, Rectangle srcRec, Rectangle dstRec, Color tint); /// Draw text (using default font) within an image (destination) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] @@ -1309,7 +1309,7 @@ namespace Raylib_cs /// Generate GPU mipmaps for a texture [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void GenTextureMipmaps(ref Texture2D texture); + public static extern void GenTextureMipmaps(Texture2D* texture); /// Set texture scaling filter mode [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] @@ -1666,7 +1666,7 @@ namespace Raylib_cs /// Upload vertex data into GPU and provided VAO/VBO ids [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UploadMesh(ref Mesh mesh, CBool dynamic); + public static extern void UploadMesh(Mesh* mesh, CBool dynamic); /// Update mesh vertex data in GPU for a specific buffer index [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] @@ -1674,7 +1674,7 @@ namespace Raylib_cs /// Unload mesh from memory (RAM and/or VRAM) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void UnloadMesh(ref Mesh mesh); + public static extern void UnloadMesh(Mesh* mesh); /// Draw a 3d mesh with material and transform [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] @@ -1694,11 +1694,11 @@ namespace Raylib_cs /// Compute mesh tangents [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void GenMeshTangents(ref Mesh mesh); + public static extern void GenMeshTangents(Mesh* mesh); /// Compute mesh binormals [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void GenMeshBinormals(ref Mesh mesh); + public static extern void GenMeshBinormals(Mesh* mesh); // Material loading/unloading functions @@ -1706,7 +1706,7 @@ namespace Raylib_cs //TODO: safe Helper method /// Load materials from model file [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern Material* LoadMaterials(string fileName, ref int materialCount); + public static extern Material* LoadMaterials(string fileName, int* materialCount); /// Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] @@ -1718,11 +1718,11 @@ namespace Raylib_cs /// Set texture for a material map type (MAP_DIFFUSE, MAP_SPECULAR...) [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetMaterialTexture(ref Material material, int mapType, Texture2D texture); + public static extern void SetMaterialTexture(Material* material, int mapType, Texture2D texture); /// Set material for a mesh [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SetModelMeshMaterial(ref Model model, int meshId, int materialId); + public static extern void SetModelMeshMaterial(Model* model, int meshId, int materialId); // Mesh generation functions @@ -1973,7 +1973,7 @@ namespace Raylib_cs /// Convert wave data to desired format [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void WaveFormat(ref Wave wave, int sampleRate, int sampleSize, int channels); + public static extern void WaveFormat(Wave* wave, int sampleRate, int sampleSize, int channels); /// Copy a wave to a new wave [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] @@ -1981,7 +1981,7 @@ namespace Raylib_cs /// Crop a wave to defined samples range [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void WaveCrop(ref Wave wave, int initSample, int finalSample); + public static extern void WaveCrop(Wave* wave, int initSample, int finalSample); //TODO: Span /// Get samples data from wave as a floats array diff --git a/Raylib-cs/Rlgl.cs b/Raylib-cs/Rlgl.cs index d333dfb..d32b0aa 100644 --- a/Raylib-cs/Rlgl.cs +++ b/Raylib-cs/Rlgl.cs @@ -101,7 +101,7 @@ namespace Raylib_cs [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void rlMultMatrixf(float* matf); - /// + /// public static void rlMultMatrixf(Matrix4x4 matf) { float16 f = Raymath.MatrixToFloatV(matf);