diff --git a/Bindings/Bindings.csproj b/Bindings/Bindings.csproj
index 2d21eb0..7127df4 100644
--- a/Bindings/Bindings.csproj
+++ b/Bindings/Bindings.csproj
@@ -5,7 +5,7 @@
Debug
AnyCPU
{A2B3BBC8-3D48-46DD-B3CF-263F554E4474}
- Exe
+ Library
Raylib
Bindings
v4.6.1
@@ -36,7 +36,7 @@
true
bin\Debug\
DEBUG;TRACE
- false
+ true
full
x64
prompt
@@ -52,6 +52,7 @@
prompt
MinimumRecommendedRules.ruleset
true
+ true
true
@@ -83,14 +84,19 @@
+
+
+
+ Form
+
diff --git a/Bindings/Program.cs b/Bindings/Program.cs
index 3ed5f06..046b8ce 100644
--- a/Bindings/Program.cs
+++ b/Bindings/Program.cs
@@ -1,44 +1,50 @@
-using Raylib;
-using static Raylib.Raylib;
-
-// example to quickly test bindings
-// otherwise build as a class library to use in other projects
-class Program
-{
- public static void Main()
- {
- // Initialization
- //--------------------------------------------------------------------------------------
- int screenWidth = 800;
int screenHeight = 450;
-
- InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
-
- SetTargetFPS(60);
- //--------------------------------------------------------------------------------------
-
- // 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);
-
- EndDrawing();
- //----------------------------------------------------------------------------------
- }
-
- // De-Initialization
- //--------------------------------------------------------------------------------------
- CloseWindow(); // Close window and OpenGL context
- //--------------------------------------------------------------------------------------
- }
-}
+using System;
+using Raylib;
+using static Raylib.Raylib;
+
+// example to quickly test bindings
+// otherwise build as a class library to use in other projects
+class Program
+{
+ public static void Main()
+ {
+ //RayForms.Run();
+ //return;
+
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ // SetConfigFlags((int)Flag.WINDOW_UNDECORATED);
+ InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
+
+ SetTargetFPS(60);
+ //--------------------------------------------------------------------------------------
+
+ // 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);
+
+ EndDrawing();
+ //----------------------------------------------------------------------------------
+ }
+
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+ CloseWindow(); // Close window and OpenGL context
+ //--------------------------------------------------------------------------------------
+ }
+}
diff --git a/Bindings/RayForms.cs b/Bindings/RayForms.cs
new file mode 100644
index 0000000..f54f92e
--- /dev/null
+++ b/Bindings/RayForms.cs
@@ -0,0 +1,102 @@
+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/Bindings/Raylib.cs b/Bindings/Raylib.cs
index ff22196..5479185 100644
--- a/Bindings/Raylib.cs
+++ b/Bindings/Raylib.cs
@@ -1,6 +1,6 @@
/**********************************************************************************************
*
- * Raylib 2.0 - A simple and easy-to-use library to learn videogames programming (www.raylib.com)
+ * Raylib - A simple and easy-to-use library to learn videogames programming (www.raylib.com)
* Original - https://github.com/raysan5/raylib/blob/master/src/raylib.h
*
**********************************************************************************************/
@@ -528,12 +528,16 @@ namespace Raylib
// Shader type (generic)
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
- public struct Shader
+ public unsafe struct Shader
{
public uint id;
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = Raylib.MAX_SHADER_LOCATIONS)]
- public int[] locs;
+ // public IntPtr locs;
+ // [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.I1, SizeConst = Raylib.MAX_SHADER_LOCATIONS)]
+ // [MarshalAs(UnmanagedType.ByValArray, SizeConst = Raylib.MAX_SHADER_LOCATIONS)]
+ //[MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_I4)]
+ // public int[] locs;
+ public fixed int locs[Raylib.MAX_SHADER_LOCATIONS];
}
// Material texture map
@@ -745,39 +749,43 @@ namespace Raylib
public static extern int GetScreenHeight();
// Get number of connected monitors
- [DllImport(nativeLibName)]
+ [DllImport(nativeLibName,CallingConvention = CallingConvention.Cdecl)]
public static extern int GetMonitorCount();
// Get primary monitor width
- [DllImport(nativeLibName)]
+ [DllImport(nativeLibName,CallingConvention = CallingConvention.Cdecl)]
public static extern int GetMonitorWidth(int monitor);
// Get primary monitor height
- [DllImport(nativeLibName)]
+ [DllImport(nativeLibName,CallingConvention = CallingConvention.Cdecl)]
public static extern int GetMonitorHeight(int monitor);
// Get primary monitor physical width in millimetres
- [DllImport(nativeLibName)]
+ [DllImport(nativeLibName,CallingConvention = CallingConvention.Cdecl)]
public static extern int GetMonitorPhysicalWidth(int monitor);
// Get primary monitor physical height in millimetres
- [DllImport(nativeLibName)]
+ [DllImport(nativeLibName,CallingConvention = CallingConvention.Cdecl)]
public static extern int GetMonitorPhysicalHeight(int monitor);
// Get the human-readable, UTF-8 encoded name of the primary monitor
- [DllImport(nativeLibName)]
+ [DllImport(nativeLibName,CallingConvention = CallingConvention.Cdecl)]
public static extern string GetMonitorName(int monitor);
- // Get current clipboard text
- //[DllImport(nativeLibName,CallingConvention = CallingConvention.Cdecl)]
- //public static extern string GetClipboard();
+ // Get handle from window
+ [DllImport(nativeLibName,CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr GetWindowHandle();
- // Set current clipboard text
- //[DllImport(nativeLibName,CallingConvention = CallingConvention.Cdecl)]
- //public static extern void SetClipboard(string text);
+ // Get current clipboard text
+ //[DllImport(nativeLibName,CallingConvention = CallingConvention.Cdecl)]
+ //public static extern string GetClipboard();
- // Shows cursor
- [DllImport(nativeLibName,CallingConvention = CallingConvention.Cdecl)]
+ // Set current clipboard text
+ //[DllImport(nativeLibName,CallingConvention = CallingConvention.Cdecl)]
+ //public static extern void SetClipboard(string text);
+
+ // Shows cursor
+ [DllImport(nativeLibName,CallingConvention = CallingConvention.Cdecl)]
public static extern void ShowCursor();
// Hides cursor
diff --git a/Bindings/lib/x64/raylib.dll b/Bindings/lib/x64/raylib.dll
index 87c7735..55e3edf 100644
Binary files a/Bindings/lib/x64/raylib.dll and b/Bindings/lib/x64/raylib.dll differ
diff --git a/Examples/RayForm.Designer.cs b/Examples/RayForm.Designer.cs
deleted file mode 100644
index 5998905..0000000
--- a/Examples/RayForm.Designer.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.42000
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-//------------------------------------------------------------------------------
-
-namespace Raylib {
- using System;
-
-
- ///
- /// A strongly-typed resource class, for looking up localized strings, etc.
- ///
- // This class was auto-generated by the StronglyTypedResourceBuilder
- // class via a tool like ResGen or Visual Studio.
- // To add or remove a member, edit your .ResX file then rerun ResGen
- // with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- public class RayForm {
-
- private static global::System.Resources.ResourceManager resourceMan;
-
- private static global::System.Globalization.CultureInfo resourceCulture;
-
- [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal RayForm() {
- }
-
- ///
- /// Returns the cached ResourceManager instance used by this class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- public static global::System.Resources.ResourceManager ResourceManager {
- get {
- if (object.ReferenceEquals(resourceMan, null)) {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Raylib.RayForm", typeof(RayForm).Assembly);
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- ///
- /// Overrides the current thread's CurrentUICulture property for all
- /// resource lookups using this strongly typed resource class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- public static global::System.Globalization.CultureInfo Culture {
- get {
- return resourceCulture;
- }
- set {
- resourceCulture = value;
- }
- }
- }
-}
diff --git a/Examples/RayForm.cs b/Examples/RayForm.cs
index ad70981..434d804 100644
--- a/Examples/RayForm.cs
+++ b/Examples/RayForm.cs
@@ -1,14 +1,16 @@
using System;
using System.Drawing;
using System.Runtime.InteropServices;
+using System.Threading;
using System.Windows.Forms;
using static Raylib.Raylib;
namespace Raylib
{
- class RayForm : Form
+ public partial class RayForms : Form
{
- private Panel panel;
+ private Panel gamePanel;
+ private bool windowAttached = false;
#region WinAPI Entry Points
@@ -21,38 +23,80 @@ namespace Raylib
#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.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- Application.Run(new RayForm());
- }
-
- public RayForm()
- {
- panel = new Panel();
- panel.Size = new Size(640, 480);
- panel.Location = new Point(80, 10);
- panel.BackColor = System.Drawing.Color.Red;
- Controls.Add(panel);
- }
-
- private void InitializeComponent()
- {
- this.SuspendLayout();
- //
- // DrawControl
- //
- this.ClientSize = new System.Drawing.Size(284, 261);
- this.Name = "DrawControl";
- this.Load += new System.EventHandler(this.DrawControl_Load);
- this.ResumeLayout(false);
-
- }
-
- private void DrawControl_Load(object sender, EventArgs e)
- {
-
+ Application.Run(new RayForms());
}
}
}
diff --git a/Examples/RayForm.resx b/Examples/RayForm.resx
deleted file mode 100644
index 1af7de1..0000000
--- a/Examples/RayForm.resx
+++ /dev/null
@@ -1,120 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
\ No newline at end of file