mirror of
https://github.com/raylib-cs/raylib-cs
synced 2025-06-30 19:03:42 -04:00
Big commit. Starting the update to 3.0!!!
- Renamed the Bindings folder to Raylib-cs. - Renamed namespace from Raylib to Raylib_cs. - Updated functions to raylib 3.0. - Documenting IntPtr types for reference. - Separating modules by making the class and nativeLibName unique to the module. - Added rlgl bindings.
This commit is contained in:
272
Raylib-cs/Easings.cs
Normal file
272
Raylib-cs/Easings.cs
Normal file
@ -0,0 +1,272 @@
|
||||
/* Easings.cs
|
||||
*
|
||||
* Copyright 2020 Chris Dill
|
||||
*
|
||||
* Release under zLib License.
|
||||
* See LICENSE for details.
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace Raylib_cs
|
||||
{
|
||||
public static class Easings
|
||||
{
|
||||
// Linear Easing functions
|
||||
public static float EaseLinearNone(float t, float b, float c, float d)
|
||||
{
|
||||
return (c * t / d + b);
|
||||
}
|
||||
|
||||
public static float EaseLinearIn(float t, float b, float c, float d)
|
||||
{
|
||||
return (c * t / d + b);
|
||||
}
|
||||
|
||||
public static float EaseLinearOut(float t, float b, float c, float d)
|
||||
{
|
||||
return (c * t / d + b);
|
||||
}
|
||||
|
||||
public static float EaseLinearInOut(float t, float b, float c, float d)
|
||||
{
|
||||
return (c * t / d + b);
|
||||
}
|
||||
|
||||
// Sine Easing functions
|
||||
public static float EaseSineIn(float t, float b, float c, float d)
|
||||
{
|
||||
return (-c * (float)Math.Cos(t / d * ((float)Math.PI / 2)) + c + b);
|
||||
}
|
||||
|
||||
public static float EaseSineOut(float t, float b, float c, float d)
|
||||
{
|
||||
return (c * (float)Math.Sin(t / d * ((float)Math.PI / 2)) + b);
|
||||
}
|
||||
|
||||
public static float EaseSineInOut(float t, float b, float c, float d)
|
||||
{
|
||||
return (-c / 2 * ((float)Math.Cos((float)Math.PI * t / d) - 1) + b);
|
||||
}
|
||||
|
||||
// Circular Easing functions
|
||||
public static float EaseCircIn(float t, float b, float c, float d)
|
||||
{
|
||||
return (-c * ((float)Math.Sqrt(1 - (t /= d) * t) - 1) + b);
|
||||
}
|
||||
|
||||
public static float EaseCircOut(float t, float b, float c, float d)
|
||||
{
|
||||
return (c * (float)Math.Sqrt(1 - (t = t / d - 1) * t) + b);
|
||||
}
|
||||
|
||||
public static float EaseCircInOut(float t, float b, float c, float d)
|
||||
{
|
||||
if ((t /= d / 2) < 1)
|
||||
{
|
||||
return (-c / 2 * ((float)Math.Sqrt(1 - t * t) - 1) + b);
|
||||
}
|
||||
return (c / 2 * ((float)Math.Sqrt(1 - t * (t -= 2)) + 1) + b);
|
||||
}
|
||||
|
||||
// Cubic Easing functions
|
||||
public static float EaseCubicIn(float t, float b, float c, float d)
|
||||
{
|
||||
return (c * (t /= d) * t * t + b);
|
||||
}
|
||||
|
||||
public static float EaseCubicOut(float t, float b, float c, float d)
|
||||
{
|
||||
return (c * ((t = t / d - 1) * t * t + 1) + b);
|
||||
}
|
||||
|
||||
public static float EaseCubicInOut(float t, float b, float c, float d)
|
||||
{
|
||||
if ((t /= d / 2) < 1)
|
||||
{
|
||||
return (c / 2 * t * t * t + b);
|
||||
}
|
||||
return (c / 2 * ((t -= 2) * t * t + 2) + b);
|
||||
}
|
||||
|
||||
// Quadratic Easing functions
|
||||
public static float EaseQuadIn(float t, float b, float c, float d)
|
||||
{
|
||||
return (c * (t /= d) * t + b);
|
||||
}
|
||||
|
||||
public static float EaseQuadOut(float t, float b, float c, float d)
|
||||
{
|
||||
return (-c * (t /= d) * (t - 2) + b);
|
||||
}
|
||||
|
||||
public static float EaseQuadInOut(float t, float b, float c, float d)
|
||||
{
|
||||
if ((t /= d / 2) < 1)
|
||||
{
|
||||
return (((c / 2) * (t * t)) + b);
|
||||
}
|
||||
return (-c / 2 * (((t - 2) * (--t)) - 1) + b);
|
||||
}
|
||||
|
||||
// Exponential Easing functions
|
||||
public static float EaseExpoIn(float t, float b, float c, float d)
|
||||
{
|
||||
return (t == 0) ? b : (c * (float)Math.Pow(2, 10 * (t / d - 1)) + b);
|
||||
}
|
||||
|
||||
public static float EaseExpoOut(float t, float b, float c, float d)
|
||||
{
|
||||
return (t == d) ? (b + c) : (c * (-(float)Math.Pow(2, -10 * t / d) + 1) + b);
|
||||
}
|
||||
|
||||
public static float EaseExpoInOut(float t, float b, float c, float d)
|
||||
{
|
||||
if (t == 0)
|
||||
{
|
||||
return b;
|
||||
}
|
||||
if (t == d)
|
||||
{
|
||||
return (b + c);
|
||||
}
|
||||
if ((t /= d / 2) < 1)
|
||||
{
|
||||
return (c / 2 * (float)Math.Pow(2, 10 * (t - 1)) + b);
|
||||
}
|
||||
return (c / 2 * (-(float)Math.Pow(2, -10 * --t) + 2) + b);
|
||||
}
|
||||
|
||||
// Back Easing functions
|
||||
public static float EaseBackIn(float t, float b, float c, float d)
|
||||
{
|
||||
float s = 1.70158f;
|
||||
float postFix = t /= d;
|
||||
return (c * (postFix) * t * ((s + 1) * t - s) + b);
|
||||
}
|
||||
|
||||
public static float EaseBackOut(float t, float b, float c, float d)
|
||||
{
|
||||
float s = 1.70158f;
|
||||
return (c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b);
|
||||
}
|
||||
|
||||
public static float EaseBackInOut(float t, float b, float c, float d)
|
||||
{
|
||||
float s = 1.70158f;
|
||||
if ((t /= d / 2) < 1)
|
||||
{
|
||||
return (c / 2 * (t * t * (((s *= (1.525f)) + 1) * t - s)) + b);
|
||||
}
|
||||
|
||||
float postFix = t -= 2;
|
||||
return (c / 2 * ((postFix) * t * (((s *= (1.525f)) + 1) * t + s) + 2) + b);
|
||||
}
|
||||
|
||||
// Bounce Easing functions
|
||||
public static float EaseBounceOut(float t, float b, float c, float d)
|
||||
{
|
||||
if ((t /= d) < (1 / 2.75f))
|
||||
{
|
||||
return (c * (7.5625f * t * t) + b);
|
||||
}
|
||||
else if (t < (2 / 2.75f))
|
||||
{
|
||||
float postFix = t -= (1.5f / 2.75f);
|
||||
return (c * (7.5625f * (postFix) * t + 0.75f) + b);
|
||||
}
|
||||
else if (t < (2.5 / 2.75))
|
||||
{
|
||||
float postFix = t -= (2.25f / 2.75f);
|
||||
return (c * (7.5625f * (postFix) * t + 0.9375f) + b);
|
||||
}
|
||||
else
|
||||
{
|
||||
float postFix = t -= (2.625f / 2.75f);
|
||||
return (c * (7.5625f * (postFix) * t + 0.984375f) + b);
|
||||
}
|
||||
}
|
||||
|
||||
public static float EaseBounceIn(float t, float b, float c, float d)
|
||||
{
|
||||
return (c - EaseBounceOut(d - t, 0, c, d) + b);
|
||||
}
|
||||
|
||||
public static float EaseBounceInOut(float t, float b, float c, float d)
|
||||
{
|
||||
if (t < d / 2)
|
||||
{
|
||||
return (EaseBounceIn(t * 2, 0, c, d) * 0.5f + b);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (EaseBounceOut(t * 2 - d, 0, c, d) * 0.5f + c * 0.5f + b);
|
||||
}
|
||||
}
|
||||
|
||||
// Elastic Easing functions
|
||||
public static float EaseElasticIn(float t, float b, float c, float d)
|
||||
{
|
||||
if (t == 0)
|
||||
{
|
||||
return b;
|
||||
}
|
||||
if ((t /= d) == 1)
|
||||
{
|
||||
return (b + c);
|
||||
}
|
||||
|
||||
float p = d * 0.3f;
|
||||
float a = c;
|
||||
float s = p / 4;
|
||||
float postFix = a * (float)Math.Pow(2, 10 * (t -= 1));
|
||||
|
||||
return (-(postFix * (float)Math.Sin((t * d - s) * (2 * (float)Math.PI) / p)) + b);
|
||||
}
|
||||
|
||||
public static float EaseElasticOut(float t, float b, float c, float d)
|
||||
{
|
||||
if (t == 0)
|
||||
{
|
||||
return b;
|
||||
}
|
||||
if ((t /= d) == 1)
|
||||
{
|
||||
return (b + c);
|
||||
}
|
||||
|
||||
float p = d * 0.3f;
|
||||
float a = c;
|
||||
float s = p / 4;
|
||||
|
||||
return (a * (float)Math.Pow(2, -10 * t) * (float)Math.Sin((t * d - s) * (2 * (float)Math.PI) / p) + c + b);
|
||||
}
|
||||
|
||||
public static float EaseElasticInOut(float t, float b, float c, float d)
|
||||
{
|
||||
if (t == 0)
|
||||
{
|
||||
return b;
|
||||
}
|
||||
if ((t /= d / 2) == 2)
|
||||
{
|
||||
return (b + c);
|
||||
}
|
||||
|
||||
float p = d * (0.3f * 1.5f);
|
||||
float a = c;
|
||||
float s = p / 4;
|
||||
|
||||
float postFix = 0f;
|
||||
if (t < 1)
|
||||
{
|
||||
postFix = a * (float)Math.Pow(2, 10 * (t -= 1));
|
||||
return -0.5f * (postFix * (float)Math.Sin((t * d - s) * (2 * (float)Math.PI) / p)) + b;
|
||||
}
|
||||
|
||||
postFix = a * (float)Math.Pow(2, -10 * (t -= 1));
|
||||
|
||||
return (postFix * (float)Math.Sin((t * d - s) * (2 * (float)Math.PI) / p) * 0.5f + c + b);
|
||||
}
|
||||
}
|
||||
}
|
239
Raylib-cs/Physac.cs
Normal file
239
Raylib-cs/Physac.cs
Normal file
@ -0,0 +1,239 @@
|
||||
/* Physac.cs
|
||||
*
|
||||
* Copyright 2020 Chris Dill
|
||||
*
|
||||
* Release under zLib License.
|
||||
* See LICENSE for details.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
namespace Raylib_cs
|
||||
{
|
||||
public enum PhysicsShapeType
|
||||
{
|
||||
PHYSICS_CIRCLE,
|
||||
PHYSICS_POLYGON
|
||||
}
|
||||
|
||||
// Mat2 type (used for polygon shape rotation matrix)
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
public struct Mat2
|
||||
{
|
||||
public float m00;
|
||||
public float m01;
|
||||
public float m10;
|
||||
public float m11;
|
||||
}
|
||||
|
||||
// @TODO Custom array marshall issue https://github.com/ChrisDill/Raylib-cs/issues/9
|
||||
// Hack same as raylib.cs _MaterialMap_e_FixedBuffer
|
||||
// No easy way to marshall arrays of custom types. no idea why?
|
||||
public unsafe struct _Polygon_e_FixedBuffer
|
||||
{
|
||||
public Vector2 v0;
|
||||
public Vector2 v1;
|
||||
public Vector2 v2;
|
||||
public Vector2 v3;
|
||||
public Vector2 v4;
|
||||
public Vector2 v5;
|
||||
public Vector2 v6;
|
||||
public Vector2 v7;
|
||||
public Vector2 v8;
|
||||
public Vector2 v9;
|
||||
public Vector2 v10;
|
||||
public Vector2 v11;
|
||||
public Vector2 v12;
|
||||
public Vector2 v13;
|
||||
public Vector2 v14;
|
||||
public Vector2 v15;
|
||||
public Vector2 v16;
|
||||
public Vector2 v17;
|
||||
public Vector2 v18;
|
||||
public Vector2 v19;
|
||||
public Vector2 v20;
|
||||
public Vector2 v21;
|
||||
public Vector2 v22;
|
||||
public Vector2 v23;
|
||||
public Vector2 v24;
|
||||
|
||||
public Vector2 this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
fixed (Vector2* e = &v0)
|
||||
return e[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
public struct PolygonData
|
||||
{
|
||||
public uint vertexCount; // Current used vertex and normals count
|
||||
public _Polygon_e_FixedBuffer positions; // Polygon vertex positions vectors
|
||||
public _Polygon_e_FixedBuffer normals; // Polygon vertex normals vectors
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
public struct PhysicsShape
|
||||
{
|
||||
public PhysicsShapeType type; // Physics shape type (circle or polygon)
|
||||
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)
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
public partial struct PhysicsBodyData
|
||||
{
|
||||
public uint id;
|
||||
|
||||
[MarshalAs(UnmanagedType.Bool)]
|
||||
public bool enabled;
|
||||
|
||||
public Vector2 position;
|
||||
public Vector2 velocity;
|
||||
public Vector2 force;
|
||||
public float angularVelocity;
|
||||
public float torque;
|
||||
public float orient;
|
||||
public float inertia;
|
||||
public float inverseInertia;
|
||||
public float mass;
|
||||
public float inverseMass;
|
||||
public float staticFriction;
|
||||
public float dynamicFriction;
|
||||
public float restitution;
|
||||
|
||||
[MarshalAs(UnmanagedType.Bool)]
|
||||
public bool useGravity;
|
||||
|
||||
[MarshalAs(UnmanagedType.Bool)]
|
||||
public bool isGrounded;
|
||||
|
||||
[MarshalAs(UnmanagedType.Bool)]
|
||||
public bool freezeOrient;
|
||||
|
||||
public PhysicsShape shape;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
public struct PhysicsManifoldData
|
||||
{
|
||||
public uint id; // Reference unique identifier
|
||||
public IntPtr bodyA; // Manifold first physics body reference
|
||||
public IntPtr 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 contactsA; // Points of contact during collision
|
||||
public Vector2 contactsB; // 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
|
||||
public float staticFriction; // Mixed static friction during collision
|
||||
}
|
||||
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
public static class Physac
|
||||
{
|
||||
// Used by DllImport to load the native library.
|
||||
public const string nativeLibName = "physac";
|
||||
|
||||
public const int PHYSAC_MAX_BODIES = 64;
|
||||
public const int PHYSAC_MAX_MANIFOLDS = 4096;
|
||||
public const int PHYSAC_MAX_VERTICES = 24;
|
||||
public const int PHYSAC_CIRCLE_VERTICES = 24;
|
||||
|
||||
public const int PHYSAC_COLLISION_ITERATIONS = 100;
|
||||
public const float PHYSAC_PENETRATION_ALLOWANCE = 0.05f;
|
||||
public const float PHYSAC_PENETRATION_CORRECTION = 0.4f;
|
||||
|
||||
// Initializes physics values, pointers and creates physics loop thread
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void InitPhysics();
|
||||
|
||||
// Run physics step, to be used if PHYSICS_NO_THREADS is set in your main loop
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void RunPhysicsStep();
|
||||
|
||||
// Sets physics fixed time step in milliseconds. 1.666666 by default
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void SetPhysicsTimeStep(double delta);
|
||||
|
||||
// Returns true if physics thread is currently enabled
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool IsPhysicsEnabled();
|
||||
|
||||
// Sets physics global gravity force
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void SetPhysicsGravity(float x, float y);
|
||||
|
||||
// Creates a new circle physics body with generic parameters
|
||||
// IntPtr refers to a PhysicsBodyData *
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr CreatePhysicsBodyCircle(Vector2 pos, float radius, float density);
|
||||
|
||||
// Creates a new rectangle physics body with generic parameters
|
||||
// IntPtr refers to a PhysicsBodyData *
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr CreatePhysicsBodyRectangle(Vector2 pos, float width, float height, float density);
|
||||
|
||||
// Creates a new polygon physics body with generic parameters
|
||||
// IntPtr refers to a PhysicsBodyData *
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr CreatePhysicsBodyPolygon(Vector2 pos, float radius, int sides, float density);
|
||||
|
||||
// Adds a force to a physics body
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void PhysicsAddForce(PhysicsBodyData body, Vector2 force);
|
||||
|
||||
// Adds an angular force to a physics body
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void PhysicsAddTorque(PhysicsBodyData body, float amount);
|
||||
|
||||
// Shatters a polygon shape physics body to little physics bodies with explosion force
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void PhysicsShatter(PhysicsBodyData body, Vector2 position, float force);
|
||||
|
||||
// Returns the current amount of created physics bodies
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int GetPhysicsBodiesCount();
|
||||
|
||||
// Returns a physics body of the bodies pool at a specific index
|
||||
// IntPtr refers to a PhysicsBodyData *
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr GetPhysicsBody(int index);
|
||||
|
||||
// Returns the physics body shape type (PHYSICS_CIRCLE or PHYSICS_POLYGON)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int GetPhysicsShapeType(int index);
|
||||
|
||||
// Returns the amount of vertices of a physics body shape
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int GetPhysicsShapeVerticesCount(int index);
|
||||
|
||||
// Returns transformed position of a body shape (body position + vertex transformed position)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Vector2 GetPhysicsShapeVertex(PhysicsBodyData body, int vertex);
|
||||
|
||||
// Sets physics body shape transform based on radians parameter
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void SetPhysicsBodyRotation(PhysicsBodyData body, float radians);
|
||||
|
||||
// Unitializes and destroy a physics body
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void DestroyPhysicsBody(PhysicsBodyData body);
|
||||
|
||||
// Destroys created physics bodies and manifolds and resets global values
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void ResetPhysics();
|
||||
|
||||
// Unitializes physics pointers and closes physics loop thread
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void ClosePhysics();
|
||||
}
|
||||
}
|
444
Raylib-cs/Raygui.cs
Normal file
444
Raylib-cs/Raygui.cs
Normal file
@ -0,0 +1,444 @@
|
||||
/* Raygui.cs
|
||||
*
|
||||
* Copyright 2020 Chris Dill
|
||||
*
|
||||
* Release under zLib License.
|
||||
* See LICENSE for details.
|
||||
*/
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using System.Text;
|
||||
|
||||
namespace Raylib_cs
|
||||
{
|
||||
// Style property
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
struct GuiStyleProp
|
||||
{
|
||||
ushort controlId;
|
||||
ushort propertyId;
|
||||
int propertyValue;
|
||||
}
|
||||
|
||||
// Gui global state enum
|
||||
public enum GuiControlState
|
||||
{
|
||||
GUI_STATE_NORMAL = 0,
|
||||
GUI_STATE_FOCUSED,
|
||||
GUI_STATE_PRESSED,
|
||||
GUI_STATE_DISABLED,
|
||||
}
|
||||
|
||||
// Gui global text alignment
|
||||
public enum GuiTextAlignment
|
||||
{
|
||||
GUI_TEXT_ALIGN_LEFT = 0,
|
||||
GUI_TEXT_ALIGN_CENTER,
|
||||
GUI_TEXT_ALIGN_RIGHT,
|
||||
}
|
||||
|
||||
// Gui standard controls
|
||||
public enum GuiControlStandard
|
||||
{
|
||||
DEFAULT = 0,
|
||||
LABEL, // LABELBUTTON
|
||||
BUTTON, // IMAGEBUTTON
|
||||
TOGGLE, // TOGGLEGROUP
|
||||
SLIDER, // SLIDERBAR
|
||||
PROGRESSBAR,
|
||||
CHECKBOX,
|
||||
COMBOBOX,
|
||||
DROPDOWNBOX,
|
||||
TEXTBOX, // TEXTBOXMULTI
|
||||
VALUEBOX,
|
||||
SPINNER,
|
||||
LISTVIEW,
|
||||
COLORPICKER,
|
||||
SCROLLBAR,
|
||||
STATUSBAR
|
||||
}
|
||||
|
||||
// Gui default properties for every control
|
||||
public enum GuiControlProperty
|
||||
{
|
||||
BORDER_COLOR_NORMAL = 0,
|
||||
BASE_COLOR_NORMAL,
|
||||
TEXT_COLOR_NORMAL,
|
||||
BORDER_COLOR_FOCUSED,
|
||||
BASE_COLOR_FOCUSED,
|
||||
TEXT_COLOR_FOCUSED,
|
||||
BORDER_COLOR_PRESSED,
|
||||
BASE_COLOR_PRESSED,
|
||||
TEXT_COLOR_PRESSED,
|
||||
BORDER_COLOR_DISABLED,
|
||||
BASE_COLOR_DISABLED,
|
||||
TEXT_COLOR_DISABLED,
|
||||
BORDER_WIDTH,
|
||||
TEXT_PADDING,
|
||||
TEXT_ALIGNMENT,
|
||||
RESERVED
|
||||
}
|
||||
|
||||
// Gui extended properties depending on control type
|
||||
// NOTE: We reserve a fixed size of additional properties per control
|
||||
|
||||
// Default properties
|
||||
public enum GuiDefaultProperty
|
||||
{
|
||||
TEXT_SIZE = 16,
|
||||
TEXT_SPACING,
|
||||
LINE_COLOR,
|
||||
BACKGROUND_COLOR,
|
||||
}
|
||||
|
||||
// Toggle / ToggleGroup
|
||||
public enum GuiToggleProperty
|
||||
{
|
||||
GROUP_PADDING = 16,
|
||||
}
|
||||
|
||||
// Slider / SliderBar
|
||||
public enum GuiSliderProperty
|
||||
{
|
||||
SLIDER_WIDTH = 16,
|
||||
TEXT_PADDING
|
||||
}
|
||||
|
||||
// ProgressBar
|
||||
public enum GuiProgressBarProperty
|
||||
{
|
||||
PROGRESS_PADDING = 16,
|
||||
}
|
||||
|
||||
// CheckBox
|
||||
public enum GuiCheckBoxProperty
|
||||
{
|
||||
CHECK_PADDING = 16
|
||||
}
|
||||
|
||||
// ComboBox
|
||||
public enum GuiComboBoxProperty
|
||||
{
|
||||
SELECTOR_WIDTH = 16,
|
||||
SELECTOR_PADDING
|
||||
}
|
||||
|
||||
// DropdownBox
|
||||
public enum GuiDropdownBoxProperty
|
||||
{
|
||||
ARROW_PADDING = 16,
|
||||
DROPDOWN_ITEMS_PADDING
|
||||
}
|
||||
|
||||
// TextBox / TextBoxMulti / ValueBox / Spinner
|
||||
public enum GuiTextBoxProperty
|
||||
{
|
||||
TEXT_INNER_PADDING = 16,
|
||||
TEXT_LINES_PADDING,
|
||||
COLOR_SELECTED_FG,
|
||||
COLOR_SELECTED_BG
|
||||
}
|
||||
|
||||
// Spinner
|
||||
public enum GuiSpinnerProperty
|
||||
{
|
||||
SPIN_BUTTON_WIDTH = 16,
|
||||
SPIN_BUTTON_PADDING,
|
||||
}
|
||||
|
||||
// ScrollBar
|
||||
public enum GuiScrollBarProperty
|
||||
{
|
||||
ARROWS_SIZE = 16,
|
||||
ARROWS_VISIBLE,
|
||||
SCROLL_SLIDER_PADDING,
|
||||
SCROLL_SLIDER_SIZE,
|
||||
SCROLL_PADDING,
|
||||
SCROLL_SPEED,
|
||||
}
|
||||
|
||||
// ScrollBar side
|
||||
public enum GuiScrollBarSide
|
||||
{
|
||||
SCROLLBAR_LEFT_SIDE = 0,
|
||||
SCROLLBAR_RIGHT_SIDE
|
||||
}
|
||||
|
||||
// ListView
|
||||
public enum GuiListViewProperty
|
||||
{
|
||||
LIST_ITEMS_HEIGHT = 16,
|
||||
LIST_ITEMS_PADDING,
|
||||
SCROLLBAR_WIDTH,
|
||||
SCROLLBAR_SIDE,
|
||||
}
|
||||
|
||||
// ColorPicker
|
||||
public enum GuiColorPickerProperty
|
||||
{
|
||||
COLOR_SELECTOR_SIZE = 16,
|
||||
HUEBAR_WIDTH, // Right hue bar width
|
||||
HUEBAR_PADDING, // Right hue bar separation from panel
|
||||
HUEBAR_SELECTOR_HEIGHT, // Right hue bar selector height
|
||||
HUEBAR_SELECTOR_OVERFLOW // Right hue bar selector overflow
|
||||
}
|
||||
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
public static class Raygui
|
||||
{
|
||||
// Used by DllImport to load the native library.
|
||||
public const string nativeLibName = "raygui";
|
||||
|
||||
public const string RAYGUI_VERSION = "2.6-dev";
|
||||
|
||||
public const int NUM_CONTROLS = 16; // Number of standard controls
|
||||
public const int NUM_PROPS_DEFAULT = 16; // Number of standard properties
|
||||
public const int NUM_PROPS_EXTENDED = 8; // Number of extended properties
|
||||
|
||||
public const int TEXTEDIT_CURSOR_BLINK_FRAMES = 20; // Text edit controls cursor blink timming
|
||||
|
||||
// Global gui modification functions
|
||||
|
||||
// Enable gui controls (global state)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void GuiEnable();
|
||||
|
||||
// Disable gui controls (global state)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void GuiDisable();
|
||||
|
||||
// Lock gui controls (global state)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void GuiLock();
|
||||
|
||||
// Unlock gui controls (global state)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void GuiUnlock();
|
||||
|
||||
// Set gui controls alpha (global state), alpha goes from 0.0f to 1.0f
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void GuiFade(float alpha);
|
||||
|
||||
// Set gui state (global state)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void GuiSetState(int state);
|
||||
|
||||
// Get gui state (global state)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int GuiGetState();
|
||||
|
||||
// Get gui custom font (global state)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void GuiSetFont(Font font);
|
||||
|
||||
// Set gui custom font (global state)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Font GuiGetFont();
|
||||
|
||||
|
||||
// Style set/get functions
|
||||
|
||||
// Set one style property
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void GuiSetStyle(GuiControlStandard control, GuiControlProperty property, int value);
|
||||
|
||||
// Get one style property
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int GuiGetStyle(GuiControlStandard control, GuiControlProperty property);
|
||||
|
||||
|
||||
// Container/separator controls, useful for controls organization
|
||||
|
||||
// Window Box control, shows a window that can be closed
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool GuiWindowBox(Rectangle bounds, string text);
|
||||
|
||||
// Group Box control with title name
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void GuiGroupBox(Rectangle bounds, string text);
|
||||
|
||||
// Line separator control
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void GuiLine(Rectangle bounds, string text);
|
||||
|
||||
// Panel control, useful to group controls
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void GuiPanel(Rectangle bounds);
|
||||
|
||||
// Scroll Panel control
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Rectangle GuiScrollPanel(Rectangle bounds, Rectangle content, ref Vector2 scroll);
|
||||
|
||||
|
||||
// Basic controls set
|
||||
|
||||
// Label control, shows text
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void GuiLabel(Rectangle bounds, string text);
|
||||
|
||||
// Button control, returns true when clicked
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool GuiButton(Rectangle bounds, string text);
|
||||
|
||||
// Label button control, show true when clicked
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool GuiLabelButton(Rectangle bounds, string text);
|
||||
|
||||
// Image button control, returns true when clicked
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool GuiImageButton(Rectangle bounds, Texture2D texture);
|
||||
|
||||
// Image button extended control, returns true when clicked
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool GuiImageButtonEx(Rectangle bounds, Texture2D texture, Rectangle texSource, string text);
|
||||
|
||||
// Toggle Button control, returns true when active
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool GuiToggle(Rectangle bounds, string text, bool active);
|
||||
|
||||
// Toggle Group control, returns active toggle index
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int GuiToggleGroup(Rectangle bounds, string text, int active);
|
||||
|
||||
// Check Box control, returns true when active
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool GuiCheckBox(Rectangle bounds, bool isChecked);
|
||||
|
||||
// Combo Box control, returns selected item index
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int GuiComboBox(Rectangle bounds, string text, int active);
|
||||
|
||||
// Dropdown Box control, returns selected item
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool GuiDropdownBox(Rectangle bounds, string[] text, ref int active, bool edit);
|
||||
|
||||
// Spinner control, returns selected value
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool GuiSpinner(Rectangle bounds, ref int value, int maxValue, int btnWidth);
|
||||
|
||||
// Value Box control, updates input text with numbers
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool GuiValueBox(Rectangle bounds, int value, int maxValue);
|
||||
|
||||
// Text Box control, updates input text
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool GuiTextBox(Rectangle bounds, StringBuilder text, int textSize, bool freeEdit);
|
||||
|
||||
// Text Box control with multiple lines
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool GuiTextBoxMulti(Rectangle bounds, StringBuilder text, int textSize, bool editMode);
|
||||
|
||||
// Slider control, returns selected value
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern float GuiSlider(Rectangle bounds, float value, float minValue, float maxValue, bool showValue);
|
||||
|
||||
// Slider Bar control, returns selected value
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern float GuiSliderBar(Rectangle bounds, float value, float minValue, float maxValue, bool showValue);
|
||||
|
||||
// Progress Bar control, shows current progress value
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern float GuiProgressBar(Rectangle bounds, float value, float minValue, float maxValue, bool showValue);
|
||||
|
||||
// Progress Bar control, shows current progress value
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern float GuiProgressBarEx(Rectangle bounds, float value, float minValue, float maxValue, bool showValue);
|
||||
|
||||
// Status Bar control, shows info text
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void GuiStatusBar(Rectangle bounds, string text);
|
||||
|
||||
// Dummy control for placeholders
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void GuiDummyRec(Rectangle bounds, string text);
|
||||
|
||||
// Scroll Bar control
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void GuiScrollBar(Rectangle bounds, int value, int minValue, int maxValue);
|
||||
|
||||
// Grid
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void GuiGrid(Rectangle bounds, float spacing, int subdivs);
|
||||
|
||||
|
||||
// Advance controls set
|
||||
|
||||
// List View control, returns selected list element index
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int GuiListView(Rectangle bounds, string text, ref int active, ref int scrollIndex, bool editMode);
|
||||
|
||||
// List View with extended parameters
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int GuiListViewEx(Rectangle bounds, string text, int count, ref int enabled, ref int active, ref int focus, ref int scrollIndex, bool editMode);
|
||||
|
||||
// Message Box control, displays a message
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool GuiMessageBox(Rectangle bounds, string windowTitle, string message);
|
||||
|
||||
// Text Input Box control, ask for text
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool GuiTextInputBox(Rectangle bounds, string windowTitle, string message, string buttons);
|
||||
|
||||
// Color Picker control
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Color GuiColorPicker(Rectangle bounds, Color color);
|
||||
|
||||
|
||||
// Styles loading functions
|
||||
|
||||
// Load style file (.rgs)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int GuiLoadStyle(string fileName);
|
||||
|
||||
// Load style default over global style
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool GuiLoadStyleDefault();
|
||||
|
||||
// Get text with icon id prepended
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern string GuiIconText(int iconId, string text);
|
||||
|
||||
|
||||
// Gui icons functionality
|
||||
|
||||
// Get full icons data pointer
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern uint[] GuiGetIcons();
|
||||
|
||||
// Get icon bit data
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern uint[] GuiGetIconData(int iconId, string text);
|
||||
|
||||
// Set icon bit data
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void GuiSetIconData(int iconId, uint[] data);
|
||||
|
||||
// Set icon pixel value
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern string GuiSetIconPixel(int iconId, int x, int y);
|
||||
|
||||
// Clear icon pixel value
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern string GuiClearIconPixel(int iconId, int x, int y);
|
||||
|
||||
// Check icon pixel value
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern string GuiCheckIconPixel(int iconId, int x, int y);
|
||||
}
|
||||
}
|
3158
Raylib-cs/Raylib.cs
Normal file
3158
Raylib-cs/Raylib.cs
Normal file
File diff suppressed because it is too large
Load Diff
361
Raylib-cs/Raymath.cs
Normal file
361
Raylib-cs/Raymath.cs
Normal file
@ -0,0 +1,361 @@
|
||||
/* Raymath.cs
|
||||
*
|
||||
* Copyright 2020 Chris Dill
|
||||
*
|
||||
* Release under zLib License.
|
||||
* See LICENSE for details.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using Quaternion = Raylib_cs.Vector4;
|
||||
|
||||
namespace Raylib_cs
|
||||
{
|
||||
// NOTE: Helper types to be used instead of array return types for *ToFloat functions
|
||||
public struct float3
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 7)]
|
||||
public float[] v;
|
||||
}
|
||||
|
||||
public struct float16
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 7)]
|
||||
public float[] v;
|
||||
}
|
||||
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
public static class Raymath
|
||||
{
|
||||
// Used by DllImport to load the native library.
|
||||
public const string nativeLibName = "raylib";
|
||||
|
||||
// Clamp float value
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern float Clamp(float value, float min, float max);
|
||||
|
||||
// Calculate linear interpolation between two vectors
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern float Lerp(float start, float end, float amount);
|
||||
|
||||
// Vector with components value 0.0f
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Vector2 Vector2Zero();
|
||||
|
||||
// Vector with components value 1.0f
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Vector2 Vector2One();
|
||||
|
||||
// Add two vectors (v1 + v2)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Vector2 Vector2Add(Vector2 v1, Vector2 v2);
|
||||
|
||||
// Subtract two vectors (v1 - v2)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Vector2 Vector2Subtract(Vector2 v1, Vector2 v2);
|
||||
|
||||
// Calculate vector length
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern float Vector2Length(Vector2 v);
|
||||
|
||||
// Calculate two vectors dot product
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern float Vector2DotProduct(Vector2 v1, Vector2 v2);
|
||||
|
||||
// Calculate distance between two vectors
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern float Vector2Distance(Vector2 v1, Vector2 v2);
|
||||
|
||||
// Calculate angle from two vectors in X-axis
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern float Vector2Angle(Vector2 v1, Vector2 v2);
|
||||
|
||||
// Scale vector (multiply by value)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Vector2 Vector2Scale(Vector2 v, float scale);
|
||||
|
||||
// Multiply vector by 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);
|
||||
|
||||
// Divide vector by a float value
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Vector2 Vector2Divide(Vector2 v, float div);
|
||||
|
||||
// Divide vector by 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);
|
||||
|
||||
// Calculate linear interpolation between two vectors
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Vector2 Vector2Lerp(Vector2 v1, Vector2 v2, float amount);
|
||||
|
||||
// Vector with components value 0.0f
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Vector3 Vector3Zero();
|
||||
|
||||
// Vector with components value 1.0f
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Vector3 Vector3One();
|
||||
|
||||
// Add two vectors
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Vector3 Vector3Add(Vector3 v1, Vector3 v2);
|
||||
|
||||
// Subtract two vectors
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Vector3 Vector3Subtract(Vector3 v1, Vector3 v2);
|
||||
|
||||
// Multiply vector by scalar
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Vector3 Vector3Multiply(Vector3 v, float scalar);
|
||||
|
||||
// Multiply vector by vector
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Vector3 Vector3MultiplyV(Vector3 v1, Vector3 v2);
|
||||
|
||||
// Calculate two vectors cross product
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Vector3 Vector3CrossProduct(Vector3 v1, Vector3 v2);
|
||||
|
||||
// Calculate one vector perpendicular vector
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Vector3 Vector3Perpendicular(Vector3 v);
|
||||
|
||||
// Calculate vector length
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern float Vector3Length(Vector3 v);
|
||||
|
||||
// Calculate two vectors dot product
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern float Vector3DotProduct(Vector3 v1, Vector3 v2);
|
||||
|
||||
// Calculate distance between two vectors
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern float Vector3Distance(Vector3 v1, Vector3 v2);
|
||||
|
||||
// Scale provided vector
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Vector3 Vector3Scale(Vector3 v, float scale);
|
||||
|
||||
// Negate provided vector (invert direction)
|
||||
[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 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);
|
||||
|
||||
// Orthonormalize provided vectors
|
||||
// Makes vectors normalized and orthogonal to each other
|
||||
// Gram-Schmidt function implementation
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Vector3OrthoNormalize(ref Vector3 v1, ref Vector3 v2);
|
||||
|
||||
// Transforms a Vector3 by a given Matrix
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Vector3 Vector3Transform(Vector3 v, Matrix mat);
|
||||
|
||||
// Transform a vector by quaternion rotation
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Vector3 Vector3RotateByQuaternion(Vector3 v, Quaternion q);
|
||||
|
||||
// Calculate linear interpolation between two vectors
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Vector3 Vector3Lerp(Vector3 v1, Vector3 v2, float amount);
|
||||
|
||||
// Calculate reflected vector to normal
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Vector3 Vector3Reflect(Vector3 v, Vector3 normal);
|
||||
|
||||
// Return min value for each pair of components
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Vector3 Vector3Min(Vector3 v1, Vector3 v2);
|
||||
|
||||
// Return max value for each pair of components
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Vector3 Vector3Max(Vector3 v1, Vector3 v2);
|
||||
|
||||
// Compute barycenter coordinates (u, v, w) for point p with respect to triangle (a, b, c)
|
||||
// NOTE: Assumes P is on the plane of the triangle
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Vector3 Vector3Barycenter(Vector3 p, Vector3 a, Vector3 b, Vector3 c);
|
||||
|
||||
// Returns Vector3 as float array
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern float3 Vector3ToFloatV(Vector3 v);
|
||||
|
||||
// Compute matrix determinant
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern float MatrixDeterminant(Matrix mat);
|
||||
|
||||
// Returns the trace of the matrix (sum of the values along the diagonal)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern float MatrixTrace(Matrix mat);
|
||||
|
||||
// Transposes provided matrix
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Matrix MatrixTranspose(Matrix mat);
|
||||
|
||||
// Invert provided matrix
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Matrix MatrixInvert(Matrix mat);
|
||||
|
||||
// Normalize provided matrix
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Matrix MatrixNormalize(Matrix mat);
|
||||
|
||||
// Returns identity matrix
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Matrix MatrixIdentity();
|
||||
|
||||
// Add two matrices
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Matrix MatrixAdd(Matrix left, Matrix right);
|
||||
|
||||
// Subtract two matrices (left - right)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Matrix MatrixSubtract(Matrix left, Matrix right);
|
||||
|
||||
// Returns translation matrix
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Matrix MatrixTranslate(float x, float y, float z);
|
||||
|
||||
// Create rotation matrix from axis and angle
|
||||
// NOTE: Angle should be provided in radians
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Matrix MatrixRotate(Vector3 axis, float angle);
|
||||
|
||||
// Returns xyz-rotation matrix (angles in radians)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Matrix MatrixRotateXYZ(Vector3 ang);
|
||||
|
||||
// Returns x-rotation matrix (angle in radians)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Matrix MatrixRotateX(float angle);
|
||||
|
||||
// Returns y-rotation matrix (angle in radians)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Matrix MatrixRotateY(float angle);
|
||||
|
||||
// Returns z-rotation matrix (angle in radians)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Matrix MatrixRotateZ(float angle);
|
||||
|
||||
// Returns scaling matrix
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Matrix MatrixScale(float x, float y, float z);
|
||||
|
||||
// Returns two matrix multiplication
|
||||
// NOTE: When multiplying matrices... the order matters!
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Matrix MatrixMultiply(Matrix left, Matrix right);
|
||||
|
||||
// Returns perspective projection matrix
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Matrix MatrixFrustum(double left, double right, double bottom, double top, double near, double far);
|
||||
|
||||
// Returns perspective projection matrix
|
||||
// NOTE: Angle should be provided in radians
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Matrix MatrixPerspective(double fovy, double aspect, double near, double far);
|
||||
|
||||
// Returns orthographic projection matrix
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Matrix MatrixOrtho(double left, double right, double bottom, double top, double near, double far);
|
||||
|
||||
// Returns camera look-at matrix (view matrix)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Matrix MatrixLookAt(Vector3 eye, Vector3 target, Vector3 up);
|
||||
|
||||
// Returns float array of matrix data
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern float16 MatrixToFloatV(Matrix mat);
|
||||
|
||||
// Returns identity quaternion
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Quaternion QuaternionIdentity();
|
||||
|
||||
// Computes the length of a quaternion
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern float QuaternionLength(Quaternion q);
|
||||
|
||||
// Normalize provided quaternion
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Quaternion QuaternionNormalize(Quaternion q);
|
||||
|
||||
// Invert provided quaternion
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Quaternion QuaternionInvert(Quaternion q);
|
||||
|
||||
// Calculate two quaternion multiplication
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Quaternion QuaternionMultiply(Quaternion q1, Quaternion q2);
|
||||
|
||||
// Calculate linear interpolation between two quaternions
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Quaternion QuaternionLerp(Quaternion q1, Quaternion q2, float amount);
|
||||
|
||||
// Calculate slerp-optimized interpolation between two quaternions
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Quaternion QuaternionNlerp(Quaternion q1, Quaternion q2, float amount);
|
||||
|
||||
// Calculates spherical linear interpolation between two quaternions
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Quaternion QuaternionSlerp(Quaternion q1, Quaternion q2, float amount);
|
||||
|
||||
// Calculate quaternion based on the rotation from one vector to another
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Quaternion QuaternionFromVector3ToVector3(Vector3 from, Vector3 to);
|
||||
|
||||
// Returns a quaternion for a given rotation matrix
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Quaternion QuaternionFromMatrix(Matrix mat);
|
||||
|
||||
// Returns a matrix for a given quaternion
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Matrix QuaternionToMatrix(Quaternion q);
|
||||
|
||||
// Returns rotation quaternion for an angle and axis
|
||||
// NOTE: angle must be provided in radians
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Quaternion QuaternionFromAxisAngle(Vector3 axis, float angle);
|
||||
|
||||
// Returns the rotation angle and axis for a given quaternion
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void QuaternionToAxisAngle(Quaternion q, ref Vector3 outAxis, ref float outAngle);
|
||||
|
||||
// Returns he quaternion equivalent to Euler angles
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Quaternion QuaternionFromEuler(float roll, float pitch, float yaw);
|
||||
|
||||
// Return the Euler angles equivalent to quaternion (roll, pitch, yaw)
|
||||
// NOTE: Angles are returned in a Vector3 struct in degrees
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Vector3 QuaternionToEuler(Quaternion q);
|
||||
|
||||
// Transform a quaternion given a transformation matrix
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Quaternion QuaternionTransform(Quaternion q, Matrix mat);
|
||||
}
|
||||
}
|
363
Raylib-cs/Rlgl.cs
Normal file
363
Raylib-cs/Rlgl.cs
Normal file
@ -0,0 +1,363 @@
|
||||
/* Rlgl.cs
|
||||
*
|
||||
* Copyright 2020 Chris Dill
|
||||
*
|
||||
* Release under zLib License.
|
||||
* See LICENSE for details.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
namespace Raylib_cs
|
||||
{
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Types and Structures Definition
|
||||
// ----------------------------------------------------------------------------------
|
||||
public enum GlVersion
|
||||
{
|
||||
OPENGL_11 = 1,
|
||||
OPENGL_21,
|
||||
OPENGL_33,
|
||||
OPENGL_ES_20
|
||||
}
|
||||
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
public static class Rlgl
|
||||
{
|
||||
// Used by DllImport to load the native library.
|
||||
public const string nativeLibName = "raylib";
|
||||
|
||||
public const float MAX_BATCH_ELEMENTS = 8192;
|
||||
public const float MAX_BATCH_BUFFERING = 1;
|
||||
public const float MAX_MATRIX_STACK_SIZE = 32;
|
||||
public const float MAX_DRAWCALL_REGISTERED = 256;
|
||||
public const float DEFAULT_NEAR_CULL_DISTANCE = 0.01f;
|
||||
public const float DEFAULT_FAR_CULL_DISTANCE = 1000.0f;
|
||||
public const int RL_TEXTURE_WRAP_S = 0x2802;
|
||||
public const int RL_TEXTURE_WRAP_T = 0x2803;
|
||||
public const int RL_TEXTURE_MAG_FILTER = 0x2800;
|
||||
public const int RL_TEXTURE_MIN_FILTER = 0x2801;
|
||||
public const int RL_TEXTURE_ANISOTROPIC_FILTER = 0x3000;
|
||||
public const int RL_FILTER_NEAREST = 0x2600;
|
||||
public const int RL_FILTER_LINEAR = 0x2601;
|
||||
public const int RL_FILTER_MIP_NEAREST = 0x2700;
|
||||
public const int RL_FILTER_NEAREST_MIP_LINEAR = 0x2702;
|
||||
public const int RL_FILTER_LINEAR_MIP_NEAREST = 0x2701;
|
||||
public const int RL_FILTER_MIP_LINEAR = 0x2703;
|
||||
public const int RL_WRAP_REPEAT = 0x2901;
|
||||
public const int RL_WRAP_CLAMP = 0x812F;
|
||||
public const int RL_WRAP_MIRROR_REPEAT = 0x8370;
|
||||
public const int RL_WRAP_MIRROR_CLAMP = 0x8742;
|
||||
public const int RL_MODELVIEW = 0x1700;
|
||||
public const int RL_PROJECTION = 0x1701;
|
||||
public const int RL_TEXTURE = 0x1702;
|
||||
public const int RL_LINES = 0x0001;
|
||||
public const int RL_TRIANGLES = 0x0004;
|
||||
public const int RL_QUADS = 0x0007;
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
// Functions Declaration - Matrix operations
|
||||
// ------------------------------------------------------------------------------------
|
||||
|
||||
// Choose the current matrix to be transformed
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlMatrixMode(int mode);
|
||||
|
||||
// Push the current matrix to stack
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlPushMatrix();
|
||||
|
||||
// Pop lattest inserted matrix from stack
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlPopMatrix();
|
||||
|
||||
// Reset current matrix to identity matrix
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlLoadIdentity();
|
||||
|
||||
// Multiply the current matrix by a translation matrix
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlTranslatef(float x, float y, float z);
|
||||
|
||||
// Multiply the current matrix by a rotation matrix
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlRotatef(float angleDeg, float x, float y, float z);
|
||||
|
||||
// Multiply the current matrix by a scaling matrix
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlScalef(float x, float y, float z);
|
||||
|
||||
// Multiply the current matrix by another matrix
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlMultMatrixf(ref float[] matf);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlFrustum(double left, double right, double bottom, double top, double znear, double zfar);
|
||||
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlOrtho(double left, double right, double bottom, double top, double znear, double zfar);
|
||||
|
||||
// Set the viewport area
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlViewport(int x, int y, int width, int height);
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
// Functions Declaration - Vertex level operations
|
||||
// ------------------------------------------------------------------------------------
|
||||
|
||||
// Initialize drawing mode (how to organize vertex)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlBegin(int mode);
|
||||
|
||||
// Finish vertex providing
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlEnd();
|
||||
|
||||
// Define one vertex (position) - 2 int
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlVertex2i(int x, int y);
|
||||
|
||||
// Define one vertex (position) - 2 float
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlVertex2f(float x, float y);
|
||||
|
||||
// Define one vertex (position) - 3 float
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlVertex3f(float x, float y, float z);
|
||||
|
||||
// Define one vertex (texture coordinate) - 2 float
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlTexCoord2f(float x, float y);
|
||||
|
||||
// Define one vertex (normal) - 3 float
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlNormal3f(float x, float y, float z);
|
||||
|
||||
// Define one vertex (color) - 4 byte
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlColor4ub(byte r, byte g, byte b, byte a);
|
||||
|
||||
// Define one vertex (color) - 3 float
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlColor3f(float x, float y, float z);
|
||||
|
||||
// Define one vertex (color) - 4 float
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlColor4f(float x, float y, float z, float w);
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
// Functions Declaration - OpenGL equivalent functions (common to 1.1, 3.3+, ES2)
|
||||
// NOTE: This functions are used to completely abstract raylib code from OpenGL layer
|
||||
// ------------------------------------------------------------------------------------
|
||||
|
||||
// Enable texture usage
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlEnableTexture(uint id);
|
||||
|
||||
// Disable texture usage
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlDisableTexture();
|
||||
|
||||
// Set texture parameters (filter, wrap)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlTextureParameters(uint id, int param, int value);
|
||||
|
||||
// Enable render texture (fbo)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlEnableRenderTexture(uint id);
|
||||
|
||||
// Disable render texture (fbo), return to default framebuffer
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlDisableRenderTexture();
|
||||
|
||||
// Enable depth test
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlEnableDepthTest();
|
||||
|
||||
// Disable depth test
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlDisableDepthTest();
|
||||
|
||||
// Enable backface culling
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlEnableBackfaceCulling();
|
||||
|
||||
// Disable backface culling
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlDisableBackfaceCulling();
|
||||
|
||||
// Enable scissor test
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlEnableScissorTest();
|
||||
|
||||
// Disable scissor test
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlDisableScissorTest();
|
||||
|
||||
// Scissor test
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlScissor(int x, int y, int width, int height);
|
||||
|
||||
// Enable wire mode
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlEnableWireMode();
|
||||
|
||||
// Disable wire mode
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlDisableWireMode();
|
||||
|
||||
// Delete OpenGL texture from GPU
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlDeleteTextures(uint id);
|
||||
|
||||
// Delete render textures (fbo) from GPU
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlDeleteRenderTextures(RenderTexture2D target);
|
||||
|
||||
// Delete OpenGL shader program from GPU
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlDeleteShader(uint id);
|
||||
|
||||
// Unload vertex data (VAO) from GPU memory
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlDeleteVertexArrays(uint id);
|
||||
|
||||
// Unload vertex data (VBO) from GPU memory
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlDeleteBuffers(uint id);
|
||||
|
||||
// Clear color buffer with color
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlClearColor(byte r, byte g, byte b, byte a);
|
||||
|
||||
// Clear used screen buffers (color and depth)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlClearScreenBuffers();
|
||||
|
||||
// Update GPU buffer with new data
|
||||
// data refers to a void *
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlUpdateBuffer(int bufferId, IntPtr data, int dataSize);
|
||||
|
||||
// Load a new attributes buffer
|
||||
// buffer refers to a void *
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern uint rlLoadAttribBuffer(uint vaoId, int shaderLoc, IntPtr buffer, int size, bool dynamic);
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
// Functions Declaration - rlgl functionality
|
||||
// ------------------------------------------------------------------------------------
|
||||
|
||||
// Initialize rlgl (buffers, shaders, textures, states)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlglInit(int width, int height);
|
||||
|
||||
// De-inititialize rlgl (buffers, shaders, textures)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlglClose();
|
||||
|
||||
// Update and draw default internal buffers
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlglDraw();
|
||||
|
||||
// Returns current OpenGL version
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern GlVersion rlGetVersion();
|
||||
|
||||
// Check internal buffer overflow for a given number of vertex
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool rlCheckBufferLimit(int vCount);
|
||||
|
||||
// Set debug marker for analysis
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlSetDebugMarker(string text);
|
||||
|
||||
// Load OpenGL extensions
|
||||
// loader refers to a void *
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlLoadExtensions(IntPtr loader);
|
||||
|
||||
// Get world coordinates from screen coordinates
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Vector3 rlUnproject(Vector3 source, Matrix proj, Matrix view);
|
||||
|
||||
// Textures data management
|
||||
// Load texture in GPU
|
||||
// data refers to a void *
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern uint rlLoadTexture(IntPtr data, int width, int height, int format, int mipmapCount);
|
||||
|
||||
// Load depth texture/renderbuffer (to be attached to fbo)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern uint rlLoadTextureDepth(int width, int height, int bits, bool useRenderBuffer);
|
||||
|
||||
// Load texture cubemap
|
||||
// data refers to a void *
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern uint rlLoadTextureCubemap(IntPtr data, int size, int format);
|
||||
|
||||
// Update GPU texture with new data
|
||||
// data refers to a const void *
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlUpdateTexture(uint id, int width, int height, int format, IntPtr data);
|
||||
|
||||
// Get OpenGL internal formats
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlGetGlTextureFormats(int format, ref uint glInternalFormat, ref uint glFormat, ref uint glType);
|
||||
|
||||
// Unload texture from GPU memory
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlUnloadTexture(uint id);
|
||||
|
||||
// Generate mipmap data for selected texture
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlGenerateMipmaps(ref Texture2D texture);
|
||||
|
||||
// Read texture pixel data
|
||||
// IntPtr refers to a void *
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr rlReadTexturePixels(Texture2D texture);
|
||||
|
||||
// Read screen pixel data (color buffer)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern byte[] rlReadScreenPixels(int width, int height);
|
||||
|
||||
// Render texture management (fbo)
|
||||
// Load a render texture (with color and depth attachments)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern RenderTexture2D rlLoadRenderTexture(int width, int height, int format, int depthBits, bool useDepthTexture);
|
||||
|
||||
// Attach texture/renderbuffer to an fbo
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlRenderTextureAttach(RenderTexture2D target, uint id, int attachType);
|
||||
|
||||
// Verify render texture is complete
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool rlRenderTextureComplete(RenderTexture2D target);
|
||||
|
||||
// Vertex data management
|
||||
// Upload vertex data into GPU and provided VAO/VBO ids
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlLoadMesh(ref Mesh mesh, bool dynamic);
|
||||
|
||||
// Update vertex or index data on GPU (upload new data to one buffer)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlUpdateMesh(Mesh mesh, int buffer, int num);
|
||||
|
||||
// Update vertex or index data on GPU, at index
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlUpdateMeshAt(Mesh mesh, int buffer, int num, int index);
|
||||
|
||||
// Draw a 3d mesh with material and transform
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlDrawMesh(Mesh mesh, Material material, Matrix transform);
|
||||
|
||||
// Unload mesh data from CPU and GPU
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void rlUnloadMesh(Mesh mesh);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user