From 26cd2c6337103dfaa8587ecc32de05d68cef921b Mon Sep 17 00:00:00 2001
From: ChrisDill <chris.rj.dill@gmail.com>
Date: Thu, 25 Oct 2018 18:20:13 +0100
Subject: [PATCH] Fixing more examples

- Changed a few parts to use IntPtr for now.
---
 Bindings/Raylib.cs                            | 15 +++++++-------
 Examples/audio/audio_raw_stream.cs            |  3 +--
 Examples/core/core_vr_simulator.cs            |  1 +
 Examples/text/text_font_sdf.cs                | 20 +++++++++----------
 Examples/text/text_input_box.cs               |  2 +-
 .../textures/textures_image_processing.cs     |  6 +++---
 6 files changed, 22 insertions(+), 25 deletions(-)

diff --git a/Bindings/Raylib.cs b/Bindings/Raylib.cs
index 2a53f16..c3d76b3 100644
--- a/Bindings/Raylib.cs
+++ b/Bindings/Raylib.cs
@@ -695,7 +695,7 @@ namespace Raylib
         public int format;
 
         public uint source;
-        public uint[] buffers = new uint[2];
+        public IntPtr buffers;
     }
 
     // Head-Mounted-Display device parameters
@@ -709,10 +709,9 @@ namespace Raylib
         public float vScreenCenter;
         public float eyeToScreenDistance;
         public float lensSeparationDistance;
-
         public float interpupillaryDistance;
-        public float[] lensDistortionValues = new float[4];
-        public float[] chromaAbCorrection = new float[4];
+        public IntPtr lensDistortionValues;
+        public IntPtr chromaAbCorrection;
     }
 
     #endregion
@@ -1582,7 +1581,7 @@ namespace Raylib
 
         // Get pixel data from image as a Color struct array
         [DllImport(nativeLibName,CallingConvention = CallingConvention.Cdecl)]
-        public static extern Color[] GetImageData(Image image);
+        public static extern IntPtr GetImageData(Image image);
 
         // Get pixel data from image as Vector4 array (float normalized)
         [DllImport(nativeLibName,CallingConvention = CallingConvention.Cdecl)]
@@ -1598,7 +1597,7 @@ namespace Raylib
 
         // Update GPU texture with new data
         [DllImport(nativeLibName,CallingConvention = CallingConvention.Cdecl)]
-        public static extern void UpdateTexture(Texture2D texture, Color[] pixels);
+        public static extern void UpdateTexture(Texture2D texture, IntPtr pixels);
 
         // Image manipulation functions
         // Create an image duplicate (useful for transformations)
@@ -1803,11 +1802,11 @@ namespace Raylib
 
         // Load font data for further use
         [DllImport(nativeLibName,CallingConvention = CallingConvention.Cdecl)]
-        public static extern CharInfo[] LoadFontData(string fileName, int fontSize, int[] fontChars, int charsCount, bool sdf);
+        public static extern IntPtr LoadFontData(string fileName, int fontSize, int[] fontChars, int charsCount, bool sdf);
 
         // Generate image font atlas using chars info
         [DllImport(nativeLibName,CallingConvention = CallingConvention.Cdecl)]
-        public static extern Image GenImageFontAtlas(CharInfo[] chars, int fontSize, int charsCount, int padding, int packMethod);
+        public static extern Image GenImageFontAtlas(IntPtr chars, int fontSize, int charsCount, int padding, int packMethod);
 
         // Unload Font from GPU memory (VRAM)
         [DllImport(nativeLibName,CallingConvention = CallingConvention.Cdecl)]
diff --git a/Examples/audio/audio_raw_stream.cs b/Examples/audio/audio_raw_stream.cs
index 1fc662c..b61493a 100644
--- a/Examples/audio/audio_raw_stream.cs
+++ b/Examples/audio/audio_raw_stream.cs
@@ -17,7 +17,7 @@ public partial class audio_raw_stream
     *
     ********************************************************************************************/
 
-
+ 
 
     public const int MAX_SAMPLES = 22050;
     public const int MAX_SAMPLES_PER_UPDATE = 4096;
@@ -105,7 +105,6 @@ public partial class audio_raw_stream
 
         // De-Initialization
         //--------------------------------------------------------------------------------------
-        // free(data);                 // Unload sine wave data
 
         CloseAudioStream(stream);   // Close raw audio stream and delete buffers from RAM
 
diff --git a/Examples/core/core_vr_simulator.cs b/Examples/core/core_vr_simulator.cs
index 63a58b7..a5dddd2 100644
--- a/Examples/core/core_vr_simulator.cs
+++ b/Examples/core/core_vr_simulator.cs
@@ -31,6 +31,7 @@ public partial class core_vr_simulator
 
         // Init VR simulator (Oculus Rift CV1 parameters)
         // fails?
