Watch
3
0
Fork
You've already forked raylib-cs
0

Updated bindings!

- Changed internal class name from rl to Raylib.
- Improving documentation and tidying bindings a bit.
- Renamed DrawControl to RayForm.
- Bindings now a class library for easy reuse.
This commit is contained in:
Chris 2018-09-10 12:18:51 +01:00
commit 410d50c65f
12 changed files with 1349 additions and 796 deletions

View file

@ -1,78 +1,81 @@
/**********************************************************************************************
*
* Raylib easings bindings
* Original - https://github.com/raysan5/raylib/blob/master/src/easings.h
*
**********************************************************************************************/
using System;
using System.Runtime.InteropServices;
namespace Raylib
{
#region Raylib-cs Enums
#endregion
#region Raylib-cs Types
#endregion
public static partial class rl
public static partial class Raylib
{
#region Raylib-cs Variables
#endregion
#region Raylib-cs Functions
// Linear Easing functions
[DllImport(nativeLibName)]
public static extern float EaseLinearNone(float t, float b, float c, float d);
[DllImport(nativeLibName)]
public static extern float EaseLinearIn(float t, float b, float c, float d);
[DllImport(nativeLibName)]
public static extern float EaseLinearOut(float t, float b, float c, float d);
[DllImport(nativeLibName)]
public static extern float EaseLinearInOut(float t, float b, float c, float d);
// Sine Easing functions
[DllImport(nativeLibName)]
public static extern float EaseSineIn(float t, float b, float c, float d);
[DllImport(nativeLibName)]
public static extern float EaseSineOut(float t, float b, float c, float d);
[DllImport(nativeLibName)]
public static extern float EaseSineInOut(float t, float b, float c, float d);
// Circular Easing functions
[DllImport(nativeLibName)]
public static extern float EaseCircIn(float t, float b, float c, float d);
[DllImport(nativeLibName)]
public static extern float EaseCircOut(float t, float b, float c, float d);
[DllImport(nativeLibName)]
public static extern float EaseCircInOut(float t, float b, float c, float d);
// Cubic Easing functions
[DllImport(nativeLibName)]
public static extern float EaseCubicIn(float t, float b, float c, float d);
[DllImport(nativeLibName)]
public static extern float EaseCubicOut(float t, float b, float c, float d);
[DllImport(nativeLibName)]
public static extern float EaseCubicInOut(float t, float b, float c, float d);
// Quadratic Easing functions
[DllImport(nativeLibName)]
public static extern float EaseQuadIn(float t, float b, float c, float d);
[DllImport(nativeLibName)]
public static extern float EaseQuadOut(float t, float b, float c, float d);
[DllImport(nativeLibName)]
public static extern float EaseQuadInOut(float t, float b, float c, float d);
// Exponential Easing functions
[DllImport(nativeLibName)]
public static extern float EaseExpoIn(float t, float b, float c, float d);
[DllImport(nativeLibName)]
public static extern float EaseExpoOut(float t, float b, float c, float d);
[DllImport(nativeLibName)]
public static extern float EaseExpoInOut(float t, float b, float c, float d);
// Back Easing functions
[DllImport(nativeLibName)]
@ -83,8 +86,7 @@ namespace Raylib
[DllImport(nativeLibName)]
public static extern float EaseBackInOut(float t, float b, float c, float d);
// Bounce Easing functions
[DllImport(nativeLibName)]
public static extern float EaseBounceOut(float t, float b, float c, float d);
@ -94,8 +96,7 @@ namespace Raylib
[DllImport(nativeLibName)]
public static extern float EaseBounceInOut(float t, float b, float c, float d);
// Elastic Easing functions
[DllImport(nativeLibName)]
public static extern float EaseElasticIn(float t, float b, float c, float d);

View file

@ -1,4 +1,11 @@
/**********************************************************************************************
*
* Physac
* Original -https://github.com/raysan5/raylib/blob/master/src/physac.h
*
**********************************************************************************************/
using System;
using System.Runtime.InteropServices;
namespace Raylib
@ -29,15 +36,19 @@ namespace Raylib
public struct PolygonData
{
public uint vertexCount; // Current used vertex and normals count
//public Vector2 positions[PHYSAC_MAX_VERTICES]; // Polygon vertex positions vectors
//public Vector2 normals[PHYSAC_MAX_VERTICES]; // Polygon vertex normals vectors
[MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Raylib.PHYSAC_MAX_VERTICES)]
public Vector2[] positions; // Polygon vertex positions vectors
[MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Raylib.PHYSAC_MAX_VERTICES)]
public Vector2[] normals; // Polygon vertex normals vectors
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct PhysicsShape
{
public PhysicsShapeType type; // Physics shape type (circle or polygon)
//public PhysicsBodyData body; // Shape physics body reference
public IntPtr body; // Shape physics body reference
public float radius; // Circle shape radius (used for circle shapes)
public Mat2 transform; // Vertices transform matrix 2x2
public PolygonData vertexData; // Polygon shape vertices position and normals data (just used for polygon shapes)
@ -71,11 +82,14 @@ namespace Raylib
public struct PhysicsManifoldData
{
public uint id; // Reference unique identifier
//public PhysicsBody bodyA; // Manifold first physics body reference
//public PhysicsBody bodyB; // Manifold second physics body reference
public PhysicsBodyData bodyA; // Manifold first physics body reference
public PhysicsBodyData bodyB; // Manifold second physics body reference
public float penetration; // Depth of penetration from collision
public Vector2 normal; // Normal direction vector from 'a' to 'b'
//public Vector2 contacts[2]; // Points of contact during collision
[MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = 2)]
public Vector2[] contacts; // Points of contact during collision
public uint contactsCount; // Current collision number of contacts
public float restitution; // Mixed restitution during collision
public float dynamicFriction; // Mixed dynamic friction during collision
@ -84,7 +98,7 @@ namespace Raylib
#endregion
public static partial class rl
public static partial class Raylib
{
#region Raylib-cs Variables
@ -108,61 +122,79 @@ namespace Raylib
#region Raylib-cs Functions
// Initializes physics values, pointers and creates physics loop thread
[DllImport(nativeLibName)]
public static extern void InitPhysics(); // Initializes physics values, pointers and creates physics loop thread
public static extern void InitPhysics();
[DllImport(nativeLibName)]
public static extern bool IsPhysicsEnabled(); // Returns true if physics thread is currently enabled
// Returns true if physics thread is currently enabled
[DllImport(nativeLibName)]
public static extern bool IsPhysicsEnabled();
[DllImport(nativeLibName)]
public static extern void SetPhysicsGravity(float x, float y); // Sets physics global gravity force
// Sets physics global gravity force
[DllImport(nativeLibName)]
public static extern void SetPhysicsGravity(float x, float y);
[DllImport(nativeLibName)]
public static extern PhysicsBodyData CreatePhysicsBodyCircle(Vector2 pos, float radius, float density); // Creates a new circle physics body with generic parameters
// Creates a new circle physics body with generic parameters
[DllImport(nativeLibName)]
public static extern PhysicsBodyData CreatePhysicsBodyCircle(Vector2 pos, float radius, float density);
[DllImport(nativeLibName)]
public static extern PhysicsBodyData CreatePhysicsBodyRectangle(Vector2 pos, float width, float height, float density); // Creates a new rectangle physics body with generic parameters
// Creates a new rectangle physics body with generic parameters
[DllImport(nativeLibName)]
public static extern PhysicsBodyData CreatePhysicsBodyRectangle(Vector2 pos, float width, float height, float density);
[DllImport(nativeLibName)]
public static extern PhysicsBodyData CreatePhysicsBodyPolygon(Vector2 pos, float radius, int sides, float density); // Creates a new polygon physics body with generic parameters
// Creates a new polygon physics body with generic parameters
[DllImport(nativeLibName)]
public static extern PhysicsBodyData CreatePhysicsBodyPolygon(Vector2 pos, float radius, int sides, float density);
[DllImport(nativeLibName)]
public static extern void PhysicsAddForce(PhysicsBodyData body, Vector2 force); // Adds a force to a physics body
// Adds a force to a physics body
[DllImport(nativeLibName)]
public static extern void PhysicsAddForce(PhysicsBodyData body, Vector2 force);
[DllImport(nativeLibName)]
public static extern void PhysicsAddTorque(PhysicsBodyData body, float amount); // Adds an angular force to a physics body
// Adds an angular force to a physics body
[DllImport(nativeLibName)]
public static extern void PhysicsAddTorque(PhysicsBodyData body, float amount);
// Shatters a polygon shape physics body to little physics bodies with explosion force
[DllImport(nativeLibName)]
public static extern void PhysicsShatter(PhysicsBodyData body, Vector2 position, float force);
[DllImport(nativeLibName)]
public static extern void PhysicsShatter(PhysicsBodyData body, Vector2 position, float force); // Shatters a polygon shape physics body to little physics bodies with explosion force
// Returns the current amount of created physics bodies
[DllImport(nativeLibName)]
public static extern int GetPhysicsBodiesCount();
[DllImport(nativeLibName)]
public static extern int GetPhysicsBodiesCount(); // Returns the current amount of created physics bodies
// Returns a physics body of the bodies pool at a specific index
[DllImport(nativeLibName)]
public static extern IntPtr GetPhysicsBody(int index);
// Returns the physics body shape type (PHYSICS_CIRCLE or PHYSICS_POLYGON)
[DllImport(nativeLibName)]
public static extern int GetPhysicsShapeType(int index);
[DllImport(nativeLibName)]
public static extern PhysicsBodyData GetPhysicsBody(int index); // Returns a physics body of the bodies pool at a specific index
// Returns the amount of vertices of a physics body shape
[DllImport(nativeLibName)]
public static extern int GetPhysicsShapeVerticesCount(int index);
[DllImport(nativeLibName)]
public static extern int GetPhysicsShapeType(int index); // Returns the physics body shape type (PHYSICS_CIRCLE or PHYSICS_POLYGON)
// Returns transformed position of a body shape (body position + vertex transformed position)
[DllImport(nativeLibName)]
public static extern Vector2 GetPhysicsShapeVertex(PhysicsBodyData body, int vertex);
[DllImport(nativeLibName)]
public static extern int GetPhysicsShapeVerticesCount(int index); // Returns the amount of vertices of a physics body shape
// Sets physics body shape transform based on radians parameter
[DllImport(nativeLibName)]
public static extern void SetPhysicsBodyRotation(PhysicsBodyData body, float radians);
[DllImport(nativeLibName)]
public static extern Vector2 GetPhysicsShapeVertex(PhysicsBodyData body, int vertex); // Returns transformed position of a body shape (body position + vertex transformed position)
// Unitializes and destroy a physics body
[DllImport(nativeLibName)]
public static extern void DestroyPhysicsBody(PhysicsBodyData body);
[DllImport(nativeLibName)]
public static extern void SetPhysicsBodyRotation(PhysicsBodyData body, float radians); // Sets physics body shape transform based on radians parameter
// Destroys created physics bodies and manifolds and resets global values
[DllImport(nativeLibName)]
public static extern void ResetPhysics();
[DllImport(nativeLibName)]
public static extern void DestroyPhysicsBody(PhysicsBodyData body); // Unitializes and destroy a physics body
// Unitializes physics pointers and closes physics loop thread
[DllImport(nativeLibName)]
public static extern void ClosePhysics();
[DllImport(nativeLibName)]
public static extern void ResetPhysics(); // Destroys created physics bodies and manifolds and resets global values
[DllImport(nativeLibName)]
public static extern void ClosePhysics(); // Unitializes physics pointers and closes physics loop thread
#endregion
#endregion
}
}

63
Bindings/RayForm.Designer.cs generated Normal file
View file

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Raylib {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// 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() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[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;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

52
Bindings/RayForm.cs Normal file
View file

@ -0,0 +1,52 @@
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using static Raylib.Raylib;
namespace Raylib
{
class DrawControl : Form
{
private Panel panel;
[DllImport("user32.dll")]
private static extern IntPtr SetParent(IntPtr child, IntPtr newParent);
[DllImport("user32.dll")]
private static extern IntPtr ShowWindow(IntPtr handle, int command);
public static void Run()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new DrawControl());
}
public DrawControl()
{
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)
{
}
}
}

