summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-11-20 14:10:24 +0800
committerchai <chaifix@163.com>2021-11-20 14:10:24 +0800
commit74ca8143a7c2352425d549b681b2838bda5ee218 (patch)
tree5aad35e7312b7c1b54769091b30f47d8ad747acb
parent850d9c034792b96e2ff5ff3bbfbcc30661757aed (diff)
*misc
-rw-r--r--Data/BuiltIn/Libraries/GameLab/Class.lua9
-rw-r--r--Data/BuiltIn/Libraries/GameLab/Engine/GUI/IMGUI.lua31
-rw-r--r--Data/BuiltIn/Libraries/GameLab/GlobalClass.lua2
-rw-r--r--Data/Libraries/GameLab/Editor/Window/GUIWindow.lua4
-rw-r--r--Data/Resources/Shaders/Editor-Text.glsl2
-rw-r--r--Data/Scripts/EditorApplication.lua2
-rw-r--r--Data/boot.lua9
-rw-r--r--Editor/GUI/GUIWindow.cpp1
-rw-r--r--Editor/Scripting/GUI/EditorGUI.bind.cpp78
-rw-r--r--Projects/VisualStudio/Editor/Editor.vcxproj2
-rw-r--r--Projects/VisualStudio/Editor/Editor.vcxproj.filters10
-rw-r--r--Runtime/GUI/UILine.cpp48
-rw-r--r--Runtime/GUI/UILine.h21
-rw-r--r--Runtime/GUI/UIMesh.h1
-rw-r--r--Runtime/GUI/UIQuad.cpp8
-rw-r--r--Runtime/Graphics/DynamicVertexBuffer.cpp4
-rw-r--r--Runtime/Scripting/GUI/GUI.bind.cpp103
17 files changed, 228 insertions, 107 deletions
diff --git a/Data/BuiltIn/Libraries/GameLab/Class.lua b/Data/BuiltIn/Libraries/GameLab/Class.lua
index e30aab7..7e2502d 100644
--- a/Data/BuiltIn/Libraries/GameLab/Class.lua
+++ b/Data/BuiltIn/Libraries/GameLab/Class.lua
@@ -113,4 +113,13 @@ end
GameLab.Class = class
+local function affirmClass(_, classname)
+ return function()
+ return "foookok"
+ end
+end
+CLASS = setmetatable({}, {__index = affirmClass})
+
+Class = class
+
return class \ No newline at end of file
diff --git a/Data/BuiltIn/Libraries/GameLab/Engine/GUI/IMGUI.lua b/Data/BuiltIn/Libraries/GameLab/Engine/GUI/IMGUI.lua
index cf84bff..084cc81 100644
--- a/Data/BuiltIn/Libraries/GameLab/Engine/GUI/IMGUI.lua
+++ b/Data/BuiltIn/Libraries/GameLab/Engine/GUI/IMGUI.lua
@@ -14,6 +14,9 @@ local Matrix44 = find "GameLab.Engine.Math.Matrix44"
local Rendering = GameLab.Engine.Rendering
local EEventType = GameLab.Events.EEventType
local Resource = GameLab.Engine.Resource
+local Vector2 = GameLab.Engine.Math.Vector2
+local Vector4 = GameLab.Engine.Math.Vector4
+local Color = Rendering.Color
local EditorRes
if GAMELAB_EDITOR then
@@ -51,8 +54,6 @@ end
GUI.Label = function()
end
-local shader
-local tex
GUI.Box = function(position, color, size)
if Event.current.type == EEventType.Repaint then
@@ -61,23 +62,16 @@ GUI.Box = function(position, color, size)
--Rendering.UseShader(Res.shaders["EditorShape"])
local ortho = Matrix44()
ortho:SetOrtho(0, size.x, size.y, 0, 0.1, 10)
- if shader == nil then
- shader = Rendering.Shader.CreateFromFile("./Resources/Shaders/Editor-Text.glsl")
- --shader = Rendering.Shader.CreateFromFile("./Resources/Shaders/Editor-UI.glsl")
- end
- if tex == nil then
- tex = Resource.LoadTexture("./Resources/Images/tile.png")
- --tex = Engine.Resource.LoadTexture("./Resources/Images/brickwall_small.jpg")
- end
- Rendering.UseShader(shader)
+ Rendering.UseShader(Res.shaders["EditorShape"])
Rendering.SetMatrix44("gamelab_mat_mvp", ortho)
Rendering.SetVector2("gamelab_ui_position", {0, 0})
+ Rendering.SetVector4("gamelab_color", Vector4(0.12, 0.12, 0.12, 1))
--Rendering.SetTexture("gamelab_main_tex", tex)
--Rendering.DrawUIQuad({0, 0, 200, 200})
--Rendering.DrawUI9Slicing(1, {25, 25}, {25, 25}, {80, 80}, {400, 30} )
- EditorGUI.Text(_G["default_font"], "你好世界!\nMaterials\nHello,World!\nProject Window Properties", 12)
- --EditorGUI.Text(_G["default_font"], "hello", 12)
+ --GUI.DrawText(_G["default_font"], "你好世界!\nMaterials\nHello,World!\nProject Window Properties", 12)
+ GUI.Line(Vector2(0, 0), Vector2(100, 100))
end
end
@@ -109,8 +103,15 @@ GUI.HorizontalScrollbar = function()
end
-GUI.DrawLine = function()
+GUI.Line = function(from, to)
+ if Event.current.type ~= EEventType.Repaint then
+ return
+ end
+ GUI.DrawLine(from, to)
+end
+
+GUI.BoxFrame = function(topleft, size)
end
-return GUI \ No newline at end of file
+return GUI \ No newline at end of file
diff --git a/Data/BuiltIn/Libraries/GameLab/GlobalClass.lua b/Data/BuiltIn/Libraries/GameLab/GlobalClass.lua
index 7104480..3d2b166 100644
--- a/Data/BuiltIn/Libraries/GameLab/GlobalClass.lua
+++ b/Data/BuiltIn/Libraries/GameLab/GlobalClass.lua
@@ -18,4 +18,6 @@ end
GameLab.GlobalClass = GlobalClass
+GClass = GlobalClass
+
return GlobalClass \ No newline at end of file
diff --git a/Data/Libraries/GameLab/Editor/Window/GUIWindow.lua b/Data/Libraries/GameLab/Editor/Window/GUIWindow.lua
index f1f4445..b5d7436 100644
--- a/Data/Libraries/GameLab/Editor/Window/GUIWindow.lua
+++ b/Data/Libraries/GameLab/Editor/Window/GUIWindow.lua
@@ -40,7 +40,7 @@ local GUIWindow = GameLab.GlobalClass("GameLab.Editor.Window.GUIWindow", functio
i = i + 1
self.m_ClearColor = col[i]
-end )
+end)
GUIWindow.get_native = function(self)
return self.m_Native
@@ -127,7 +127,7 @@ end
GUIWindow.ClearBackground = function(self)
if Event.current.type == EEventType.Repaint then
- GL.ClearColor(self.m_ClearColor)
+ GL.ClearColor(Color(0.16,0.16,0.16,1 ))
GL.Clear(GL.EBufferType.ColorBuffer)
end
end
diff --git a/Data/Resources/Shaders/Editor-Text.glsl b/Data/Resources/Shaders/Editor-Text.glsl
index 3c1ad4f..7db820c 100644
--- a/Data/Resources/Shaders/Editor-Text.glsl
+++ b/Data/Resources/Shaders/Editor-Text.glsl
@@ -36,7 +36,7 @@ out vec4 FragColor;
void main()
{
- vec4 sampled = vec4(0.8,0.8,0.8,texture(gamelab_main_tex, uv).r);
+ vec4 sampled = vec4(1,1,1,texture(gamelab_main_tex, uv).r);
sampled *= color;
FragColor = sampled;
}
diff --git a/Data/Scripts/EditorApplication.lua b/Data/Scripts/EditorApplication.lua
index 1a31cdd..ad30d3a 100644
--- a/Data/Scripts/EditorApplication.lua
+++ b/Data/Scripts/EditorApplication.lua
@@ -1,3 +1,5 @@
+setfenv(1, _G)
+
local json = require "LiteJson.json"
local inspect = require "inspect"
local AssetBrowser = require "./Scripts/Editor/AssetBrowser"
diff --git a/Data/boot.lua b/Data/boot.lua
index 94dabd1..6807de6 100644
--- a/Data/boot.lua
+++ b/Data/boot.lua
@@ -22,14 +22,19 @@ if GAMELAB_DEBUG then
print = GameLab.Debug.Log
end
+-- gamelab enviroument
+local env = {}
+setmetatable(env, {__index = _G})
+setfenv(1, env)
+
-- load gamelab modules
require "GameLab"
require "GameLab.Containers"
require "GameLab.Utils"
require "GameLab.Events"
require "GameLab.Engine"
-require "GameLab.Engine.GUI"
require "GameLab.Engine.Math"
+require "GameLab.Engine.GUI"
require "GameLab.Engine.Rendering"
require "GameLab.Engine.Resource"
require "GameLab.Engine.GL"
@@ -37,7 +42,7 @@ require "GameLab.Editor"
require "GameLab.Editor.Window"
-- debugging
-require("LuaPanda").start("127.0.0.1",8818)
+--require("LuaPanda").start("127.0.0.1",8818)
-- launch editor
dofile("./Scripts/EditorApplication.lua")
diff --git a/Editor/GUI/GUIWindow.cpp b/Editor/GUI/GUIWindow.cpp
index b680e28..1a4a949 100644
--- a/Editor/GUI/GUIWindow.cpp
+++ b/Editor/GUI/GUIWindow.cpp
@@ -48,7 +48,6 @@ void GUIWindowProxy::DoGUI(LuaBind::State& state)
void GUIWindowProxy::DoClean(LuaBind::State& state)
{
-
}
void GUIWindowProxy::Start(LuaBind::State& state)
diff --git a/Editor/Scripting/GUI/EditorGUI.bind.cpp b/Editor/Scripting/GUI/EditorGUI.bind.cpp
index e0b94e0..e4ba24e 100644
--- a/Editor/Scripting/GUI/EditorGUI.bind.cpp
+++ b/Editor/Scripting/GUI/EditorGUI.bind.cpp
@@ -13,82 +13,6 @@
#include "Editor/Win/Win.h"
using namespace LuaBind;
-using namespace Win;
-
-static std::vector<character::Unicode>* s_Codepoints;
-
-InitializeStaticVariables([]() {
- s_Codepoints = new std::vector<character::Unicode>();
-});
-
-// Editor.GUI.Text(font, str, pixelSize, lineHeight, color, anchor, alignment, wordwrap, preferred, encoding)
-static int Text(lua_State* L)
-{
- LUA_BIND_STATE(L);
-
- Font* font = (Font*)state.GetUserdata<Font>(1);
- char* buf = (char*)state.GetValue<const char*>(2, "");
- int pixelSize = state.GetValue<int>(3, 12);
- int lineHeight = state.GetValue<int>(4, pixelSize + 3);
- Color32 color = state.GetValue<Color32>(5, Color32::white);
- int anchor = state.GetValue<int>(6, TextAnchor_UpperLeft);
- int alignment = state.GetValue<int>(7, TextAlignment_Left);
- bool wordwrap = state.GetValue<bool>(8, false);
- int preferred = state.GetValue<int>(9, 0);
- int encoding = state.GetValue<int>(10, EEncoding::Encoding_UTF8);
-
- s_Codepoints->clear();
- InvokeWhenLeave([]() {
- s_Codepoints->clear();
- });
-
- if (encoding == EEncoding::Encoding_UTF8)
- {
- while (*buf != 0) {
- int err;
- s_Codepoints->push_back(utf8::getu8c(&buf, &err));
- if (err != 0)
- {
- log_warning("Illegal utf8 bytes %d", err);
- }
- }
- }
- else if (encoding == EEncoding::Encoding_UTF16)
- {
- while (*buf != 0) {
- unsigned short* s = (unsigned short*)(buf);
- s_Codepoints->push_back(*s);
- buf += 2;
- }
- }
- else if (encoding == EEncoding::Encoding_ASCII)
- {
- while (*buf != 0) {
- s_Codepoints->push_back(*buf);
- buf += 1;
- }
- }
-
- font->RenderCharacters(*s_Codepoints, pixelSize);
-
- UnicodeString str;
- str.str = s_Codepoints->data();
- str.length = s_Codepoints->size();
-
- WipeGLError();
-
- const UITextMesh* tm = g_TextMeshGenerator.GetTextMesh(str, font, pixelSize, lineHeight, color, (ETextAnchor)anchor, (ETextAlignment)alignment, wordwrap, preferred);
- tm->Draw();
-
- WipeGLError();
-
- return 0;
-}
-
-static luaL_Reg guiFuncs[] = {
- {"Text", Text},
- {0, 0}
-};
int luaopen_GameLab_Editor_GUI(lua_State* L)
{
@@ -101,7 +25,5 @@ int luaopen_GameLab_Editor_GUI(lua_State* L)
state.PushNamespace("Editor");
state.PushNamespace("GUI");
- state.RegisterMethods(guiFuncs);
-
return 1;
} \ No newline at end of file
diff --git a/Projects/VisualStudio/Editor/Editor.vcxproj b/Projects/VisualStudio/Editor/Editor.vcxproj
index eaf43c7..9ef11e1 100644
--- a/Projects/VisualStudio/Editor/Editor.vcxproj
+++ b/Projects/VisualStudio/Editor/Editor.vcxproj
@@ -204,6 +204,7 @@
<ClCompile Include="..\..\..\Runtime\Graphics\VertexBuffer.cpp" />
<ClCompile Include="..\..\..\Runtime\GUI\Font.cpp" />
<ClCompile Include="..\..\..\Runtime\GUI\UI9Slicing.cpp" />
+ <ClCompile Include="..\..\..\Runtime\GUI\UILine.cpp" />
<ClCompile Include="..\..\..\Runtime\GUI\UIMesh.cpp" />
<ClCompile Include="..\..\..\Runtime\GUI\UISquare.cpp" />
<ClCompile Include="..\..\..\Runtime\GUI\UITextMesh.cpp" />
@@ -305,6 +306,7 @@
<ClInclude Include="..\..\..\Runtime\GUI\freetype.h" />
<ClInclude Include="..\..\..\Runtime\GUI\Font.h" />
<ClInclude Include="..\..\..\Runtime\GUI\UI9Slicing.h" />
+ <ClInclude Include="..\..\..\Runtime\GUI\UILine.h" />
<ClInclude Include="..\..\..\Runtime\GUI\UIMesh.h" />
<ClInclude Include="..\..\..\Runtime\GUI\UISquare.h" />
<ClInclude Include="..\..\..\Runtime\GUI\UITextMesh.h" />
diff --git a/Projects/VisualStudio/Editor/Editor.vcxproj.filters b/Projects/VisualStudio/Editor/Editor.vcxproj.filters
index c775d60..c90b38d 100644
--- a/Projects/VisualStudio/Editor/Editor.vcxproj.filters
+++ b/Projects/VisualStudio/Editor/Editor.vcxproj.filters
@@ -384,7 +384,6 @@
<ClCompile Include="..\..\..\Runtime\GUI\UIMesh.cpp">
<Filter>Runtime\GUI</Filter>
</ClCompile>
- <ClCompile Include="..\..\..\Runtime\Graphics\Color.cpp" />
<ClCompile Include="..\..\..\Runtime\Lua\LuaBind\LuaBindInvoker.cpp">
<Filter>Runtime\Lua\LuaBind</Filter>
</ClCompile>
@@ -424,6 +423,12 @@
<ClCompile Include="..\..\..\Runtime\GUI\UISquare.cpp">
<Filter>Runtime\GUI</Filter>
</ClCompile>
+ <ClCompile Include="..\..\..\Runtime\Graphics\Color.cpp">
+ <Filter>Runtime\Graphics</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\Runtime\GUI\UILine.cpp">
+ <Filter>Runtime\GUI</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\Editor\GUI\Dock.h">
@@ -774,6 +779,9 @@
<ClInclude Include="..\..\..\Runtime\Math\ITransData.h">
<Filter>Runtime\Math</Filter>
</ClInclude>
+ <ClInclude Include="..\..\..\Runtime\GUI\UILine.h">
+ <Filter>Runtime\GUI</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\Runtime\Lua\LuaBind\LuaBindClass.inc">
diff --git a/Runtime/GUI/UILine.cpp b/Runtime/GUI/UILine.cpp
new file mode 100644
index 0000000..8db681e
--- /dev/null
+++ b/Runtime/GUI/UILine.cpp
@@ -0,0 +1,48 @@
+#include "UILine.h"
+
+struct UILineLayout
+{
+ Vector2 position;
+};
+
+static CustomVertexLayout layout;
+
+InitializeStaticVariables([]() {
+ VertexAttributeDescriptor POSITION = VertexAttributeDescriptor(0, 2, VertexAttrFormat_Float, sizeof(UILineLayout));
+
+ layout.attributes.push_back(POSITION);
+});
+
+void UILine::Draw()
+{
+ const int nVerts = 2;
+ const int nIndices = 2;
+
+ float pos[] = {
+ m_From.x, m_From.y,
+ m_To.x, m_To.y,
+ };
+
+ uint16 indices[] = {
+ 0, 1
+ };
+
+
+ uint8* vb;
+ uint16* ib;
+
+ g_SharedVBO.GetChunk(sizeof(UILineLayout), sizeof(uint16), nVerts, nIndices, Primitive_Line, (void**)&vb, (void**)&ib);
+
+ UILineLayout* dst = (UILineLayout*)vb;
+
+ for (int i = 0; i < nVerts; ++i)
+ {
+ dst[i].position.Set(pos[2 * i], pos[2 * i + 1]);
+ }
+
+ for (int i = 0; i < nIndices; ++i)
+ ib[i] = indices[i];
+
+ g_SharedVBO.ReleaseChunk(nVerts, nIndices);
+ g_SharedVBO.DrawChunk(layout);
+} \ No newline at end of file
diff --git a/Runtime/GUI/UILine.h b/Runtime/GUI/UILine.h
new file mode 100644
index 0000000..a47b1f1
--- /dev/null
+++ b/Runtime/GUI/UILine.h
@@ -0,0 +1,21 @@
+#pragma once
+
+#include "../Utilities/StaticInitiator.h"
+#include "UIMesh.h"
+
+class UILine : public UIMesh
+{
+public:
+ UILine(Vector2f from, Vector2f to)
+ {
+ m_From = from;
+ m_To = to;
+ }
+
+ void Draw() override;
+
+private:
+ Vector2f m_From;
+ Vector2f m_To;
+
+};
diff --git a/Runtime/GUI/UIMesh.h b/Runtime/GUI/UIMesh.h
index 8b6b56d..1de111b 100644
--- a/Runtime/GUI/UIMesh.h
+++ b/Runtime/GUI/UIMesh.h
@@ -9,6 +9,7 @@
#include "Runtime/Graphics/Color.h"
#include "Runtime/Graphics/GfxDevice.h"
+// UIĬϵĶ㲼
struct UIVertexLayout
{
UIVertexLayout(Vector2 pos = Vector2::zero, Vector2 texCoord = Vector2::zero, Color32 col = Color32())
diff --git a/Runtime/GUI/UIQuad.cpp b/Runtime/GUI/UIQuad.cpp
index c57685c..269b805 100644
--- a/Runtime/GUI/UIQuad.cpp
+++ b/Runtime/GUI/UIQuad.cpp
@@ -30,8 +30,6 @@ void UIQuad::Draw()
m_Left, m_Top, // top-left
};
- int n = sizeof(Vector2);
-
float uv[] = {
0, 0,
1, 0,
@@ -39,7 +37,7 @@ void UIQuad::Draw()
0, 1,
};
- int indices[] = {
+ uint16 indices[] = {
0, 1, 3, // right-top
1, 2, 3, // left-bottom
};
@@ -47,7 +45,7 @@ void UIQuad::Draw()
uint8* vb;
uint16* ib;
- g_SharedVBO.GetChunk(sizeof(UIQuadLayout), sizeof(uint16), 4, 6, Primitive_Triangle, (void**)&vb, (void**)&ib);
+ g_SharedVBO.GetChunk(sizeof(UIQuadLayout), sizeof(uint16), nVerts, nIndices, Primitive_Triangle, (void**)&vb, (void**)&ib);
UIQuadLayout* dst = (UIQuadLayout*)vb;
@@ -60,6 +58,6 @@ void UIQuad::Draw()
for (int i = 0; i < nIndices; ++i)
ib[i] = indices[i];
- g_SharedVBO.ReleaseChunk(4, 6);
+ g_SharedVBO.ReleaseChunk(nVerts, nIndices);
g_SharedVBO.DrawChunk(layout);
} \ No newline at end of file
diff --git a/Runtime/Graphics/DynamicVertexBuffer.cpp b/Runtime/Graphics/DynamicVertexBuffer.cpp
index cb59a8b..8a5499a 100644
--- a/Runtime/Graphics/DynamicVertexBuffer.cpp
+++ b/Runtime/Graphics/DynamicVertexBuffer.cpp
@@ -192,11 +192,11 @@ void DynamicVertexBuffer::DrawChunk(CustomVertexLayout& layout)
g_FrameStats.AddTrianglesCount(m_CurIndexCount / 3);
break;
case Primitive_Line:
- glDrawElements(GL_LINE, m_CurIndexCount, indexFormat, indexPtr);
+ glDrawElements(GL_LINES, m_CurIndexCount, indexFormat, indexPtr);
g_FrameStats.AddDrawCall();
break;
case Primitive_Point:
- glDrawElements(GL_POINT, m_CurIndexCount, indexFormat, indexPtr);
+ glDrawElements(GL_POINTS, m_CurIndexCount, indexFormat, indexPtr);
g_FrameStats.AddDrawCall();
break;
}
diff --git a/Runtime/Scripting/GUI/GUI.bind.cpp b/Runtime/Scripting/GUI/GUI.bind.cpp
index a4ee772..e05d373 100644
--- a/Runtime/Scripting/GUI/GUI.bind.cpp
+++ b/Runtime/Scripting/GUI/GUI.bind.cpp
@@ -4,9 +4,110 @@
#include "Runtime/FileSystem/FileJobs.h"
#include "Runtime/GUI/Font.h"
#include "Runtime/GUI/UITextMesh.h"
+#include "Runtime/GUI/utf8.h"
+#include "Runtime/Utilities/StaticInitiator.h"
+#include "Runtime/GUI/UITextMesh.h"
+#include "Runtime/Math/Math.h"
+#include "Runtime/GUI/TextMeshGenerator.h"
+#include "Runtime/Utilities/AutoInvoke.h"
+#include "Editor/Win/Win.h"
+#include "Runtime/GUI/UILine.h"
using namespace std;
using namespace LuaBind;
+
+static std::vector<character::Unicode>* s_Codepoints;
+
+InitializeStaticVariables([]() {
+ s_Codepoints = new std::vector<character::Unicode>();
+});
+
+#undef DrawText
+// GUI.DrawText(font, str, pixelSize, lineHeight, color, anchor, alignment, wordwrap, preferred, encoding)
+static int DrawText(lua_State* L)
+{
+ LUA_BIND_STATE(L);
+
+ Font* font = (Font*)state.GetUserdata<Font>(1);
+ char* buf = (char*)state.GetValue<const char*>(2, "");
+ int pixelSize = state.GetValue<int>(3, 12);
+ int lineHeight = state.GetValue<int>(4, pixelSize + 3);
+ Color32 color = state.GetValue<Color32>(5, Color32::white);
+ int anchor = state.GetValue<int>(6, TextAnchor_UpperLeft);
+ int alignment = state.GetValue<int>(7, TextAlignment_Left);
+ bool wordwrap = state.GetValue<bool>(8, false);
+ int preferred = state.GetValue<int>(9, 0);
+ int encoding = state.GetValue<int>(10, EEncoding::Encoding_UTF8);
+
+ s_Codepoints->clear();
+ InvokeWhenLeave([]() {
+ s_Codepoints->clear();
+ });
+
+ if (encoding == EEncoding::Encoding_UTF8)
+ {
+ while (*buf != 0) {
+ int err;
+ s_Codepoints->push_back(utf8::getu8c(&buf, &err));
+ if (err != 0)
+ {
+ log_warning("Illegal utf8 bytes %d", err);
+ }
+ }
+ }
+ else if (encoding == EEncoding::Encoding_UTF16)
+ {
+ while (*buf != 0) {
+ unsigned short* s = (unsigned short*)(buf);
+ s_Codepoints->push_back(*s);
+ buf += 2;
+ }
+ }
+ else if (encoding == EEncoding::Encoding_ASCII)
+ {
+ while (*buf != 0) {
+ s_Codepoints->push_back(*buf);
+ buf += 1;
+ }
+ }
+
+ font->RenderCharacters(*s_Codepoints, pixelSize);
+
+ UnicodeString str;
+ str.str = s_Codepoints->data();
+ str.length = s_Codepoints->size();
+
+ WipeGLError();
+
+ const UITextMesh* tm = g_TextMeshGenerator.GetTextMesh(str, font, pixelSize, lineHeight, color, (ETextAnchor)anchor, (ETextAlignment)alignment, wordwrap, preferred);
+ tm->Draw();
+
+ WipeGLError();
+
+ return 0;
+}
+
+#undef DrawLine
+// GUI.DrawLine(from, to)
+static int DrawLine(lua_State* L)
+{
+ LUA_BIND_STATE(L);
+
+ Vector2f from, to;
+ from.RestoreFromLuaObject(state, 1);
+ to.RestoreFromLuaObject(state, 2);
+
+ UILine line = UILine(from, to);
+ line.Draw();
+
+ return 0;
+}
+
+static luaL_Reg guiFuncs[] = {
+ { "DrawText", DrawText },
+ { "DrawLine", DrawLine },
+ {0, 0}
+};
int luaopen_GameLab_Engine_GUI(lua_State* L)
{
@@ -21,6 +122,8 @@ int luaopen_GameLab_Engine_GUI(lua_State* L)
state.RegisterNativeClass<Font>();
+ state.RegisterMethods(guiFuncs);
+
LUA_BIND_REGISTER_ENUM(state, "EEncoding",
{ "ASCII", Encoding_ASCII },
{ "UTF8", Encoding_UTF8 },