From 5a198187ec4a573f91589f33afe29f27fd9e626d Mon Sep 17 00:00:00 2001
From: Ben Parsons <9parsonsb@gmail.com>
Date: Sun, 5 Dec 2021 21:11:55 +1100
Subject: [PATCH] Create rlMultMatrixf safe overload
---
Raylib-cs/Rlgl.cs | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/Raylib-cs/Rlgl.cs b/Raylib-cs/Rlgl.cs
index 1c7157c..1a1273f 100644
--- a/Raylib-cs/Rlgl.cs
+++ b/Raylib-cs/Rlgl.cs
@@ -1,6 +1,7 @@
using System;
using System.ComponentModel;
using System.Numerics;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
@@ -95,10 +96,28 @@ namespace Raylib_cs
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void rlScalef(float x, float y, float z);
- /// Multiply the current matrix by another matrix
+ ///
+ /// Multiply the current matrix by another matrix
+ ///
+ /// Current Matrix can be set via
+ ///
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void rlMultMatrixf(float* matf);
+ public static void rlMultMatrixf(ref Matrix4x4 matf)
+ {
+ var pinned = new GCHandle();
+ try
+ {
+ pinned = GCHandle.Alloc(matf, GCHandleType.Pinned);
+ rlMultMatrixf((float*)pinned.AddrOfPinnedObject());
+ }
+ finally
+ {
+ pinned.Free();
+ }
+ }
+
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void rlFrustum(double left, double right, double bottom, double top, double znear, double zfar);