120
Bindings/RayForm.resx Normal file
View file

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -1,3 +1,9 @@
/**********************************************************************************************
*
* Raygui
* https://github.com/raysan5/raygui/blob/master/src/raygui.h
*
**********************************************************************************************/
using System;
using System.Runtime.InteropServices;
@ -182,14 +188,18 @@ namespace Raylib
LISTVIEW_TEXT_COLOR_DISABLED
}
#endregion
#region Raylib-cs Types
// GUI controls state
public enum GuiControlState
{
DISABLED = 0,
NORMAL,
FOCUSED,
PRESSED
}
#endregion
public static partial class rl
public static partial class Raylib
{
#region Raylib-cs Variables
@ -197,10 +207,6 @@ namespace Raylib
#region Raylib-cs Functions
//----------------------------------------------------------------------------------
// Module Functions Declaration
//----------------------------------------------------------------------------------
// Global gui modification functions
// Enable gui controls (global state)
[DllImport(nativeLibName)]
@ -213,8 +219,7 @@ namespace Raylib
// Set gui controls alpha (global state), alpha goes from 0.0f to 1.0f
[DllImport(nativeLibName)]
public static extern void GuiFade(float alpha);
// Style set/get functions
// Set one style property
[DllImport(nativeLibName)]
@ -223,8 +228,7 @@ namespace Raylib
// Get one style property
[DllImport(nativeLibName)]
public static extern int GuiGetStyleProperty(int guiProperty);
// Container/separator controls, useful for controls organization
// Window Box control, shows a window that can be closed
[DllImport(nativeLibName)]
@ -244,9 +248,7 @@ namespace Raylib
// Scroll Panel control
[DllImport(nativeLibName)]
public static extern Vector2 GuiScrollPanel(Rectangle bounds, Rectangle content, Vector2 viewScroll);
public static extern Vector2 GuiScrollPanel(Rectangle bounds, Rectangle content, Vector2 viewScroll);
// Basic controls set
// Label control, shows text
@ -339,8 +341,7 @@ namespace Raylib
// Dummy control for placeholders
[DllImport(nativeLibName)]
public static extern void GuiDummyRec(Rectangle bounds, string text);
public static extern void GuiDummyRec(Rectangle bounds, string text);
// Advance controls set
// List View control, returns selected list element index

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,11 @@
/**********************************************************************************************
*
* Raymath v1.2 bindings - Math functions to work with Vector3, Matrix and Quaternions
* Original - https://github.com/raysan5/raylib/blob/master/src/raymath.h
*
**********************************************************************************************/
using System;
using System.Runtime.InteropServices;
namespace Raylib
@ -17,6 +24,7 @@ namespace Raylib
this.y = y;
}
// extensions
public override bool Equals(object obj)
{
return (obj is Vector2) && Equals((Vector2)obj);
@ -32,43 +40,6 @@ namespace Raylib
return "Vector2(" + x + " " + y + ")";
}
// utility for c functions Vector2Zero -> Zero etc
[DllImport(rl.nativeLibName, EntryPoint = "Vector2Zero")]
public static extern Vector2 Zero();
[DllImport(rl.nativeLibName, EntryPoint = "Vector2One")]
public static extern Vector2 One();
[DllImport(rl.nativeLibName, EntryPoint = "Vector2Add")]
public static extern Vector2 operator +(Vector2 v1, Vector2 v2);
[DllImport(rl.nativeLibName, EntryPoint = "Vector2Subtract")]
public static extern Vector2 operator -(Vector2 v1, Vector2 v2);
[DllImport(rl.nativeLibName, EntryPoint = "Vector2Length")]
public static extern float Length(Vector2 v);
[DllImport(rl.nativeLibName, EntryPoint = "Vector2DotProduct")]
public static extern float DotProduct(Vector2 v1, Vector2 v2);
[DllImport(rl.nativeLibName, EntryPoint = "Vector2Distance")]
public static extern float Distance(Vector2 v1, Vector2 v2);
[DllImport(rl.nativeLibName, EntryPoint = "Vector2Angle")]
public static extern float Angle(Vector2 v1, Vector2 v2);
[DllImport(rl.nativeLibName, EntryPoint = "Vector2Scale")]
public static extern Vector2 Scale(Vector2 v, float scale);
[DllImport(rl.nativeLibName, EntryPoint = "Vector2Negate")]
public static extern Vector2 Negate(Vector2 v);
[DllImport(rl.nativeLibName, EntryPoint = "Vector2Divide")]
public static extern Vector2 Divide(Vector2 v, float div);
[DllImport(rl.nativeLibName, EntryPoint = "Vector2Normalize")]
public static extern Vector2 Normalize(Vector2 v);
public static bool operator ==(Vector2 v1, Vector2 v2)
{
return (v1.x == v2.x && v1.y == v2.y);
@ -78,6 +49,74 @@ namespace Raylib
{
return !(v1 == v2);
}
public static bool operator >(Vector2 v1, Vector2 v2)
{
return v1.x > v2.x && v1.y > v2.y;
}
public static bool operator <(Vector2 v1, Vector2 v2)
{
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();
}
public static float Length(Vector2 v)
{
return Raylib.Vector2Length(v);
}
public static float DotProduct(Vector2 v1, Vector2 v2)
{
return Raylib.Vector2DotProduct(v1, v2);
}
public static float Distance(Vector2 v1, Vector2 v2)
{
return Raylib.Vector2Distance(v1, v2);
}
public static float Angle(Vector2 v1, Vector2 v2)
{
return Raylib.Vector2Angle(v1, v2);
}
public static Vector2 Scale(Vector2 v, float scale)
{
return Raylib.Vector2Scale(v, scale);
}
public static Vector2 Negate(Vector2 v)
{
return Raylib.Vector2Negate(v);
}
public static Vector2 Divide(Vector2 v, float div)
{
return Raylib.Vector2Divide(v, div);
}
public static Vector2 Normalize(Vector2 v)
{
return Raylib.Vector2Normalize(v);
}
// extra operators(Vector2Add(v1, v2) -> v1 += v2);
[DllImport(Raylib.nativeLibName, EntryPoint = "Vector2Add")]
public static extern Vector2 operator +(Vector2 v1, Vector2 v2);
[DllImport(Raylib.nativeLibName, EntryPoint = "Vector2Subtract")]
public static extern Vector2 operator -(Vector2 v1, Vector2 v2);
}
// Vector3 type
@ -104,55 +143,10 @@ namespace Raylib
return x.GetHashCode() + y.GetHashCode() + z.GetHashCode();
}
// utility for c functions Vector3Zero -> Zero etc
[DllImport(rl.nativeLibName, EntryPoint = "Vector3Zero")]
public static extern Vector3 Zero();
[DllImport(rl.nativeLibName, EntryPoint = "Vector3One")]
public static extern Vector3 One();
[DllImport(rl.nativeLibName, EntryPoint = "Vector3Add")]
public static extern Vector3 operator +(Vector3 v1, Vector3 v3);
[DllImport(rl.nativeLibName, EntryPoint = "Vector3Subtract")]
public static extern Vector3 operator -(Vector3 v1, Vector3 v3);
[DllImport(rl.nativeLibName, EntryPoint = "Vector3Length")]
public static extern float Length(Vector3 v);
[DllImport(rl.nativeLibName, EntryPoint = "Vector3DotProduct")]
public static extern float DotProduct(Vector3 v1, Vector3 v3);
[DllImport(rl.nativeLibName, EntryPoint = "Vector3Distance")]
public static extern float Distance(Vector3 v1, Vector3 v3);
[DllImport(rl.nativeLibName, EntryPoint = "Vector3Angle")]
public static extern float Angle(Vector3 v1, Vector3 v3);
[DllImport(rl.nativeLibName, EntryPoint = "Vector3Scale")]
public static extern Vector3 Scale(Vector3 v, float scale);
[DllImport(rl.nativeLibName, EntryPoint = "Vector3Negate")]
public static extern Vector3 Negate(Vector3 v);
[DllImport(rl.nativeLibName, EntryPoint = "Vector3Divide")]
public static extern Vector3 Divide(Vector3 v, float div);
[DllImport(rl.nativeLibName, EntryPoint = "Vector3Normalize")]
public static extern Vector3 Normalize(Vector3 v);
// operators
[DllImport(rl.nativeLibName, EntryPoint = "Vector3MultiplyV")]
public static extern Vector3 operator *(Vector3 v1, Vector3 v3);
[DllImport(rl.nativeLibName, EntryPoint = "Vector3Multiply")]
public static extern Vector3 operator *(Vector3 v1, float scale);
[DllImport(rl.nativeLibName, EntryPoint = "Vector3Divide")]
public static extern Vector3 operator /(Vector3 v1, Vector3 v3);
[DllImport(rl.nativeLibName, EntryPoint = "Vector3Negate")]
public static extern Vector3 operator -(Vector3 v1);
public override string ToString()
{
return "Vector3(" + x + " " + y + " " + z + ")";
}
public static bool operator ==(Vector3 v1, Vector3 v2)
{
@ -163,6 +157,66 @@ namespace Raylib
{
return !(v1 == v2);
}
/*public bool operator >(Vector2 v1, Vector2 v2)
{
return v1.x > v2.x && v1.y > v2.y;
}
public static bool operator <(Vector2 v1, Vector2 v2)
{
return v1.x < v2.x && v1.y < v2.y;
}*/
// utility for c functions Vector3Zero -> Zero etc
[DllImport(Raylib.nativeLibName, EntryPoint = "Vector3Zero")]
public static extern Vector3 Zero();
[DllImport(Raylib.nativeLibName, EntryPoint = "Vector3One")]
public static extern Vector3 One();
[DllImport(Raylib.nativeLibName, EntryPoint = "Vector3Add")]
public static extern Vector3 operator +(Vector3 v1, Vector3 v3);
[DllImport(Raylib.nativeLibName, EntryPoint = "Vector3Subtract")]
public static extern Vector3 operator -(Vector3 v1, Vector3 v3);
[DllImport(Raylib.nativeLibName, EntryPoint = "Vector3Length")]
public static extern float Length(Vector3 v);
[DllImport(Raylib.nativeLibName, EntryPoint = "Vector3DotProduct")]
public static extern float DotProduct(Vector3 v1, Vector3 v3);
[DllImport(Raylib.nativeLibName, EntryPoint = "Vector3Distance")]
public static extern float Distance(Vector3 v1, Vector3 v3);
[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);
}
// Vector4 type
@ -180,6 +234,21 @@ namespace Raylib
this.z = z;
this.w = w;
}
public override bool Equals(object obj)
{
return (obj is Vector4) && Equals((Vector4)obj);
}
public override int GetHashCode()
{
return x.GetHashCode() + y.GetHashCode() + z.GetHashCode() + w.GetHashCode();
}
public override string ToString()
{
return "Vector4(" + x + " " + y + " " + z + " " + w + ")";
}
}
// Matrix type (OpenGL style 4x4 - right handed, column major)
@ -190,6 +259,11 @@ namespace Raylib
public float m1, m5, m9, m13;
public float m2, m6, m10, m14;
public float m3, m7, m11, m15;
public override string ToString()
{
return $"Matrix({m0}, {m4}, {m8}, {m12}\n {m1}, {m5}, {m9}, {m13}\n {m2}, {m6}, {m10}, {m14}\n {m3}, {m7}, {m11}, {m15})";
}
}
// Quaternion type
@ -200,11 +274,16 @@ namespace Raylib
public float y;
public float z;
public float w;
public override string ToString()
{
return "Quaternion(" + x + " " + y + " " + z + " " + w + ")";
}
}
#endregion
public static partial class rl
public static partial class Raylib
{
#region Raylib-cs Functions
@ -260,7 +339,6 @@ namespace Raylib
[DllImport(nativeLibName)]
public static extern Vector2 Vector2Normalize(Vector2 v);
// Vector with components value 0.0f
[DllImport(nativeLibName)]
public static extern Vector3 Vector3Zero();
@ -356,7 +434,6 @@ namespace Raylib
[DllImport(nativeLibName)]
public static extern float[] Vector3ToFloatV(Vector3 v);
// Compute matrix determinant
[DllImport(nativeLibName)]
public static extern float MatrixDeterminant(Matrix mat);
@ -439,8 +516,7 @@ namespace Raylib
// Returns float array of matrix data
[DllImport(nativeLibName)]
public static extern float[] MatrixToFloatV(Matrix mat);
// Returns identity quaternion
[DllImport(nativeLibName)]
public static extern Quaternion QuaternionIdentity();

View file

@ -1,3 +1,9 @@
/**********************************************************************************************
*
* Rlgl
* Original - https://github.com/raysan5/raylib/blob/master/src/rlgl.h
*
**********************************************************************************************/
using System;
using System.Runtime.InteropServices;
@ -13,7 +19,7 @@ namespace Raylib
#endregion
public static partial class rl
public static partial class Raylib
{
#region Raylib-cs Variables

Binary file not shown.

Binary file not shown.

View file

@ -1 +1 @@
using Raylib; using static Raylib.rl; public partial class Examples { /******************************************************************************************* * * raylib [core] example - Basic window * * Welcome to raylib! * * To test examples, just press F6 and execute raylib_compile_execute script * Note that compiled executable is placed in the same folder as .c file * * You can find all basic examples on C:\raylib\raylib\examples folder or * raylib official webpage: www.raylib.com * * Enjoy using raylib. :) * * This example has been created using raylib 1.0 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * * Copyright (c) 2013-2016 Ramon Santamaria (@raysan5) * ********************************************************************************************/ public static int core_basic_window() { // 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 //-------------------------------------------------------------------------------------- return 0; } }
using Raylib; using static Raylib.Raylib; public partial class Examples { /******************************************************************************************* * * raylib [core] example - Basic window * * Welcome to raylib! * * To test examples, just press F6 and execute raylib_compile_execute script * Note that compiled executable is placed in the same folder as .c file * * You can find all basic examples on C:\raylib\raylib\examples folder or * raylib official webpage: www.raylib.com * * Enjoy using raylib. :) * * This example has been created using raylib 1.0 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * * Copyright (c) 2013-2016 Ramon Santamaria (@raysan5) * ********************************************************************************************/ public static int core_basic_window() { // 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 //-------------------------------------------------------------------------------------- return 0; } }