From fc0527a2effe720a019613cbee232624c89d41df Mon Sep 17 00:00:00 2001 From: ChrisDill Date: Sat, 20 Oct 2018 13:16:58 +0100 Subject: [PATCH] Review and cleanup - General cleanup. - Fixed missing functions from raymath. - Nuget info part of project file. --- .gitignore | 3 + Bindings/Bindings.csproj | 17 +- Bindings/Raylib.cs | 13 +- Bindings/Raymath.cs | 252 ++++++++++++++++++---------- Examples/core/core_basic_window.exe | Bin 4096 -> 0 bytes Examples/core/core_input_keys.exe | Bin 4608 -> 0 bytes Examples/core/core_input_mouse.exe | Bin 4608 -> 0 bytes Examples/core/core_mouse_wheel.exe | Bin 4608 -> 0 bytes Generator/Generator.cs | 15 +- Generator/Program.cs | 95 ++--------- Raylib-cs.nuspec | 21 --- Raylib-cs.sln | 28 ++-- Test/App.config | 6 +- Test/Program.cs | 8 +- Test/RayForms.cs | 102 ----------- Test/Test.csproj | 50 +++++- Test/packages.config | 7 + 17 files changed, 276 insertions(+), 341 deletions(-) delete mode 100644 Examples/core/core_basic_window.exe delete mode 100644 Examples/core/core_input_keys.exe delete mode 100644 Examples/core/core_input_mouse.exe delete mode 100644 Examples/core/core_mouse_wheel.exe delete mode 100644 Raylib-cs.nuspec delete mode 100644 Test/RayForms.cs create mode 100644 Test/packages.config diff --git a/.gitignore b/.gitignore index f8669e7..24a2560 100644 --- a/.gitignore +++ b/.gitignore @@ -16,11 +16,13 @@ *.user *.userosscache *.sln.docstates +*.exe # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs # Build results +[Bb]in/ [Dd]ebugPublic/ [Rr]elease/ [Rr]eleases/ @@ -29,6 +31,7 @@ bld/ [Dd]ebug [Oo]bj/ [Ll]og/ +[Ee]xamples/ # Visual Studio 2015 cache/options directory .vs/ diff --git a/Bindings/Bindings.csproj b/Bindings/Bindings.csproj index 2015e30..d3b612b 100644 --- a/Bindings/Bindings.csproj +++ b/Bindings/Bindings.csproj @@ -3,10 +3,25 @@ netstandard2.0 Bindings + true + Testing C# bindings for raylib, a simple and easy-to-use library to learn videogames programming. + https://github.com/ChrisDill/Raylib-cs/blob/master/LICENSE + https://github.com/ChrisDill/Raylib-cs/blob/master/Logo/raylib-cs.ico + Copyright 2018 + https://github.com/ChrisDill/Raylib-cs + Made for raylib 2.0 + raylib csharp binding opengl gamedev + https://github.com/ChrisDill/Raylib-cs true - + bin\Debug + false + + + + + diff --git a/Bindings/Raylib.cs b/Bindings/Raylib.cs index 34ff856..1389992 100644 --- a/Bindings/Raylib.cs +++ b/Bindings/Raylib.cs @@ -4,7 +4,6 @@ * Original - https://github.com/raysan5/raylib/blob/master/src/raylib.h * **********************************************************************************************/ - using System; using System.Runtime.InteropServices; @@ -431,9 +430,6 @@ namespace Raylib public Texture2D depth; } - // RenderTexture type, same as RenderTexture2D - // typedef RenderTexture2D RenderTexture; - // Font character info [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct CharInfo @@ -512,6 +508,7 @@ namespace Raylib public int vertexCount; public int triangleCount; + public Span Vertices => new Span(vertices.ToPointer(), vertexCount * 3); public IntPtr vertices; public IntPtr texcoords; public IntPtr texcoords2; @@ -553,9 +550,9 @@ namespace Raylib public Color color; public float value; } + public unsafe struct _MaterialMap_e_FixedBuffer { - public MaterialMap maps0; public MaterialMap maps1; public MaterialMap maps2; @@ -578,17 +575,13 @@ namespace Raylib } } } + // Material type (generic) [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct Material { - - - public Shader shader; - public _MaterialMap_e_FixedBuffer maps; - public IntPtr param; } diff --git a/Bindings/Raymath.cs b/Bindings/Raymath.cs index d453684..0f4a17d 100644 --- a/Bindings/Raymath.cs +++ b/Bindings/Raymath.cs @@ -24,7 +24,12 @@ namespace Raylib this.y = y; } - // extensions + public Vector2(float value) + { + this.x = value; + this.y = value; + } + public override bool Equals(object obj) { return (obj is Vector2) && Equals((Vector2)obj); @@ -39,36 +44,25 @@ namespace Raylib { return "Vector2(" + x + " " + y + ")"; } - - public static bool operator ==(Vector2 v1, Vector2 v2) + + public static Vector2 Zero { - return (v1.x == v2.x && v1.y == v2.y); + get { return Raylib.Vector2Zero(); } } - public static bool operator !=(Vector2 v1, Vector2 v2) + public static Vector2 One { - return !(v1 == v2); + get { return Raylib.Vector2One(); } } - public static bool operator >(Vector2 v1, Vector2 v2) + public static Vector2 UnitX { - return v1.x > v2.x && v1.y > v2.y; + get { return new Vector2(1, 0); } } - public static bool operator <(Vector2 v1, Vector2 v2) + public static Vector2 UnitY { - return v1.x < v2.x && v1.y < v2.y; - } - - // utility for c functions Vector2Zero() -> Vector2.Zero() etc - public static Vector2 Zero() - { - return Raylib.Vector2Zero(); - } - - public static Vector2 One() - { - return Raylib.Vector2One(); + get { return new Vector2(0, 1); } } public static float Length(Vector2 v) @@ -91,12 +85,12 @@ namespace Raylib return Raylib.Vector2Angle(v1, v2); } - public static Vector2 Scale(Vector2 v, float scale) + public static Vector2 Scale(Vector2 v, float scale) { return Raylib.Vector2Scale(v, scale); } - public static Vector2 Negate(Vector2 v) + public static Vector2 Negate(Vector2 v) { return Raylib.Vector2Negate(v); } @@ -105,30 +99,70 @@ namespace Raylib { return Raylib.Vector2Divide(v, div); } - + public static Vector2 Normalize(Vector2 v) - { + { return Raylib.Vector2Normalize(v); } - // operators - [DllImport(Raylib.nativeLibName, EntryPoint = "Vector2Add")] - public static extern Vector2 operator +(Vector2 v1, Vector2 v3); + #region Public Static Operators - [DllImport(Raylib.nativeLibName, EntryPoint = "Vector2Subtract")] - public static extern Vector2 operator -(Vector2 v1, Vector2 v3); + public static bool operator ==(Vector2 v1, Vector2 v2) + { + return (v1.x == v2.x && v1.y == v2.y); + } - [DllImport(Raylib.nativeLibName, EntryPoint = "Vector2MultiplyV")] - public static extern Vector2 operator *(Vector2 v1, Vector2 v3); + public static bool operator !=(Vector2 v1, Vector2 v2) + { + return !(v1 == v2); + } - [DllImport(Raylib.nativeLibName, EntryPoint = "Vector2Scale")] - public static extern Vector2 operator *(Vector2 v1, float scale); + public static bool operator >(Vector2 v1, Vector2 v2) + { + return v1.x > v2.x && v1.y > v2.y; + } - [DllImport(Raylib.nativeLibName, EntryPoint = "Vector2Divide")] - public static extern Vector2 operator /(Vector2 v1, Vector2 v3); + public static bool operator <(Vector2 v1, Vector2 v2) + { + return v1.x < v2.x && v1.y < v2.y; + } - [DllImport(Raylib.nativeLibName, EntryPoint = "Vector2Negate")] - public static extern Vector2 operator -(Vector2 v1); + public static Vector2 operator +(Vector2 v1, Vector2 v2) + { + return Raylib.Vector2Add(v1, v2); + } + + public static Vector2 operator -(Vector2 v1, Vector2 v2) + { + return Raylib.Vector2Subtract(v1, v2); + } + + public static Vector2 operator *(Vector2 v1, Vector2 v2) + { + return Raylib.Vector2Multiplyv(v1, v2); + } + + public static Vector2 operator *(Vector2 v, float scale) + { + return Raylib.Vector2Scale(v, scale); + } + + public static Vector2 operator /(Vector2 v1, Vector2 v2) + { + return Raylib.Vector2DivideV(v1, v2); + } + + public static Vector2 operator /(Vector2 v1, float div) + { + return Raylib.Vector2Divide(v1, div); + } + + public static Vector2 operator -(Vector2 v1) + { + return Raylib.Vector2Negate(v1); + } + + #endregion } // Vector3 type @@ -145,6 +179,14 @@ namespace Raylib this.z = z; } + public Vector3(float value) + { + this.x = value; + this.y = value; + this.z = value; + } + + // extensions public override bool Equals(object obj) { return (obj is Vector3) && Equals((Vector3)obj); @@ -160,6 +202,33 @@ namespace Raylib return "Vector3(" + x + " " + y + " " + z + ")"; } + public static Vector3 Zero + { + get { return Raylib.Vector3Zero(); } + } + + public static Vector3 One + { + get { return Raylib.Vector3One(); } + } + + public static Vector3 UnitX + { + get { return new Vector3(1, 0, 0); } + } + + public static Vector3 UnitY + { + get { return new Vector3(0, 1, 0); } + } + + public static Vector3 UnitZ + { + get { return new Vector3(0, 0, 1); } + } + + #region Public Static Operators + public static bool operator ==(Vector3 v1, Vector3 v2) { return (v1.x == v2.x && v1.y == v2.y && v1.z == v2.z); @@ -170,65 +239,52 @@ namespace Raylib return !(v1 == v2); } - /*public bool operator >(Vector2 v1, Vector2 v2) + public static bool operator >(Vector3 v1, Vector3 v2) { - return v1.x > v2.x && v1.y > v2.y; + return v1.x > v2.x && v1.y > v2.y && v1.z > v2.z; } - public static bool operator <(Vector2 v1, Vector2 v2) + public static bool operator <(Vector3 v1, Vector3 v2) { - return v1.x < v2.x && v1.y < v2.y; - }*/ + return v1.x < v2.x && v1.y < v2.y && v1.z < v2.z; + } - // utility for c functions Vector3Zero -> Zero etc - [DllImport(Raylib.nativeLibName, EntryPoint = "Vector3Zero")] - public static extern Vector3 Zero(); + public static Vector3 operator +(Vector3 v1, Vector3 v2) + { + return Raylib.Vector3Add(v1, v2); + } - [DllImport(Raylib.nativeLibName, EntryPoint = "Vector3One")] - public static extern Vector3 One(); + public static Vector3 operator -(Vector3 v1, Vector3 v2) + { + return Raylib.Vector3Subtract(v1, v2); + } - [DllImport(Raylib.nativeLibName, EntryPoint = "Vector3Add")] - public static extern Vector3 operator +(Vector3 v1, Vector3 v3); + public static Vector3 operator *(Vector3 v1, Vector3 v2) + { + return Raylib.Vector3MultiplyV(v1, v2); + } - [DllImport(Raylib.nativeLibName, EntryPoint = "Vector3Subtract")] - public static extern Vector3 operator -(Vector3 v1, Vector3 v3); + public static Vector3 operator *(Vector3 v, float scale) + { + return Raylib.Vector3Scale(v, scale); + } - [DllImport(Raylib.nativeLibName, EntryPoint = "Vector3Length")] - public static extern float Length(Vector3 v); + public static Vector3 operator /(Vector3 v1, Vector3 v2) + { + return Raylib.Vector3DivideV(v1, v2); + } - [DllImport(Raylib.nativeLibName, EntryPoint = "Vector3DotProduct")] - public static extern float DotProduct(Vector3 v1, Vector3 v3); + public static Vector3 operator /(Vector3 v1, float div) + { + return Raylib.Vector3Divide(v1, div); + } - [DllImport(Raylib.nativeLibName, EntryPoint = "Vector3Distance")] - public static extern float Distance(Vector3 v1, Vector3 v3); + public static Vector3 operator -(Vector3 v1) + { + return Raylib.Vector3Negate(v1); + } - [DllImport(Raylib.nativeLibName, EntryPoint = "Vector3Angle")] - public static extern float Angle(Vector3 v1, Vector3 v3); - - [DllImport(Raylib.nativeLibName, EntryPoint = "Vector3Scale")] - public static extern Vector3 Scale(Vector3 v, float scale); - - [DllImport(Raylib.nativeLibName, EntryPoint = "Vector3Negate")] - public static extern Vector3 Negate(Vector3 v); - - [DllImport(Raylib.nativeLibName, EntryPoint = "Vector3Divide")] - public static extern Vector3 Divide(Vector3 v, float div); - - [DllImport(Raylib.nativeLibName, EntryPoint = "Vector3Normalize")] - public static extern Vector3 Normalize(Vector3 v); - - // operators - [DllImport(Raylib.nativeLibName, EntryPoint = "Vector3MultiplyV")] - public static extern Vector3 operator *(Vector3 v1, Vector3 v3); - - [DllImport(Raylib.nativeLibName, EntryPoint = "Vector3Multiply")] - public static extern Vector3 operator *(Vector3 v1, float scale); - - [DllImport(Raylib.nativeLibName, EntryPoint = "Vector3Divide")] - public static extern Vector3 operator /(Vector3 v1, Vector3 v3); - - [DllImport(Raylib.nativeLibName, EntryPoint = "Vector3Negate")] - public static extern Vector3 operator -(Vector3 v1); + #endregion } // Vector4 type @@ -247,6 +303,14 @@ namespace Raylib this.w = w; } + public Vector4(float value) + { + this.x = value; + this.y = value; + this.z = value; + this.w = value; + } + public override bool Equals(object obj) { return (obj is Vector4) && Equals((Vector4)obj); @@ -336,9 +400,13 @@ namespace Raylib public static extern float Vector2Angle(Vector2 v1, Vector2 v2); // Scale vector (multiply by value) - [DllImport(nativeLibName,CallingConvention = CallingConvention.Cdecl)] + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern Vector2 Vector2Scale(Vector2 v, float scale); + // Multiply vector by a vector + [DllImport(nativeLibName,CallingConvention = CallingConvention.Cdecl)] + public static extern Vector2 Vector2Multiplyv(Vector2 v1, Vector2 v2); + // Negate vector [DllImport(nativeLibName,CallingConvention = CallingConvention.Cdecl)] public static extern Vector2 Vector2Negate(Vector2 v); @@ -347,6 +415,10 @@ namespace Raylib [DllImport(nativeLibName,CallingConvention = CallingConvention.Cdecl)] public static extern Vector2 Vector2Divide(Vector2 v, float div); + // Divide vector by a vector + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector2 Vector2DivideV(Vector2 v1, Vector2 v2); + // Normalize provided vector [DllImport(nativeLibName,CallingConvention = CallingConvention.Cdecl)] public static extern Vector2 Vector2Normalize(Vector2 v); @@ -403,6 +475,14 @@ namespace Raylib [DllImport(nativeLibName,CallingConvention = CallingConvention.Cdecl)] public static extern Vector3 Vector3Negate(Vector3 v); + // Divide vector by a float value + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector3 Vector3Divide(Vector3 v, float div); + + // Divide vector by a vector + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Vector3 Vector3DivideV(Vector3 v1, Vector3 v2); + // Normalize provided vector [DllImport(nativeLibName,CallingConvention = CallingConvention.Cdecl)] public static extern Vector3 Vector3Normalize(Vector3 v); diff --git a/Examples/core/core_basic_window.exe b/Examples/core/core_basic_window.exe deleted file mode 100644 index 01bad608ae436e53952649ebe48d5f6dc8d0ce6b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4096 zcmeZ`n!v!!z`(%5z`*eTKLf)K1_*F~PW0fj3A#BEFrtPEEa7#LDm7#J8Cz!+p3LNO66VFOl%9Ee^) z1_cFX1_myLLyQaz+-&Scj0_9~8Y~P9Tx#+*8mtTqTnyT#3>s`8Mjbl?1D6H|h*{*# zz)+yD4-_mX7#JAjMd~;~a$F!e4Q>$0puxkyz$NyNk%vQfzXmTzNK1)HgAdGLU|?_x z_Htqb`v4LiWhQzCdd3FEhL#`?K-?F=$iSdn$H1_Mk%6HB#11Yg%FIhI2C1-NW?)#r zz`&p!8q9Eq8Juz$l-)x;T^JY`-Y_#TRDk51a`KZviXlPG=q|#lE7=%w8CV$E7<$2EB*RAreg+jrPzG>iyve}DV8CF&z{T*C z!2o0fR1e69j0^${#*7RMq6{Ej04RSjOatd1Murn$UYo>g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input_keys.exe deleted file mode 100644 index c313e17585731ef628771fac8c4f07cc22bafffd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4608 zcmeZ`n!v!!z`(%5z`*eTKLf)K1_*F~PEy`tixWCp0)Kz;|Q=Ypw#&<+d?4thnYIr+&@wm__~!3U}Rue0b&Q26lLb67lTwxU}j+GVPIfT4h?3I zVF9Ob24(k9PZtIT1|1d#h8Z9^r=0vGkYY%ZV00H@V&DYve=!;}h=Jn?oXtSV1%yQy z7{KKLH2%TKh=Jh*)Rk-uT@0FxYz(WwWEq1PBR_*DBLf2)Llxr}1}+9h244m)2467A z#pnyN2Vxro$e)Z10t^w13=E=RUH~XJGfZRn&0xmB$WWjNQrspXz{tkH$iT@Uz{toT z$N=I=G6*noF<3H8W0YYqWDsCfX0T*XV$fu;WME*_V=!b`$Y{)9$gr5vn8A|aIfEI4 zC4&%y6@w*12!kDiC4)7X-N@*|V96j2X6rNfF<3I(0jo@52xqWl=wdWu&;;A1$H2{y z!l1_>%#h2V#~{tn!yv%G0xD5Jj)UVYMnt&-5{za5g*YTEL3{{K1O*|48J3z{l3!%R zVB?#gQks)$#}MQg8Sdd3;>zIb807Eo#}J%a5|UVyo?7A-5X|6GlvwVZS(KcU8phz_ z80769mOz;m43*%B@-1RWWT<4wVaQ}iVo+d+W=LkpXDDJwWr$@^U`S=CU`S-h zWhh|CVMt|AV9;eyV8~`jWvFCGV#sGmWGG@tVNhVmWXNMEU?^oMVPLe*WyohJ1FJ1z z$Nwkd7#YgSU20{sLWBv#${hzK5yfxWnfWY zWaMC0U|?ibU}O{&76wKp4kk7pW(EdE zW;Q`ZRt82!K}AjmRz^OMHbo8wW=26t9zjKB1_maM?Nu>hk|qy2IT*o30Rw{^D7S_% ziG>#>7Wn1oxmF~n7J$-BNJde9c`+jgBLk@L1qWFMwEh5bnm}xDt_JZ?F|3|}h{ikT z7r9oXf>Q@LWv8a@meFflMpaA06a0aZL80~kPT69xu`Fos};c!n?rSB4;l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rzV#c zWtLPz`3ed)MX80Qsl_F!DFH>9Wtlmt>8Zs;nraL)RY3vS9M_7} - /// Rough generator for Raylib-cs to help automate binding + porting raylib code - /// Output will still need to be modified + /// Rough generator for creating bindings and ports for raylib + /// Not a full parser so generated code is not perfect /// class Program { static void Main(string[] args) { Console.WriteLine("Raylib-cs generator"); - GenerateBindings(); - GenerateExamples(); - GenerateTemplates(); - GenerateGames(); - + // GeneratePort("Examples"); + // GeneratePort("Templates"); + // GeneratePort("Games"); Console.WriteLine("Finished generating. Enjoy! :)"); Console.WriteLine("Press enter to exit"); Console.Read(); } + /// + /// Requires raylib headers + /// static void GenerateBindings() { Console.WriteLine("Generating bindings"); Generator.Process("raylib.h", "RLAPI"); + Generator.Process("raymath.h", "RMDEF"); + Generator.Process("physac.h", "PDEF"); Generator.Process("rlgl.h", "RLGL"); } - static void GenerateExamples() + /// + /// Porting C to C# + /// + static void GeneratePort(string folder) { Console.WriteLine("Generating examples"); // output folder - var folder = "Examples"; Directory.CreateDirectory(folder); var path = Generator.RaylibDirectory + folder.ToLower(); var dirs = Directory.GetDirectories(path); @@ -51,75 +56,5 @@ namespace Raylibcs Generator.ProcessExample(file, folder, folder + "//" + name); } } - - static void GenerateTemplates() - { - Console.WriteLine("Generating templates"); - - // output folder - var folder = "Templates"; - Directory.CreateDirectory(folder); - var path = Generator.RaylibDirectory2 + folder.ToLower(); - var dirs = Directory.GetDirectories(path); - - // copy folder structure - foreach (string dirPath in Directory.GetDirectories(path, "*", - SearchOption.AllDirectories)) - Directory.CreateDirectory(dirPath.Replace(path, folder)); - - // process all c files in directory and output result - var files = Directory.GetFiles(path, "*.c", SearchOption.AllDirectories); - foreach (var file in files) - { - var dirName = Path.GetDirectoryName(file); - var name = new DirectoryInfo(dirName).Name; - if (name == folder.ToLower()) - { - Generator.ProcessExample(file, folder, folder); - } - else - { - var t = file; - t = folder + t.Replace(path, ""); - t = new FileInfo(t).Directory.FullName; - Generator.ProcessExample(file, folder, t); - } - } - } - - static void GenerateGames() - { - Console.WriteLine("Generating games"); - - // output folder - var folder = "Games"; - Directory.CreateDirectory(folder); - var path = Generator.RaylibDirectory2 + folder.ToLower(); - var dirs = Directory.GetDirectories(path); - - // copy folder structure - foreach (string dirPath in Directory.GetDirectories(path, "*", - SearchOption.AllDirectories)) - Directory.CreateDirectory(dirPath.Replace(path, folder)); - - // process all c files in directory and output result - var files = Directory.GetFiles(path, "*.c", SearchOption.AllDirectories); - foreach (var file in files) - { - var dirName = Path.GetDirectoryName(file); - var name = new DirectoryInfo(dirName).Name; - if (name == folder.ToLower()) - { - Generator.ProcessExample(file, folder, folder); - } - else - { - var t = file; - t = folder + t.Replace(path, ""); - t = new FileInfo(t).Directory.FullName; - Generator.ProcessExample(file, folder, t); - } - } - } } } diff --git a/Raylib-cs.nuspec b/Raylib-cs.nuspec deleted file mode 100644 index a3c0e00..0000000 --- a/Raylib-cs.nuspec +++ /dev/null @@ -1,21 +0,0 @@ - - - - Raylib-cs - 1.0 - Chris Dill - Chris Dill - https://github.com/ChrisDill/Raylib-cs/blob/master/LICENSE - https://github.com/ChrisDill/Raylib-cs - https://github.com/ChrisDill/Raylib-cs/blob/master/Logo/raylib-cs.ico - false - Testing C# bindings for raylib, a simple and easy-to-use library to learn videogames programming. - Made for raylib 2.0 - Copyright 2018 - raylib csharp binding opengl gamedev - - - - - - \ No newline at end of file diff --git a/Raylib-cs.sln b/Raylib-cs.sln index 5c75c20..5e88691 100644 --- a/Raylib-cs.sln +++ b/Raylib-cs.sln @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.27703.2035 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Generator", "Generator\Generator.csproj", "{063F21F1-12D3-41C6-B598-125C725955B1}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bindings", "Bindings\Bindings.csproj", "{9F30944C-415B-4763-91C7-81721117879D}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bindings", "Bindings\Bindings.csproj", "{363D543C-F690-41AA-8215-2D368EA7434E}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Generator", "Generator\Generator.csproj", "{063F21F1-12D3-41C6-B598-125C725955B1}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{A2B3BBC8-3D48-46DD-B3CF-263F554E4474}" EndProject @@ -19,6 +19,18 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9F30944C-415B-4763-91C7-81721117879D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9F30944C-415B-4763-91C7-81721117879D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9F30944C-415B-4763-91C7-81721117879D}.Debug|x64.ActiveCfg = Debug|Any CPU + {9F30944C-415B-4763-91C7-81721117879D}.Debug|x64.Build.0 = Debug|Any CPU + {9F30944C-415B-4763-91C7-81721117879D}.Debug|x86.ActiveCfg = Debug|Any CPU + {9F30944C-415B-4763-91C7-81721117879D}.Debug|x86.Build.0 = Debug|Any CPU + {9F30944C-415B-4763-91C7-81721117879D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9F30944C-415B-4763-91C7-81721117879D}.Release|Any CPU.Build.0 = Release|Any CPU + {9F30944C-415B-4763-91C7-81721117879D}.Release|x64.ActiveCfg = Release|Any CPU + {9F30944C-415B-4763-91C7-81721117879D}.Release|x64.Build.0 = Release|Any CPU + {9F30944C-415B-4763-91C7-81721117879D}.Release|x86.ActiveCfg = Release|Any CPU + {9F30944C-415B-4763-91C7-81721117879D}.Release|x86.Build.0 = Release|Any CPU {063F21F1-12D3-41C6-B598-125C725955B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {063F21F1-12D3-41C6-B598-125C725955B1}.Debug|Any CPU.Build.0 = Debug|Any CPU {063F21F1-12D3-41C6-B598-125C725955B1}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -31,18 +43,6 @@ Global {063F21F1-12D3-41C6-B598-125C725955B1}.Release|x64.Build.0 = Release|Any CPU {063F21F1-12D3-41C6-B598-125C725955B1}.Release|x86.ActiveCfg = Release|Any CPU {063F21F1-12D3-41C6-B598-125C725955B1}.Release|x86.Build.0 = Release|Any CPU - {363D543C-F690-41AA-8215-2D368EA7434E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {363D543C-F690-41AA-8215-2D368EA7434E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {363D543C-F690-41AA-8215-2D368EA7434E}.Debug|x64.ActiveCfg = Debug|Any CPU - {363D543C-F690-41AA-8215-2D368EA7434E}.Debug|x64.Build.0 = Debug|Any CPU - {363D543C-F690-41AA-8215-2D368EA7434E}.Debug|x86.ActiveCfg = Debug|Any CPU - {363D543C-F690-41AA-8215-2D368EA7434E}.Debug|x86.Build.0 = Debug|Any CPU - {363D543C-F690-41AA-8215-2D368EA7434E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {363D543C-F690-41AA-8215-2D368EA7434E}.Release|Any CPU.Build.0 = Release|Any CPU - {363D543C-F690-41AA-8215-2D368EA7434E}.Release|x64.ActiveCfg = Release|Any CPU - {363D543C-F690-41AA-8215-2D368EA7434E}.Release|x64.Build.0 = Release|Any CPU - {363D543C-F690-41AA-8215-2D368EA7434E}.Release|x86.ActiveCfg = Release|Any CPU - {363D543C-F690-41AA-8215-2D368EA7434E}.Release|x86.Build.0 = Release|Any CPU {A2B3BBC8-3D48-46DD-B3CF-263F554E4474}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A2B3BBC8-3D48-46DD-B3CF-263F554E4474}.Debug|Any CPU.Build.0 = Debug|Any CPU {A2B3BBC8-3D48-46DD-B3CF-263F554E4474}.Debug|x64.ActiveCfg = Debug|x64 diff --git a/Test/App.config b/Test/App.config index 731f6de..8fc0551 100644 --- a/Test/App.config +++ b/Test/App.config @@ -1,6 +1,6 @@ - + - + - \ No newline at end of file + diff --git a/Test/Program.cs b/Test/Program.cs index 046b8ce..265e373 100644 --- a/Test/Program.cs +++ b/Test/Program.cs @@ -8,9 +8,6 @@ class Program { public static void Main() { - //RayForms.Run(); - //return; - // Initialization //-------------------------------------------------------------------------------------- int screenWidth = 800; @@ -19,6 +16,9 @@ class Program // SetConfigFlags((int)Flag.WINDOW_UNDECORATED); InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window"); + var model = LoadModel("bridge.obj"); + model.mesh.Vertices[0] = 5f; + SetTargetFPS(60); //-------------------------------------------------------------------------------------- @@ -45,6 +45,6 @@ class Program // De-Initialization //-------------------------------------------------------------------------------------- CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- + //-------------------------------------------------------------------------------------- } } diff --git a/Test/RayForms.cs b/Test/RayForms.cs deleted file mode 100644 index f54f92e..0000000 --- a/Test/RayForms.cs +++ /dev/null @@ -1,102 +0,0 @@ -using System; -using System.Drawing; -using System.Runtime.InteropServices; -using System.Threading; -using System.Windows.Forms; -using static Raylib.Raylib; - -namespace Raylib -{ - public partial class RayForms : Form - { - private Panel gamePanel; - private bool windowAttached = false; - - #region WinAPI Entry Points - - [DllImport("user32.dll")] - private static extern IntPtr SetWindowPos(IntPtr handle, IntPtr handleAfter, int x, int y, int cx, int cy, uint flags); - [DllImport("user32.dll")] - private static extern IntPtr SetParent(IntPtr child, IntPtr newParent); - [DllImport("user32.dll")] - private static extern IntPtr ShowWindow(IntPtr handle, int command); - - #endregion - - public RayForms() - { - Size = new Size(1024, 700); - Text = "Rayforms"; - - gamePanel = new Panel(); - gamePanel.Size = new Size(800, 500); - gamePanel.Location = new Point(50, 50); - - Button button = new Button(); - button.Text = "Attach window"; - button.Size = new Size(150, 20); - button.Location = new Point( - (Size.Width / 2) - (button.Size.Width / 2), - gamePanel.Location.Y + gamePanel.Size.Height + 10 - ); - button.Click += new EventHandler(ClickedButton); - Controls.Add(button); - Controls.Add(gamePanel); - } - - private void ClickedButton(object sender, EventArgs e) - { - if (!windowAttached) - { - // new Thread(Test).Start(); - Test(); - } - } - - private void Test() - { - SetConfigFlags((int)Flag.WINDOW_UNDECORATED); - InitWindow(800, 480, "Rayforms test"); - SetTargetFPS(60); - - IntPtr winHandle = GetWindowHandle(); - Invoke(new Action(() => - { - SetWindowPos(winHandle, Handle, 0, 0, 0, 0, 0x0401 /*NOSIZE | SHOWWINDOW */); - SetParent(winHandle, gamePanel.Handle); - ShowWindow(winHandle, 1); - windowAttached = true; - })); - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - // TODO: Update your variables here - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText("Congrats! You created your first window!", 190, 200, 20, MAROON); - - DrawText(GetFrameTime().ToString(), 100, 10, 15, MAROON); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - CloseWindow(); - } - - public static void Run() - { - Application.Run(new RayForms()); - } - } -} diff --git a/Test/Test.csproj b/Test/Test.csproj index 72b8248..2ba1edb 100644 --- a/Test/Test.csproj +++ b/Test/Test.csproj @@ -8,9 +8,25 @@ Exe Test Test - v4.6.1 + v4.7.1 512 true + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true AnyCPU @@ -84,27 +100,49 @@ + + ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll + + + ..\packages\System.Memory.4.5.1\lib\netstandard2.0\System.Memory.dll + + + + ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + - - - Form - + + + + False + Microsoft .NET Framework 4.6.1 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + - {363d543c-f690-41aa-8215-2d368ea7434e} + {9f30944c-415b-4763-91c7-81721117879d} Bindings diff --git a/Test/packages.config b/Test/packages.config new file mode 100644 index 0000000..087ebcb --- /dev/null +++ b/Test/packages.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file