using System; using System.Numerics; using System.Runtime.InteropServices; namespace Raylib_cs { public static unsafe partial class Raylib { /// Initialize window and OpenGL context public static void InitWindow(int width, int height, string title) { using var str1 = title.ToUTF8Buffer(); InitWindow(width, height, str1.AsPointer()); } /// Set title for window (only PLATFORM_DESKTOP) public static void SetWindowTitle(string title) { using var str1 = title.ToUTF8Buffer(); SetWindowTitle(str1.AsPointer()); } /// Get the human-readable, UTF-8 encoded name of the specified monitor public static string GetMonitorName_(int monitor) { return Utf8StringUtils.GetUTF8String(GetMonitorName(monitor)); } /// Get clipboard text content public static string GetClipboardText_() { return Utf8StringUtils.GetUTF8String(GetClipboardText()); } /// Set clipboard text content public static void SetClipboardText(string text) { using var str1 = text.ToUTF8Buffer(); SetClipboardText(str1.AsPointer()); } /// Load shader from files and bind default locations public static Shader LoadShader(string vsFileName, string fsFileName) { using var str1 = vsFileName.ToUTF8Buffer(); using var str2 = fsFileName.ToUTF8Buffer(); return LoadShader(str1.AsPointer(), str2.AsPointer()); } /// Load shader from code string and bind default locations public static Shader LoadShaderFromMemory(string vsCode, string fsCode) { using var str1 = vsCode.ToUTF8Buffer(); using var str2 = fsCode.ToUTF8Buffer(); return LoadShaderFromMemory(str1.AsPointer(), str2.AsPointer()); } /// Get shader uniform location public static int GetShaderLocation(Shader shader, string uniformName) { using var str1 = uniformName.ToUTF8Buffer(); return GetShaderLocation(shader, str1.AsPointer()); } /// Get shader attribute location public static int GetShaderLocationAttrib(Shader shader, string attribName) { using var str1 = attribName.ToUTF8Buffer(); return GetShaderLocationAttrib(shader, str1.AsPointer()); } /// Takes a screenshot of current screen (saved a .png) public static void TakeScreenshot(string fileName) { using var str1 = fileName.ToUTF8Buffer(); TakeScreenshot(str1.AsPointer()); } /// Check file extension public static CBool IsFileExtension(string fileName, string ext) { using var str1 = fileName.ToUTF8Buffer(); using var str2 = ext.ToUTF8Buffer(); return IsFileExtension(str1.AsPointer(), str2.AsPointer()); } /// Get file modification time (last write time) public static long GetFileModTime(string fileName) { using var str1 = fileName.ToUTF8Buffer(); return GetFileModTime(str1.AsPointer()); } /// Load image from file into CPU memory (RAM) public static Image LoadImage(string fileName) { using var str1 = fileName.ToUTF8Buffer(); return LoadImage(str1.AsPointer()); } /// Load image from RAW file data public static Image LoadImageRaw(string fileName, int width, int height, PixelFormat format, int headerSize) { using var str1 = fileName.ToUTF8Buffer(); return LoadImageRaw(str1.AsPointer(), width, height, format, headerSize); } /// Load image sequence from file (frames appended to image.data) public static Image LoadImageAnim(string fileName, out int frames) { using var str1 = fileName.ToUTF8Buffer(); fixed (int* p = &frames) { return LoadImageAnim(str1.AsPointer(), p); } } /// /// Load image from a native copy of managed memory, fileType refers to extension: i.e. "png" /// public static Image LoadImageFromMemory(string fileType, byte[] fileData) { using var fileTypeNative = fileType.ToUTF8Buffer(); byte* fileDataNative = (byte*)MemAlloc(fileData.Length); Marshal.Copy(fileData, 0, (IntPtr)fileDataNative, fileData.Length); Image image = LoadImageFromMemory(fileTypeNative.AsPointer(), fileDataNative, fileData.Length); return image; } /// Export image data to file public static CBool ExportImage(Image image, string fileName) { using var str1 = fileName.ToUTF8Buffer(); return ExportImage(image, str1.AsPointer()); } /// Export image as code file defining an array of bytes public static CBool ExportImageAsCode(Image image, string fileName) { using var str1 = fileName.ToUTF8Buffer(); return ExportImageAsCode(image, str1.AsPointer()); } /// Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR) public static void TraceLog(TraceLogLevel logLevel, string text) { using var str1 = text.ToUTF8Buffer(); TraceLog(logLevel, str1.AsPointer()); } /// Set shader uniform value vector public static void SetShaderValueV( Shader shader, int locIndex, T[] values, ShaderUniformDataType uniformType, int count ) where T : unmanaged { SetShaderValueV(shader, locIndex, (Span)values, uniformType, count); } /// Set shader uniform value vector public static void SetShaderValueV( Shader shader, int locIndex, Span values, ShaderUniformDataType uniformType, int count ) where T : unmanaged { fixed (T* valuePtr = values) { SetShaderValueV(shader, locIndex, valuePtr, uniformType, count); } } /// Set shader uniform value public static void SetShaderValue(Shader shader, int locIndex, T value, ShaderUniformDataType uniformType) where T : unmanaged { SetShaderValue(shader, locIndex, &value, uniformType); } /// Set shader uniform value public static void SetShaderValue( Shader shader, int locIndex, T[] values, ShaderUniformDataType uniformType ) where T : unmanaged { SetShaderValue(shader, locIndex, (Span)values, uniformType); } /// Set shader uniform value public static void SetShaderValue( Shader shader, int locIndex, Span values, ShaderUniformDataType uniformType ) where T : unmanaged { fixed (T* valuePtr = values) { SetShaderValue(shader, locIndex, valuePtr, uniformType); } } /// Load file data as byte array (read) public static byte* LoadFileData(string fileName, ref uint bytesRead) { using var str1 = fileName.ToUTF8Buffer(); fixed (uint* p = &bytesRead) { return LoadFileData(str1.AsPointer(), p); } } /// Get dropped files names (memory should be freed) public static string[] GetDroppedFiles() { var filePathList = LoadDroppedFiles(); var files = new string[filePathList.count]; for (var i = 0; i < filePathList.count; i++) { files[i] = Marshal.PtrToStringUTF8((IntPtr)filePathList.paths[i]); } UnloadDroppedFiles(filePathList); return files; } /// Get gamepad internal name id public static string GetGamepadName_(int gamepad) { return Utf8StringUtils.GetUTF8String(GetGamepadName(gamepad)); } /// Update camera position for selected mode public static void UpdateCamera(ref Camera3D camera, CameraMode mode) { fixed (Camera3D* c = &camera) { UpdateCamera(c, mode); } } /// Update camera movement/rotation public static void UpdateCameraPro(ref Camera3D camera, Vector3 movement, Vector3 rotation, float zoom) { fixed (Camera3D* c = &camera) { UpdateCameraPro(c, movement, rotation, zoom); } } /// /// Check the collision between two lines defined by two points each, returns collision point by reference /// public static CBool CheckCollisionLines( Vector2 startPos1, Vector2 endPos1, Vector2 startPos2, Vector2 endPos2, ref Vector2 collisionPoint ) { fixed (Vector2* p = &collisionPoint) { return CheckCollisionLines(startPos1, endPos1, startPos2, endPos2, p); } } /// Create an image from text (default font) public static Image ImageText(string text, int fontSize, Color color) { using var str1 = text.ToUTF8Buffer(); return ImageText(str1.AsPointer(), fontSize, color); } /// Create an image from text (custom sprite font) public static Image ImageTextEx(Font font, string text, float fontSize, float spacing, Color tint) { using var str1 = text.ToUTF8Buffer(); return ImageTextEx(font, str1.AsPointer(), fontSize, spacing, tint); } /// Convert image to POT (power-of-two) public static void ImageToPOT(ref Image image, Color fill) { fixed (Image* p = &image) { ImageToPOT(p, fill); } } /// Convert image data to desired format public static void ImageFormat(ref Image image, PixelFormat newFormat) { fixed (Image* p = &image) { ImageFormat(p, newFormat); } } /// Apply alpha mask to image public static void ImageAlphaMask(ref Image image, Image alphaMask) { fixed (Image* p = &image) { ImageAlphaMask(p, alphaMask); } } /// Clear alpha channel to desired color public static void ImageAlphaClear(ref Image image, Color color, float threshold) { fixed (Image* p = &image) { ImageAlphaClear(p, color, threshold); } } /// Crop image depending on alpha value public static void ImageAlphaCrop(ref Image image, float threshold) { fixed (Image* p = &image) { ImageAlphaCrop(p, threshold); } } /// Premultiply alpha channel public static void ImageAlphaPremultiply(ref Image image) { fixed (Image* p = &image) { ImageAlphaPremultiply(p); } } /// Apply Gaussian blur using a box blur approximation public static void ImageBlurGaussian(ref Image image, int blurSize) { fixed (Image* p = &image) { ImageBlurGaussian(p, blurSize); } } /// Crop an image to a defined rectangle public static void ImageCrop(ref Image image, Rectangle crop) { fixed (Image* p = &image) { ImageCrop(p, crop); } } /// Resize image (Bicubic scaling algorithm) public static void ImageResize(ref Image image, int newWidth, int newHeight) { fixed (Image* p = &image) { ImageResize(p, newWidth, newHeight); } } /// Resize image (Nearest-Neighbor scaling algorithm) public static void ImageResizeNN(ref Image image, int newWidth, int newHeight) { fixed (Image* p = &image) { ImageResizeNN(p, newWidth, newHeight); } } /// Resize canvas and fill with color public static void ImageResizeCanvas( ref Image image, int newWidth, int newHeight, int offsetX, int offsetY, Color color ) { fixed (Image* p = &image) { ImageResizeCanvas(p, newWidth, newHeight, offsetX, offsetY, color); } } /// Generate all mipmap levels for a provided image public static void ImageMipmaps(ref Image image) { fixed (Image* p = &image) { ImageMipmaps(p); } } /// Dither image data to 16bpp or lower (Floyd-Steinberg dithering) public static void ImageDither(ref Image image, int rBpp, int gBpp, int bBpp, int aBpp) { fixed (Image* p = &image) { ImageDither(p, rBpp, gBpp, bBpp, aBpp); } } /// Flip image vertically public static void ImageFlipVertical(ref Image image) { fixed (Image* p = &image) { ImageFlipVertical(p); } } /// Flip image horizontally public static void ImageFlipHorizontal(ref Image image) { fixed (Image* p = &image) { ImageFlipHorizontal(p); } } /// Rotate image clockwise 90deg public static void ImageRotateCW(ref Image image) { fixed (Image* p = &image) { ImageRotateCW(p); } } /// Rotate image counter-clockwise 90deg public static void ImageRotateCCW(ref Image image) { fixed (Image* p = &image) { ImageRotateCCW(p); } } /// Modify image color: tint public static void ImageColorTint(ref Image image, Color color) { fixed (Image* p = &image) { ImageColorTint(p, color); } } /// Modify image color: invert public static void ImageColorInvert(ref Image image) { fixed (Image* p = &image) { ImageColorInvert(p); } } /// Modify image color: grayscale public static void ImageColorGrayscale(ref Image image) { fixed (Image* p = &image) { ImageColorGrayscale(p); } } /// Modify image color: contrast (-100 to 100) public static void ImageColorContrast(ref Image image, float contrast) { fixed (Image* p = &image) { ImageColorContrast(p, contrast); } } /// Modify image color: brightness (-255 to 255) public static void ImageColorBrightness(ref Image image, int brightness) { fixed (Image* p = &image) { ImageColorBrightness(p, brightness); } } /// Modify image color: replace color public static void ImageColorReplace(ref Image image, Color color, Color replace) { fixed (Image* p = &image) { ImageColorReplace(p, color, replace); } } /// Clear image background with given color public static void ImageClearBackground(ref Image dst, Color color) { fixed (Image* p = &dst) { ImageClearBackground(p, color); } } /// Draw pixel within an image public static void ImageDrawPixel(ref Image dst, int posX, int posY, Color color) { fixed (Image* p = &dst) { ImageDrawPixel(p, posX, posY, color); } } /// Draw pixel within an image (Vector version) public static void ImageDrawPixelV(ref Image dst, Vector2 position, Color color) { fixed (Image* p = &dst) { ImageDrawPixelV(p, position, color); } } /// Draw line within an image public static void ImageDrawLine( ref Image dst, int startPosX, int startPosY, int endPosX, int endPosY, Color color ) { fixed (Image* p = &dst) { ImageDrawLine(p, startPosX, startPosY, endPosX, endPosY, color); } } /// Draw line within an image (Vector version) public static void ImageDrawLineV(ref Image dst, Vector2 start, Vector2 end, Color color) { fixed (Image* p = &dst) { ImageDrawLineV(p, start, end, color); } } /// Draw circle within an image public static void ImageDrawCircle(ref Image dst, int centerX, int centerY, int radius, Color color) { fixed (Image* p = &dst) { ImageDrawCircle(p, centerX, centerY, radius, color); } } /// Draw circle within an image (Vector version) public static void ImageDrawCircleV(ref Image dst, Vector2 center, int radius, Color color) { fixed (Image* p = &dst) { ImageDrawCircleV(p, center, radius, color); } } /// Draw rectangle within an image public static void ImageDrawRectangle(ref Image dst, int posX, int posY, int width, int height, Color color) { fixed (Image* p = &dst) { ImageDrawRectangle(p, posX, posY, width, height, color); } } /// Draw rectangle within an image (Vector version) public static void ImageDrawRectangleV(ref Image dst, Vector2 position, Vector2 size, Color color) { fixed (Image* p = &dst) { ImageDrawRectangleV(p, position, size, color); } } /// Draw rectangle within an image public static void ImageDrawRectangleRec(ref Image dst, Rectangle rec, Color color) { fixed (Image* p = &dst) { ImageDrawRectangleRec(p, rec, color); } } /// Draw rectangle lines within an image public static void ImageDrawRectangleLines(ref Image dst, Rectangle rec, int thick, Color color) { fixed (Image* p = &dst) { ImageDrawRectangleLines(p, rec, thick, color); } } /// Draw a source image within a destination image (tint applied to source) public static void ImageDraw(ref Image dst, Image src, Rectangle srcRec, Rectangle dstRec, Color tint) { fixed (Image* p = &dst) { ImageDraw(p, src, srcRec, dstRec, tint); } } /// Draw text (using default font) within an image (destination) public static void ImageDrawText(ref Image dst, string text, int x, int y, int fontSize, Color color) { using var str1 = text.ToUTF8Buffer(); fixed (Image* p = &dst) { ImageDrawText(p, str1.AsPointer(), x, y, fontSize, color); } } /// Draw text (custom sprite font) within an image (destination) public static void ImageDrawTextEx( ref Image dst, Font font, string text, Vector2 position, int fontSize, float spacing, Color color ) { using var str1 = text.ToUTF8Buffer(); fixed (Image* p = &dst) { ImageDrawTextEx(p, font, str1.AsPointer(), position, fontSize, spacing, color); } } /// Load texture from file into GPU memory (VRAM) public static Texture2D LoadTexture(string fileName) { using var str1 = fileName.ToUTF8Buffer(); return LoadTexture(str1.AsPointer()); } /// Generate GPU mipmaps for a texture public static void GenTextureMipmaps(ref Texture2D texture) { fixed (Texture2D* p = &texture) { GenTextureMipmaps(p); } } /// Load font from file into GPU memory (VRAM) public static Font LoadFont(string fileName) { using var str1 = fileName.ToUTF8Buffer(); return LoadFont(str1.AsPointer()); } /// Load font from file with extended parameters public static Font LoadFontEx(string fileName, int fontSize, int[] fontChars, int glyphCount) { using var str1 = fileName.ToUTF8Buffer(); fixed (int* p = fontChars) { return LoadFontEx(str1.AsPointer(), fontSize, p, glyphCount); } } /// /// Load font from a native copy of managed memory, fileType refers to extension: i.e. "ttf" /// public static Font LoadFontFromMemory( string fileType, byte[] fileData, int fontSize, int[] fontChars, int glyphCount ) { using var fileTypeNative = fileType.ToUTF8Buffer(); byte* fileDataNative = (byte*)MemAlloc(fileData.Length); Marshal.Copy(fileData, 0, (IntPtr)fileDataNative, fileData.Length); fixed (int* fontCharsNative = fontChars) { Font font = LoadFontFromMemory( fileTypeNative.AsPointer(), fileDataNative, fileData.Length, fontSize, fontCharsNative, glyphCount ); return font; } } /// Upload vertex data into GPU and provided VAO/VBO ids public static void UploadMesh(ref Mesh mesh, CBool dynamic) { fixed (Mesh* p = &mesh) { UploadMesh(p, dynamic); } } /// Unload mesh from memory (RAM and/or VRAM) public static void UnloadMesh(ref Mesh mesh) { fixed (Mesh* p = &mesh) { UnloadMesh(p); } } /// Set texture for a material map type (MAP_DIFFUSE, MAP_SPECULAR...) public static void SetMaterialTexture(ref Material material, MaterialMapIndex mapType, Texture2D texture) { fixed (Material* p = &material) { SetMaterialTexture(p, mapType, texture); } } /// Set material for a mesh public static void SetModelMeshMaterial(ref Model model, int meshId, int materialId) { fixed (Model* p = &model) { SetModelMeshMaterial(p, meshId, materialId); } } /// Load model animations from file public static ReadOnlySpan LoadModelAnimations(string fileName, ref uint animCount) { using var str1 = fileName.ToUTF8Buffer(); fixed (uint* p = &animCount) { ModelAnimation* modelAnimations = LoadModelAnimations(str1.AsPointer(), p); if ((IntPtr)modelAnimations == IntPtr.Zero) { throw new ApplicationException("Failed to load animation"); } return new ReadOnlySpan(modelAnimations, (int)animCount); } } /// Compute mesh tangents public static void GenMeshTangents(ref Mesh mesh) { fixed (Mesh* p = &mesh) { GenMeshTangents(p); } } /// Convert wave data to desired format public static void WaveFormat(ref Wave wave, int sampleRate, int sampleSize, int channels) { fixed (Wave* p = &wave) { WaveFormat(p, sampleRate, sampleSize, channels); } } /// Crop a wave to defined samples range public static void WaveCrop(ref Wave wave, int initSample, int finalSample) { fixed (Wave* p = &wave) { WaveCrop(p, initSample, finalSample); } } /// Draw lines sequence public static void DrawLineStrip(Vector2[] points, int pointCount, Color color) { fixed (Vector2* p = points) { DrawLineStrip(p, pointCount, color); } } /// Draw a triangle fan defined by points (first vertex is the center) public static void DrawTriangleFan(Vector2[] points, int pointCount, Color color) { fixed (Vector2* p = points) { DrawTriangleFan(p, pointCount, color); } } /// Draw a triangle strip defined by points public static void DrawTriangleStrip(Vector2[] points, int pointCount, Color color) { fixed (Vector2* p = points) { DrawTriangleStrip(p, pointCount, color); } } /// Draw text (using default font) public static void DrawText(string text, int posX, int posY, int fontSize, Color color) { using var str1 = text.ToUTF8Buffer(); DrawText(str1.AsPointer(), posX, posY, fontSize, color); } /// Draw text using font and additional parameters public static void DrawTextEx( Font font, string text, Vector2 position, float fontSize, float spacing, Color tint ) { using var str1 = text.ToUTF8Buffer(); DrawTextEx(font, str1.AsPointer(), position, fontSize, spacing, tint); } /// Draw text using Font and pro parameters (rotation) public static void DrawTextPro( Font font, string text, Vector2 position, Vector2 origin, float rotation, float fontSize, float spacing, Color tint ) { using var str1 = text.ToUTF8Buffer(); DrawTextPro(font, str1.AsPointer(), position, origin, rotation, fontSize, spacing, tint); } /// Measure string width for default font public static int MeasureText(string text, int fontSize) { using var str1 = text.ToUTF8Buffer(); return MeasureText(str1.AsPointer(), fontSize); } /// Measure string size for Font public static Vector2 MeasureTextEx(Font font, string text, float fontSize, float spacing) { using var str1 = text.ToUTF8Buffer(); return MeasureTextEx(font, str1.AsPointer(), fontSize, spacing); } /// Append text at specific position and move cursor! public static void TextAppend(string text, string append, int position) { using var str1 = text.ToUTF8Buffer(); using var str2 = append.ToUTF8Buffer(); TextAppend(str1.AsPointer(), str2.AsPointer(), &position); } /// Get Pascal case notation version of provided string public static string TextToPascal(string text) { using var str1 = text.ToUTF8Buffer(); return Utf8StringUtils.GetUTF8String(TextToPascal(str1.AsPointer())); } /// Get integer value from text (negative values not supported) public static int TextToInteger(string text) { using var str1 = text.ToUTF8Buffer(); return TextToInteger(str1.AsPointer()); } /// Get all codepoints in a string, codepoints count returned by parameters public static int[] LoadCodepoints(string text, ref int count) { using var str1 = text.ToUTF8Buffer(); fixed (int* c = &count) { var pointsPtr = LoadCodepoints(str1.AsPointer(), c); var codepoints = new ReadOnlySpan(pointsPtr, count).ToArray(); UnloadCodepoints(pointsPtr); return codepoints; } } /// Get total number of codepoints in a UTF8 encoded string public static int GetCodepointCount(string text) { using var str1 = text.ToUTF8Buffer(); return GetCodepointCount(str1.AsPointer()); } /// Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure public static int GetCodepoint(string text, ref int codepointSize) { using var str1 = text.ToUTF8Buffer(); fixed (int* p = &codepointSize) { return GetCodepoint(str1.AsPointer(), p); } } /// Encode one codepoint into UTF-8 byte array (array length returned as parameter) public static string CodepointToUTF8(int codepoint, ref int utf8Size) { fixed (int* l1 = &utf8Size) { var ptr = CodepointToUTF8(codepoint, l1); return Utf8StringUtils.GetUTF8String(ptr); } } /// Load UTF-8 text encoded from codepoints array public static string LoadUTF8(int[] codepoints, int length) { fixed (int* c1 = codepoints) { var ptr = LoadUTF8(c1, length); var text = Utf8StringUtils.GetUTF8String(ptr); MemFree(ptr); return text; } } /// Draw a model (with texture if set) public static Model LoadModel(string fileName) { using var str1 = fileName.ToUTF8Buffer(); return LoadModel(str1.AsPointer()); } /// Export mesh data to file, returns true on success public static CBool ExportMesh(Mesh mesh, string fileName) { using var str1 = fileName.ToUTF8Buffer(); return ExportMesh(mesh, str1.AsPointer()); } /// Draw a triangle strip defined by points public static void DrawTriangleStrip3D(Vector3[] points, int pointCount, Color color) { fixed (Vector3* p = points) { DrawTriangleStrip3D(p, pointCount, color); } } /// Draw multiple mesh instances with material and different transforms public static void DrawMeshInstanced(Mesh mesh, Material material, Matrix4x4[] transforms, int instances) { fixed (Matrix4x4* p = transforms) { DrawMeshInstanced(mesh, material, p, instances); } } /// Load wave data from file public static Wave LoadWave(string fileName) { using var str1 = fileName.ToUTF8Buffer(); return LoadWave(str1.AsPointer()); } /// /// Load wave from a native copy of managed memory, fileType refers to extension: i.e. "wav" /// public static Wave LoadWaveFromMemory( string fileType, byte[] fileData ) { using var fileTypeNative = fileType.ToUTF8Buffer(); byte* fileDataNative = (byte*)MemAlloc(fileData.Length); Marshal.Copy(fileData, 0, (IntPtr)fileDataNative, fileData.Length); Wave wave = LoadWaveFromMemory( fileTypeNative.AsPointer(), fileDataNative, fileData.Length ); return wave; } /// Load sound from file public static Sound LoadSound(string fileName) { using var str1 = fileName.ToUTF8Buffer(); return LoadSound(str1.AsPointer()); } /// Export wave data to file public static CBool ExportWave(Wave wave, string fileName) { using var str1 = fileName.ToUTF8Buffer(); return ExportWave(wave, str1.AsPointer()); } /// Export wave sample data to code (.h) public static CBool ExportWaveAsCode(Wave wave, string fileName) { using var str1 = fileName.ToUTF8Buffer(); return ExportWaveAsCode(wave, str1.AsPointer()); } /// Load music stream from file public static Music LoadMusicStream(string fileName) { using var str1 = fileName.ToUTF8Buffer(); return LoadMusicStream(str1.AsPointer()); } /// /// Load music stream from a native copy of managed memory, fileType refers to extension: i.e. ".wav" /// public static Music LoadMusicStreamFromMemory( string fileType, byte[] fileData ) { using var fileTypeNative = fileType.ToUTF8Buffer(); byte* fileDataNative = (byte*)MemAlloc(fileData.Length); Marshal.Copy(fileData, 0, (IntPtr)fileDataNative, fileData.Length); Music music = LoadMusicStreamFromMemory( fileTypeNative.AsPointer(), fileDataNative, fileData.Length ); return music; } public static string SubText(this string input, int position, int length) { return input.Substring(position, Math.Min(length, input.Length)); } public static Material GetMaterial(ref Model model, int materialIndex) { return model.materials[materialIndex]; } public static Texture2D GetMaterialTexture(ref Model model, int materialIndex, MaterialMapIndex mapIndex) { return model.materials[materialIndex].maps[(int)mapIndex].texture; } public static void SetMaterialTexture( ref Model model, int materialIndex, MaterialMapIndex mapIndex, ref Texture2D texture ) { SetMaterialTexture(&model.materials[materialIndex], mapIndex, texture); } public static void SetMaterialShader(ref Model model, int materialIndex, ref Shader shader) { model.materials[materialIndex].shader = shader; } } }