+        var a = GetVrDeviceInfo((int)HMD_OCULUS_RIFT_CV1);
         InitVrSimulator(GetVrDeviceInfo((int)HMD_OCULUS_RIFT_CV1));
 
         // Define the camera to look into our 3d world
diff --git a/Examples/text/text_font_sdf.cs b/Examples/text/text_font_sdf.cs
index ad175a8..02b4b3b 100644
--- a/Examples/text/text_font_sdf.cs
+++ b/Examples/text/text_font_sdf.cs
@@ -35,11 +35,11 @@ public partial class text_font_sdf
         fontDefault.charsCount = 95;
         // Parameters > font size: 16, no chars array provided (0), chars count: 95 (autogenerate chars array)
         // TODO: fix conversion
-        //fontDefault.chars = LoadFontData("resources/AnonymousPro-Bold.ttf", 16, null, 95, false);
+        fontDefault.chars = LoadFontData("resources/AnonymousPro-Bold.ttf", 16, null, 95, false);
         // Parameters > chars count: 95, font size: 16, chars padding in image: 4 px, pack method: 0 (default)
-        //Image atlas = GenImageFontAtlas(fontDefault.chars, 95, 16, 4, 0);
-        //fontDefault.texture = LoadTextureFromImage(atlas);
-        //UnloadImage(atlas);
+        Image atlas = GenImageFontAtlas(fontDefault.chars, 95, 16, 4, 0);
+        fontDefault.texture = LoadTextureFromImage(atlas);
+        UnloadImage(atlas);
 
         // SDF font generation from TTF font
         // NOTE: SDF chars data is generated with LoadFontData(), it's just a bool option
@@ -47,13 +47,11 @@ public partial class text_font_sdf
         fontSDF.baseSize = 16;
         fontSDF.charsCount = 95;
         // Parameters > font size: 16, no chars array provided (0), chars count: 0 (defaults to 95)
-        // TODO: fix conversion
-        //fontSDF.chars = LoadFontData("resources/AnonymousPro-Bold.ttf", 16, null, 0, true);
-        // Parameters > chars count: 95, font size: 16, chars padding in image: 0 px, pack method: 1 (Skyline algorythm)
-        // TODO: fix conversion
-        //atlas = GenImageFontAtlas(fontSDF.chars, 95, 16, 0, 1);
-        //fontSDF.texture = LoadTextureFromImage(atlas);
-        //UnloadImage(atlas);
+        fontSDF.chars = LoadFontData("resources/AnonymousPro-Bold.ttf", 16, null, 0, true);
+        // Parameters > chars count: 95, font size: 16, chars padding in image: 0 px, pack method: 1 (Skyline algorythm)        
+        atlas = GenImageFontAtlas(fontSDF.chars, 95, 16, 0, 1);
+        fontSDF.texture = LoadTextureFromImage(atlas);
+        UnloadImage(atlas);
 
         // Load SDF required shader (we use default vertex shader)
         Shader shader = LoadShader(null, "resources/shaders/sdf.fs");
diff --git a/Examples/text/text_input_box.cs b/Examples/text/text_input_box.cs
index 8f44535..e78a1b2 100644
--- a/Examples/text/text_input_box.cs
+++ b/Examples/text/text_input_box.cs
@@ -27,7 +27,7 @@ public partial class text_input_box
 
         InitWindow(screenWidth, screenHeight, "raylib [text] example - input box");
 
-        StringBuilder name = new StringBuilder(' ', MAX_INPUT_CHARS + 1);      // NOTE: One extra space required for line ending char '\0'
+        StringBuilder name = new StringBuilder(" ", MAX_INPUT_CHARS + 1);      // NOTE: One extra space required for line ending char '\0'
         int letterCount = 0;
 
         Rectangle textBox = new Rectangle( screenWidth/2 - 100, 180, 225, 50 );
diff --git a/Examples/textures/textures_image_processing.cs b/Examples/textures/textures_image_processing.cs
index 893ffde..5519ead 100644
--- a/Examples/textures/textures_image_processing.cs
+++ b/Examples/textures/textures_image_processing.cs
@@ -17,8 +17,8 @@ public partial class textures_image_processing
     *
     ********************************************************************************************/
 
-
-
+    
+    
     public const int NUM_PROCESSES = 8;
 
     enum ImageProcess
@@ -107,7 +107,7 @@ public partial class textures_image_processing
                     default: break;
                 }
 
-                Color[] pixels = GetImageData(image);        // Get pixel data from image (RGBA 32bit)
+                var pixels = GetImageData(image);        // Get pixel data from image (RGBA 32bit)
                 UpdateTexture(texture, pixels);             // Update texture with new image data
                 // free(pixels);                               // Unload pixels data from RAM