Browse Source

Exposed GUICanvas to C# code

BearishSun 9 years ago
parent
commit
f306536e2d

+ 1 - 0
Source/BansheeEngine/Include/BsPrerequisites.h

@@ -168,6 +168,7 @@ namespace BansheeEngine
 	class GUISliderVert;
 	class GUISliderHorz;
 	class GUIProgressBar;
+	class GUICanvas;
 
 	class RenderableHandler;
 	class ProfilerOverlay;

+ 1 - 1
Source/MBansheeEditor/Windows/Library/LibraryGUIEntry.cs

@@ -85,7 +85,7 @@ namespace BansheeEditor
 
             SpriteTexture iconTexture = GetIcon(path, owner.TileSize);
 
-            icon = new GUITexture(iconTexture, GUIImageScaleMode.ScaleToFit,
+            icon = new GUITexture(iconTexture, GUITextureScaleMode.ScaleToFit,
                 true, GUIOption.FixedHeight(owner.TileSize), GUIOption.FixedWidth(owner.TileSize));
 
             label = null;

+ 262 - 0
Source/MBansheeEngine/GUI/GUICanvas.cs

@@ -0,0 +1,262 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+using System;
+using System.Runtime.CompilerServices;
+
+namespace BansheeEngine
+{
+    /** @addtogroup GUI-Engine
+     *  @{
+     */
+
+    /// <summary>
+    /// A GUI element that allows the user to draw custom graphics. All drawn elements relative to the canvas, to its origin
+    /// in the top left corner.
+    /// </summary>
+    public sealed class GUICanvas : GUIElement
+    {
+        /// <summary>
+        /// Creates a new canvas element.
+        /// </summary>
+        /// <param name="style">Optional style to use for the element. Style controls the look of the element, as well as 
+        ///                     default layout options. Style will be retrieved from the active GUISkin. If not specified 
+        ///                     default element style is used.</param>
+        /// <param name="options">Options that allow you to control how is the element  positioned and sized. This will 
+        ///                       override any similar options set by style.</param>
+        public GUICanvas(string style, params GUIOption[] options)
+        {
+            Internal_CreateInstance(this, style, options);
+        }
+
+        /// <summary>
+        /// Creates a new canvas element.
+        /// </summary>
+        /// <param name="style">Optional style to use for the element. Style controls the look of the element, as well as 
+        ///                     default layout options. Style will be retrieved from the active GUISkin. If not specified 
+        ///                     default element style is used.</param>
+        public GUICanvas(string style = "")
+        {
+            Internal_CreateInstance(this, style, new GUIOption[0]);
+        }
+
+        /// <summary>
+        /// Creates a new canvas element.
+        /// </summary>
+        /// <param name="options">Options that allow you to control how is the element positioned and sized. This will 
+        ///                       override any similar options set by style.</param>
+        public GUICanvas(params GUIOption[] options)
+        {
+            Internal_CreateInstance(this, "", options);
+        }
+
+        /// <summary>
+        /// Draws a line going from <paramref name="a"/> to <paramref name="b"/>.
+        /// </summary>
+        /// <param name="a">Starting point of the line, relative to the canvas origin (top-left).</param>
+        /// <param name="b">Ending point of the line, relative to the canvas origin (top-left).</param>
+        /// <param name="width">Color of the line.</param>
+        public void DrawLine(Vector2I a, Vector2I b, float width = 1.0f)
+        {
+            Color color = Color.White;
+            Internal_DrawLine(mCachedPtr, ref a, ref b, width, ref color);
+        }
+
+        /// <summary>
+        /// Draws a line going from <paramref name="a"/> to <paramref name="b"/>.
+        /// </summary>
+        /// <param name="a">Starting point of the line, relative to the canvas origin (top-left).</param>
+        /// <param name="b">Ending point of the line, relative to the canvas origin (top-left).</param>
+        /// <param name="color">Width of the line, in pixels.</param>
+        /// <param name="width">Color of the line.</param>
+        public void DrawLine(Vector2I a, Vector2I b, Color color, float width = 1.0f)
+        {
+            Internal_DrawLine(mCachedPtr, ref a, ref b, width, ref color);
+        }
+
+        /// <summary>
+        /// Draws multiple lines following the path by the provided vertices. First vertex connects to the second vertex,
+        /// and every following vertex connects to the previous vertex.
+        /// </summary>
+        /// <param name="vertices">Points to use for drawing the line. Must have at least two elements. All points are 
+        ///                        relative to the canvas origin(top-left).</param>
+        /// <param name="width">Width of the line, in pixels.</param>
+        public void DrawPolyLine(Vector2I[] vertices, float width = 1.0f)
+        {
+            Color color = Color.White;
+            Internal_DrawPolyLine(mCachedPtr, vertices, width, ref color);
+        }
+
+        /// <summary>
+        /// Draws multiple lines following the path by the provided vertices. First vertex connects to the second vertex,
+        /// and every following vertex connects to the previous vertex.
+        /// </summary>
+        /// <param name="vertices">Points to use for drawing the line. Must have at least two elements. All points are 
+        ///                        relative to the canvas origin(top-left).</param>
+        /// <param name="color">Color of the line.</param>
+        /// <param name="width">Width of the line, in pixels.</param>
+        public void DrawPolyLine(Vector2I[] vertices, Color color, float width = 1.0f)
+        {
+            Internal_DrawPolyLine(mCachedPtr, vertices, width, ref color);
+        }
+
+        /// <summary>
+        /// Draws a quad with a the provided texture displayed.
+        /// </summary>
+        /// <param name="texture">Texture to draw.</param>
+        /// <param name="area">Position and size of the texture to draw. Position is relative to the canvas origin 
+        ///                    (top-left). If size is zero, the default texture size will be used.</param>
+        /// <param name="scaleMode">Scale mode to use when sizing the texture. Only relevant if the provided quad size 
+        ///                         doesn't match the texture size.</param>
+        public void DrawTexture(SpriteTexture texture, Rect2I area,
+            GUITextureScaleMode scaleMode = GUITextureScaleMode.StretchToFit)
+        {
+            IntPtr texturePtr = IntPtr.Zero;
+            if (texture != null)
+                texturePtr = texture.GetCachedPtr();
+
+            Color color = Color.White;
+            Internal_DrawTexture(mCachedPtr, texturePtr, ref area, scaleMode, ref color);
+        }
+
+        /// <summary>
+        /// Draws a quad with a the provided texture displayed.
+        /// </summary>
+        /// <param name="texture">Texture to draw.</param>
+        /// <param name="area">Position and size of the texture to draw. Position is relative to the canvas origin 
+        ///                    (top-left). If size is zero, the default texture size will be used.</param>
+        /// <param name="color">Color to tint the drawn texture with.</param>
+        /// <param name="scaleMode">Scale mode to use when sizing the texture. Only relevant if the provided quad size 
+        ///                         doesn't match the texture size.</param>
+        public void DrawTexture(SpriteTexture texture, Rect2I area, Color color,
+            GUITextureScaleMode scaleMode = GUITextureScaleMode.StretchToFit)
+        {
+            IntPtr texturePtr = IntPtr.Zero;
+            if (texture != null)
+                texturePtr = texture.GetCachedPtr();
+
+            Internal_DrawTexture(mCachedPtr, texturePtr, ref area, scaleMode, ref color);
+        }
+
+        /// <summary>
+        /// Draws a triangle strip. First three vertices are used to form the initial triangle, and every next vertex will
+        /// form a triangle with the previous two.
+        /// </summary>
+        /// <param name="vertices">A set of points defining the triangles. Must have at least three elements. All points
+        ///                        are relative to the canvas origin(top-left).</param>
+        public void DrawTriangleStrip(Vector2I[] vertices)
+        {
+            Color color = Color.White;
+            Internal_DrawTriangleStrip(mCachedPtr, vertices, ref color);
+        }
+
+        /// <summary>
+        /// Draws a triangle strip. First three vertices are used to form the initial triangle, and every next vertex will
+        /// form a triangle with the previous two.
+        /// </summary>
+        /// <param name="vertices">A set of points defining the triangles. Must have at least three elements. All points
+        ///                        are relative to the canvas origin(top-left).</param>
+        /// <param name="color">Color of the triangles.</param>
+        public void DrawTriangleStrip(Vector2I[] vertices, Color color)
+        {
+            Internal_DrawTriangleStrip(mCachedPtr, vertices, ref color);
+        }
+
+        /// <summary>
+        /// Draws a triangle list. Every three vertices in the list represent a unique triangle.
+        /// </summary>
+        /// <param name="vertices">A set of points defining the triangles. Must have at least three elements, and its size
+        ///                        must be a multiple of three.</param>
+        public void DrawTriangleList(Vector2I[] vertices)
+        {
+            Color color = Color.White;
+            Internal_DrawTriangleList(mCachedPtr, vertices, ref color);
+        }
+
+        /// <summary>
+        /// Draws a triangle list. Every three vertices in the list represent a unique triangle.
+        /// </summary>
+        /// <param name="vertices">A set of points defining the triangles. Must have at least three elements, and its size
+        ///                        must be a multiple of three.</param>
+        /// <param name="color">Color of the triangles.</param>
+        public void DrawTriangleList(Vector2I[] vertices, Color color)
+        {
+            Internal_DrawTriangleList(mCachedPtr, vertices, ref color);
+        }
+
+        /// <summary>
+        /// Draws a piece of text with the wanted font. The text will be aligned to the top-left corner of the provided
+        /// position, and will not be word wrapped.
+        /// </summary>
+        /// <param name="text">Text to draw.</param>
+        /// <param name="position">Position of the text to draw. This represents the top-left corner of the text. It is
+        ///                        relative to the canvas origin(top-left).</param>
+        /// <param name="font">Font to draw the text with.</param>
+        /// <param name="color">Color of the text.</param>
+        /// <param name="size">Size of the font.</param>
+        public void DrawText(string text, Vector2I position, Font font, Color color, int size = 10)
+        {
+            IntPtr fontPtr = IntPtr.Zero;
+            if (font != null)
+                fontPtr = font.GetCachedPtr();
+
+            Internal_DrawText(mCachedPtr, text, ref position, fontPtr, size, ref color);
+        }
+
+        /// <summary>
+        /// Draws a piece of text with the wanted font. The text will be aligned to the top-left corner of the provided
+        /// position, and will not be word wrapped.
+        /// </summary>
+        /// <param name="text">Text to draw.</param>
+        /// <param name="position">Position of the text to draw. This represents the top-left corner of the text. It is
+        ///                        relative to the canvas origin(top-left).</param>
+        /// <param name="font">Font to draw the text with.</param>
+        /// <param name="size">Size of the font.</param>
+        public void DrawText(string text, Vector2I position, Font font, int size = 10)
+        {
+            IntPtr fontPtr = IntPtr.Zero;
+            if (font != null)
+                fontPtr = font.GetCachedPtr();
+
+            Color color = Color.White;
+            Internal_DrawText(mCachedPtr, text, ref position, fontPtr, size, ref color);
+        }
+
+        /// <summary>
+        /// Clears the canvas, removing any previously drawn elements.
+        /// </summary>
+        public void Clear()
+        {
+            Internal_Clear(mCachedPtr);
+        }
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_CreateInstance(GUICanvas instance, string style, GUIOption[] options);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_DrawLine(IntPtr nativeInstance, ref Vector2I a, ref Vector2I b, float width, 
+            ref Color color);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_DrawPolyLine(IntPtr nativeInstance, Vector2I[] vertices, float width, 
+            ref Color color);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_DrawTexture(IntPtr nativeInstance, IntPtr texture, ref Rect2I area,
+            GUITextureScaleMode scaleMode, ref Color color);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_DrawTriangleStrip(IntPtr nativeInstance, Vector2I[] vertices, ref Color color);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_DrawTriangleList(IntPtr nativeInstance, Vector2I[] vertices, ref Color color);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_DrawText(IntPtr nativeInstance, string text, ref Vector2I position,
+            IntPtr font, int size, ref Color color);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_Clear(IntPtr nativeInstance);
+    }
+
+    /** @} */
+}

+ 10 - 10
Source/MBansheeEngine/GUI/GUITexture.cs

@@ -12,7 +12,7 @@ namespace BansheeEngine
     /// <summary>
     /// Type of scaling modes for GUI images.
     /// </summary>
-    public enum GUIImageScaleMode // Note: Must match C++ enum GUIImageScaleMode
+    public enum GUITextureScaleMode // Note: Must match C++ enum TextureScaleMode
 	{
         /// <summary>
         /// Image will stretch non-uniformly in all dimensions in order to cover the assigned area fully.
@@ -49,7 +49,7 @@ namespace BansheeEngine
         ///                     default element style is used.</param>
         /// <param name="options">Options that allow you to control how is the element  positioned and sized. This will 
         ///                       override any similar options set by style.</param>
-        public GUITexture(SpriteTexture texture, GUIImageScaleMode scale, bool transparent, string style, params GUIOption[] options)
+        public GUITexture(SpriteTexture texture, GUITextureScaleMode scale, bool transparent, string style, params GUIOption[] options)
         {
             Internal_CreateInstance(this, texture, scale, transparent, style, options);
         }
@@ -63,7 +63,7 @@ namespace BansheeEngine
         /// <param name="transparent">Determines should the texture be rendered with transparency active.</param>
         /// <param name="options">Options that allow you to control how is the element  positioned and sized. This will 
         ///                       override any similar options set by style.</param>
-        public GUITexture(SpriteTexture texture, GUIImageScaleMode scale, bool transparent, params GUIOption[] options)
+        public GUITexture(SpriteTexture texture, GUITextureScaleMode scale, bool transparent, params GUIOption[] options)
         {
             Internal_CreateInstance(this, texture, scale, transparent, "", options);
         }
@@ -81,7 +81,7 @@ namespace BansheeEngine
         ///                       override any similar options set by style.</param>
         public GUITexture(SpriteTexture texture, bool transparent, string style, params GUIOption[] options)
         {
-            Internal_CreateInstance(this, texture, GUIImageScaleMode.StretchToFit, transparent, style, options);
+            Internal_CreateInstance(this, texture, GUITextureScaleMode.StretchToFit, transparent, style, options);
         }
 
         /// <summary>
@@ -94,7 +94,7 @@ namespace BansheeEngine
         ///                       override any similar options set by style.</param>
         public GUITexture(SpriteTexture texture, bool transparent, params GUIOption[] options)
         {
-            Internal_CreateInstance(this, texture, GUIImageScaleMode.StretchToFit, transparent, "", options);
+            Internal_CreateInstance(this, texture, GUITextureScaleMode.StretchToFit, transparent, "", options);
         }
 
         /// <summary>
@@ -108,7 +108,7 @@ namespace BansheeEngine
         ///                     default element style is used.</param>
         /// <param name="options">Options that allow you to control how is the element  positioned and sized. This will 
         ///                       override any similar options set by style.</param>
-        public GUITexture(SpriteTexture texture, GUIImageScaleMode scale, string style, params GUIOption[] options)
+        public GUITexture(SpriteTexture texture, GUITextureScaleMode scale, string style, params GUIOption[] options)
         {
             Internal_CreateInstance(this, texture, scale, true, style, options);
         }
@@ -121,7 +121,7 @@ namespace BansheeEngine
         /// <param name="scale">Scale mode to use when sizing the texture.</param>
         /// <param name="options">Options that allow you to control how is the element  positioned and sized. This will 
         ///                       override any similar options set by style.</param>
-        public GUITexture(SpriteTexture texture, GUIImageScaleMode scale, params GUIOption[] options)
+        public GUITexture(SpriteTexture texture, GUITextureScaleMode scale, params GUIOption[] options)
         {
             Internal_CreateInstance(this, texture, scale, true, "", options);
         }
@@ -138,7 +138,7 @@ namespace BansheeEngine
         ///                       override any similar options set by style.</param>
         public GUITexture(SpriteTexture texture, string style, params GUIOption[] options)
         {
-            Internal_CreateInstance(this, texture, GUIImageScaleMode.StretchToFit, true, style, options);
+            Internal_CreateInstance(this, texture, GUITextureScaleMode.StretchToFit, true, style, options);
         }
 
         /// <summary>
@@ -150,7 +150,7 @@ namespace BansheeEngine
         ///                       override any similar options set by style.</param>
         public GUITexture(SpriteTexture texture, params GUIOption[] options)
         {
-            Internal_CreateInstance(this, texture, GUIImageScaleMode.StretchToFit, true, "", options);
+            Internal_CreateInstance(this, texture, GUITextureScaleMode.StretchToFit, true, "", options);
         }
 
         /// <summary>
@@ -174,7 +174,7 @@ namespace BansheeEngine
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern void Internal_CreateInstance(GUITexture instance, SpriteTexture texture,
-            GUIImageScaleMode scale, bool transparent, string style, GUIOption[] options);
+            GUITextureScaleMode scale, bool transparent, string style, GUIOption[] options);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern void Internal_SetTexture(IntPtr nativeInstance, SpriteTexture texture);

+ 1 - 0
Source/MBansheeEngine/MBansheeEngine.csproj

@@ -49,6 +49,7 @@
     <Compile Include="Audio\AudioSource.cs" />
     <Compile Include="Audio\Interop\NativeAudioListener.cs" />
     <Compile Include="Audio\Interop\NativeAudioSource.cs" />
+    <Compile Include="GUI\GUICanvas.cs" />
     <Compile Include="Rendering\PostProcessSettings.cs" />
     <Compile Include="Utility\AsyncOp.cs" />
     <Compile Include="Math\Bounds.cs" />

+ 2 - 0
Source/SBansheeEngine/CMakeSources.cmake

@@ -37,6 +37,7 @@ set(BS_SBANSHEEENGINE_SRC_WRAPPERS_GUI
 	"Source/BsScriptGUISkin.cpp"
 	"Source/BsScriptGUIWidget.cpp"
 	"Source/BsScriptGUI.cpp"
+	"Source/BsScriptGUICanvas.cpp"
 )
 
 set(BS_SBANSHEEENGINE_INC_SERIALIZATION_RTTI
@@ -162,6 +163,7 @@ set(BS_SBANSHEEENGINE_INC_WRAPPERS_GUI
 	"Include/BsScriptGUISkin.h"
 	"Include/BsScriptGUIWidget.h"
 	"Include/BsScriptGUI.h"
+	"Include/BsScriptGUICanvas.h"
 )
 
 set(BS_SBANSHEEENGINE_INC_WRAPPERS_PHYSICS

+ 39 - 0
Source/SBansheeEngine/Include/BsScriptGUICanvas.h

@@ -0,0 +1,39 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsScriptEnginePrerequisites.h"
+#include "BsScriptGUIElement.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup ScriptInteropEngine
+	 *  @{
+	 */
+
+	/**	Interop class between C++ & CLR for GUICanvas. */
+	class BS_SCR_BE_EXPORT ScriptGUICanvas : public TScriptGUIElement<ScriptGUICanvas>
+	{
+	public:
+		SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "GUICanvas")
+
+	private:
+		ScriptGUICanvas(MonoObject* instance, GUICanvas* canvas);
+
+		/************************************************************************/
+		/* 								CLR HOOKS						   		*/
+		/************************************************************************/
+		static void internal_createInstance(MonoObject* instance, MonoString* style, MonoArray* guiOptions);
+		static void internal_drawLine(ScriptGUICanvas* nativeInstance, Vector2I* a, Vector2I* b, float width, Color* color);
+		static void internal_drawPolyLine(ScriptGUICanvas* nativeInstance, MonoArray* vertices, float width, Color* color);
+		static void internal_drawTexture(ScriptGUICanvas* nativeInstance, ScriptSpriteTexture* texture, Rect2I* area,
+			TextureScaleMode scaleMode, Color* color);
+		static void internal_drawTriangleStrip(ScriptGUICanvas* nativeInstance, MonoArray* vertices, Color* color);
+		static void internal_drawTriangleList(ScriptGUICanvas* nativeInstance, MonoArray* vertices, Color* color);
+		static void internal_drawText(ScriptGUICanvas* nativeInstance, MonoString* text, Vector2I* position, 
+			ScriptFont* font, UINT32 size, Color* color);
+		static void internal_clear(ScriptGUICanvas* nativeInstance);
+	};
+
+	/** @} */
+}

+ 123 - 0
Source/SBansheeEngine/Source/BsScriptGUICanvas.cpp

@@ -0,0 +1,123 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#include "BsScriptGUICanvas.h"
+#include "BsScriptMeta.h"
+#include "BsScriptSpriteTexture.h"
+#include "BsMonoUtil.h"
+#include "BsGUILayout.h"
+#include "BsGUICanvas.h"
+#include "BsGUIOptions.h"
+#include "BsScriptVector2I.h"
+#include "BsScriptFont.h"
+
+namespace BansheeEngine
+{
+	ScriptGUICanvas::ScriptGUICanvas(MonoObject* instance, GUICanvas* canvas)
+		:TScriptGUIElement(instance, canvas)
+	{
+
+	}
+
+	void ScriptGUICanvas::initRuntimeData()
+	{
+		metaData.scriptClass->addInternalCall("Internal_CreateInstance", &ScriptGUICanvas::internal_createInstance);
+		metaData.scriptClass->addInternalCall("Internal_DrawLine", &ScriptGUICanvas::internal_drawLine);
+		metaData.scriptClass->addInternalCall("Internal_DrawPolyLine", &ScriptGUICanvas::internal_drawPolyLine);
+		metaData.scriptClass->addInternalCall("Internal_DrawTexture", &ScriptGUICanvas::internal_drawTexture);
+		metaData.scriptClass->addInternalCall("Internal_DrawTriangleStrip", &ScriptGUICanvas::internal_drawTriangleStrip);
+		metaData.scriptClass->addInternalCall("Internal_DrawTriangleList", &ScriptGUICanvas::internal_drawTriangleList);
+		metaData.scriptClass->addInternalCall("Internal_DrawText", &ScriptGUICanvas::internal_drawText);
+		metaData.scriptClass->addInternalCall("Internal_Clear", &ScriptGUICanvas::internal_clear);
+	}
+
+	void ScriptGUICanvas::internal_createInstance(MonoObject* instance, MonoString* style, MonoArray* guiOptions)
+	{
+		GUIOptions options;
+
+		ScriptArray scriptArray(guiOptions);
+		UINT32 arrayLen = scriptArray.size();
+		for (UINT32 i = 0; i < arrayLen; i++)
+			options.addOption(scriptArray.get<GUIOption>(i));
+
+		GUICanvas* guiCanvas = GUICanvas::create(options, toString(MonoUtil::monoToWString(style)));
+
+		new (bs_alloc<ScriptGUICanvas>()) ScriptGUICanvas(instance, guiCanvas);
+	}
+
+	void ScriptGUICanvas::internal_drawLine(ScriptGUICanvas* nativeInstance, Vector2I* a, Vector2I* b, float width, Color* color)
+	{
+		GUICanvas* canvas = (GUICanvas*)nativeInstance->getGUIElement();
+		canvas->drawLine(*a, *b, width, *color);
+	}
+
+	void ScriptGUICanvas::internal_drawPolyLine(ScriptGUICanvas* nativeInstance, MonoArray* vertices, float width, 
+		Color* color)
+	{
+		GUICanvas* canvas = (GUICanvas*)nativeInstance->getGUIElement();
+
+		ScriptArray verticesArray(vertices);
+		UINT32 size = verticesArray.size();
+
+		Vector<Vector2I> nativeVertices(size);
+		memcpy(nativeVertices.data(), verticesArray.getRawPtr<ScriptVector2I>(), sizeof(Vector2));
+
+		canvas->drawPolyLine(nativeVertices, width, *color);
+	}
+
+	void ScriptGUICanvas::internal_drawTexture(ScriptGUICanvas* nativeInstance, ScriptSpriteTexture* texture, Rect2I* area,
+		TextureScaleMode scaleMode, Color* color)
+	{
+		GUICanvas* canvas = (GUICanvas*)nativeInstance->getGUIElement();
+
+		HSpriteTexture nativeTexture;
+		if (texture != nullptr)
+			nativeTexture = texture->getHandle();
+
+		canvas->drawTexture(nativeTexture, *area, scaleMode, *color);
+	}
+	
+	void ScriptGUICanvas::internal_drawTriangleStrip(ScriptGUICanvas* nativeInstance, MonoArray* vertices, Color* color)
+	{
+		GUICanvas* canvas = (GUICanvas*)nativeInstance->getGUIElement();
+
+		ScriptArray verticesArray(vertices);
+		UINT32 size = verticesArray.size();
+
+		Vector<Vector2I> nativeVertices(size);
+		memcpy(nativeVertices.data(), verticesArray.getRawPtr<ScriptVector2I>(), sizeof(Vector2));
+
+		canvas->drawTriangleStrip(nativeVertices, *color);
+	}
+
+	void ScriptGUICanvas::internal_drawTriangleList(ScriptGUICanvas* nativeInstance, MonoArray* vertices, Color* color)
+	{
+		GUICanvas* canvas = (GUICanvas*)nativeInstance->getGUIElement();
+
+		ScriptArray verticesArray(vertices);
+		UINT32 size = verticesArray.size();
+
+		Vector<Vector2I> nativeVertices(size);
+		memcpy(nativeVertices.data(), verticesArray.getRawPtr<ScriptVector2I>(), sizeof(Vector2));
+
+		canvas->drawTriangleList(nativeVertices, *color);
+	}
+
+	void ScriptGUICanvas::internal_drawText(ScriptGUICanvas* nativeInstance, MonoString* text, Vector2I* position,
+		ScriptFont* font, UINT32 size, Color* color)
+	{
+		GUICanvas* canvas = (GUICanvas*)nativeInstance->getGUIElement();
+		WString nativeText = MonoUtil::monoToWString(text);
+
+		HFont nativeFont;
+		if (font != nullptr)
+			nativeFont = font->getHandle();
+
+		canvas->drawText(nativeText, *position, nativeFont, size, *color);
+	}
+
+	void ScriptGUICanvas::internal_clear(ScriptGUICanvas* nativeInstance)
+	{
+		GUICanvas* canvas = (GUICanvas*)nativeInstance->getGUIElement();
+		canvas->clear();
+	}
+}