summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-11-03 09:52:26 +0800
committerchai <chaifix@163.com>2021-11-03 09:52:26 +0800
commitc10e0d92f46e5eaf25a69e1fafe5f4dbd8eaab9d (patch)
tree2eb1a91339b35fea68f48b2774355f496519db83
parent3898f2c648b1a731dead8337aad8912d2b8b80d7 (diff)
*misc
-rw-r--r--Data/Resources/Font/simsun.ttcbin0 -> 18214472 bytes
-rw-r--r--Data/Resources/Metatable/Excel/Icons.xlsxbin12425 -> 12447 bytes
-rw-r--r--Data/Resources/Shaders/Editor-Text.glsl7
-rw-r--r--Data/Scripts/Editor/AssetBrowser.lua6
-rw-r--r--Data/Scripts/EditorApplication.lua2
-rw-r--r--Projects/VisualStudio/Editor/Editor.vcxproj9
-rw-r--r--Projects/VisualStudio/Editor/Editor.vcxproj.filters27
-rw-r--r--Runtime/GUI/Font.cpp7
-rw-r--r--Runtime/GUI/TextMeshGenerator.h4
-rw-r--r--Runtime/GUI/UI9Slicing.cpp30
-rw-r--r--Runtime/GUI/UI9Slicing.h25
-rw-r--r--Runtime/GUI/UIMesh.cpp15
-rw-r--r--Runtime/GUI/UIMesh.h32
-rw-r--r--Runtime/GUI/UIQuad.h4
-rw-r--r--Runtime/GUI/UITextMesh.cpp (renamed from Runtime/GUI/TextMesh.cpp)27
-rw-r--r--Runtime/GUI/UITextMesh.h (renamed from Runtime/GUI/TextMesh.h)44
-rw-r--r--Runtime/Math/Math.h4
-rw-r--r--Runtime/Math/MathHelper.h11
-rw-r--r--Runtime/Math/Vector2.h17
-rw-r--r--Runtime/Rendering/DynamicMesh.h3
-rw-r--r--Runtime/Scripting/GUI/Font.bind.cpp4
21 files changed, 222 insertions, 56 deletions
diff --git a/Data/Resources/Font/simsun.ttc b/Data/Resources/Font/simsun.ttc
new file mode 100644
index 0000000..5f22ce3
--- /dev/null
+++ b/Data/Resources/Font/simsun.ttc
Binary files differ
diff --git a/Data/Resources/Metatable/Excel/Icons.xlsx b/Data/Resources/Metatable/Excel/Icons.xlsx
index 7259175..c4c454a 100644
--- a/Data/Resources/Metatable/Excel/Icons.xlsx
+++ b/Data/Resources/Metatable/Excel/Icons.xlsx
Binary files differ
diff --git a/Data/Resources/Shaders/Editor-Text.glsl b/Data/Resources/Shaders/Editor-Text.glsl
index 34412e3..7548507 100644
--- a/Data/Resources/Shaders/Editor-Text.glsl
+++ b/Data/Resources/Shaders/Editor-Text.glsl
@@ -1,3 +1,5 @@
+// 渲染编辑器文字
+
#version 330 core
CMD_BEGIN
@@ -8,6 +10,7 @@ CMD_END
uniform mat4 gamelab_mat_mvp;
uniform sampler2D gamelab_main_tex;
+uniform vec2 gamelab_ui_position;
VSH_BEGIN
layout (location = 0) in vec2 vPos;
@@ -19,7 +22,7 @@ out vec4 color;
void main()
{
- vec2 pos = vPos + vec2(10, 40);
+ vec2 pos = vPos + gamelab_ui_position;
vec4 clip = gamelab_mat_mvp * vec4(pos, -1, 1.0);
gl_Position = clip;
uv = vUV;
@@ -38,7 +41,7 @@ void main()
//vec2 uv = vec2(uv.x, 1 - uv.y);
vec4 sampled = vec4(0.8,0.8,0.8,texture(gamelab_main_tex, uv).r);
sampled *= color;
- // vec4 sampled = vec4(1,1,1,1);
+ //sampled = vec4(1,1,1,1);
FragColor = sampled;
}
FSH_END
diff --git a/Data/Scripts/Editor/AssetBrowser.lua b/Data/Scripts/Editor/AssetBrowser.lua
index ecaecda..0c2d03f 100644
--- a/Data/Scripts/Editor/AssetBrowser.lua
+++ b/Data/Scripts/Editor/AssetBrowser.lua
@@ -27,7 +27,7 @@ AssetBrowser.OnGUI = function(self)
end
local ortho = Matrix44.New()
- ortho:SetOrtho(0, 400, 0, 400, 0.1, 10)
+ ortho:SetOrtho(0, 400, 400, 0, 0.1, 10)
Debug.Log("AssetBrowser.OnGUI()")
GL.ClearColor({0.1,0.1,0.1,1})
@@ -35,9 +35,11 @@ AssetBrowser.OnGUI = function(self)
Engine.Rendering.UseShader(shader)
Engine.Rendering.SetMatrix44("gamelab_mat_mvp", ortho)
+ Engine.Rendering.SetVector2("gamelab_ui_position", {0, 0})
--Engine.Rendering.SetTexture("gamelab_main_tex", tex)
--Engine.Rendering.DrawUIQuad({0, 0, 10, 20})
- _G["default_font"]:GetCharacters("你好世界!Hello,World! Project Window Properties", 12)
+ -- _G["default_font"]:GetCharacters("你好世界!Hello,World! Project Window Properties", 15)
+ _G["default_font"]:GetCharacters("A", 17)
Engine.Rendering.ResetUniformState()
end
diff --git a/Data/Scripts/EditorApplication.lua b/Data/Scripts/EditorApplication.lua
index 103dcdf..0aae504 100644
--- a/Data/Scripts/EditorApplication.lua
+++ b/Data/Scripts/EditorApplication.lua
@@ -113,7 +113,7 @@ local fsh = [[
BeforeMainLoop()
-local font = Engine.GUI.Font.New("./Resources/Font/consola.ttf", {512, 512}, 5, 5)
+local font = Engine.GUI.Font.New("./Resources/Font/simsun.ttc", {512, 512}, 5, 5)
_G["default_font"] = font
while true do
diff --git a/Projects/VisualStudio/Editor/Editor.vcxproj b/Projects/VisualStudio/Editor/Editor.vcxproj
index 83df147..9b2fbe0 100644
--- a/Projects/VisualStudio/Editor/Editor.vcxproj
+++ b/Projects/VisualStudio/Editor/Editor.vcxproj
@@ -200,7 +200,9 @@
<ClCompile Include="..\..\..\Runtime\Graphics\VertexAttribute.cpp" />
<ClCompile Include="..\..\..\Runtime\Graphics\VertexBuffer.cpp" />
<ClCompile Include="..\..\..\Runtime\GUI\Font.cpp" />
- <ClCompile Include="..\..\..\Runtime\GUI\TextMesh.cpp" />
+ <ClCompile Include="..\..\..\Runtime\GUI\UI9Slicing.cpp" />
+ <ClCompile Include="..\..\..\Runtime\GUI\UIMesh.cpp" />
+ <ClCompile Include="..\..\..\Runtime\GUI\UITextMesh.cpp" />
<ClCompile Include="..\..\..\Runtime\GUI\TextMeshGenerator.cpp" />
<ClCompile Include="..\..\..\Runtime\GUI\UIQuad.cpp" />
<ClCompile Include="..\..\..\Runtime\GUI\utf8.cpp" />
@@ -289,7 +291,9 @@
<ClInclude Include="..\..\..\Runtime\Graphics\VertexBuffer.h" />
<ClInclude Include="..\..\..\Runtime\GUI\freetype.h" />
<ClInclude Include="..\..\..\Runtime\GUI\Font.h" />
- <ClInclude Include="..\..\..\Runtime\GUI\TextMesh.h" />
+ <ClInclude Include="..\..\..\Runtime\GUI\UI9Slicing.h" />
+ <ClInclude Include="..\..\..\Runtime\GUI\UIMesh.h" />
+ <ClInclude Include="..\..\..\Runtime\GUI\UITextMesh.h" />
<ClInclude Include="..\..\..\Runtime\GUI\TextMeshGenerator.h" />
<ClInclude Include="..\..\..\Runtime\GUI\UIQuad.h" />
<ClInclude Include="..\..\..\Runtime\GUI\utf8.h" />
@@ -316,6 +320,7 @@
<ClInclude Include="..\..\..\Runtime\Math\AABB.h" />
<ClInclude Include="..\..\..\Runtime\Math\FloatConversion.h" />
<ClInclude Include="..\..\..\Runtime\Math\Math.h" />
+ <ClInclude Include="..\..\..\Runtime\Math\MathHelper.h" />
<ClInclude Include="..\..\..\Runtime\Math\Matrix44.h" />
<ClInclude Include="..\..\..\Runtime\Math\Rect.h" />
<ClInclude Include="..\..\..\Runtime\Math\Vector2.h" />
diff --git a/Projects/VisualStudio/Editor/Editor.vcxproj.filters b/Projects/VisualStudio/Editor/Editor.vcxproj.filters
index e2b1c24..432151c 100644
--- a/Projects/VisualStudio/Editor/Editor.vcxproj.filters
+++ b/Projects/VisualStudio/Editor/Editor.vcxproj.filters
@@ -396,9 +396,6 @@
<ClCompile Include="..\..\..\Runtime\Scripting\GUI\GUI.bind.cpp">
<Filter>Runtime\Scripting\GUI</Filter>
</ClCompile>
- <ClCompile Include="..\..\..\Runtime\GUI\TextMesh.cpp">
- <Filter>Runtime\GUI</Filter>
- </ClCompile>
<ClCompile Include="..\..\..\Runtime\GUI\TextMeshGenerator.cpp">
<Filter>Runtime\GUI</Filter>
</ClCompile>
@@ -408,6 +405,15 @@
<ClCompile Include="..\..\..\Runtime\GUI\UIQuad.cpp">
<Filter>Runtime\GUI</Filter>
</ClCompile>
+ <ClCompile Include="..\..\..\Runtime\GUI\UITextMesh.cpp">
+ <Filter>Runtime\GUI</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\Runtime\GUI\UI9Slicing.cpp">
+ <Filter>Runtime\GUI</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\Runtime\GUI\UIMesh.cpp">
+ <Filter>Runtime\GUI</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\Editor\GUI\Dock.h">
@@ -692,9 +698,6 @@
<ClInclude Include="..\..\..\Runtime\GUI\utf8.h">
<Filter>Runtime\GUI</Filter>
</ClInclude>
- <ClInclude Include="..\..\..\Runtime\GUI\TextMesh.h">
- <Filter>Runtime\GUI</Filter>
- </ClInclude>
<ClInclude Include="..\..\..\Runtime\GUI\TextMeshGenerator.h">
<Filter>Runtime\GUI</Filter>
</ClInclude>
@@ -704,6 +707,18 @@
<ClInclude Include="..\..\..\Runtime\GUI\UIQuad.h">
<Filter>Runtime\GUI</Filter>
</ClInclude>
+ <ClInclude Include="..\..\..\Runtime\GUI\UITextMesh.h">
+ <Filter>Runtime\GUI</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\Runtime\GUI\UIMesh.h">
+ <Filter>Runtime\GUI</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\Runtime\GUI\UI9Slicing.h">
+ <Filter>Runtime\GUI</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\Runtime\Math\MathHelper.h">
+ <Filter>Runtime\Math</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\Runtime\Lua\LuaBind\LuaBindClass.inc">
diff --git a/Runtime/GUI/Font.cpp b/Runtime/GUI/Font.cpp
index 8cdfdf3..614792a 100644
--- a/Runtime/GUI/Font.cpp
+++ b/Runtime/GUI/Font.cpp
@@ -146,8 +146,8 @@ void Font::RenderCharacter(character::Codepoint codepoint, int pixelSize)
int w = m_FTFace->glyph->bitmap.width;
int h = m_FTFace->glyph->bitmap.rows;
-
- //TextHelper::print_glyph(m_FTFace->glyph->bitmap.buffer, w, h);
+
+ TextHelper::print_glyph(m_FTFace->glyph->bitmap.buffer, w, h);
GlyphAtals* atlas = RequestAtlas(pixelSize, Internal::Vector2(w, h));
Assert(atlas);
@@ -173,6 +173,9 @@ void Font::RenderCharacter(character::Codepoint codepoint, int pixelSize)
character.advance = m_FTFace->glyph->advance.x * 1/64.f;
m_Characters.insert(std::pair<character::Hash, Character>(hash, character));
+/*
+ FT_Done_Face(m_FTFace);
+ FT_Done_FreeType(m_FTLibrary);*/
}
const GlyphAtals* Font::GetGlyphAtlas(int index)
diff --git a/Runtime/GUI/TextMeshGenerator.h b/Runtime/GUI/TextMeshGenerator.h
index baeaf16..94bcaa2 100644
--- a/Runtime/GUI/TextMeshGenerator.h
+++ b/Runtime/GUI/TextMeshGenerator.h
@@ -1,6 +1,6 @@
#pragma once
-#include "TextMesh.h"
+#include "UITextMesh.h"
#include "Runtime/Utilities/IIncrementalTask.h"
#include "Font.h"
@@ -24,7 +24,7 @@ public:
class TextMeshGenerator : public Singleton<TextMeshGenerator>
{
public:
- TextMesh* GetTextMesh(const UnicodeString& str);
+ UITextMesh* GetTextMesh(const UnicodeString& str);
private:
diff --git a/Runtime/GUI/UI9Slicing.cpp b/Runtime/GUI/UI9Slicing.cpp
new file mode 100644
index 0000000..01a0143
--- /dev/null
+++ b/Runtime/GUI/UI9Slicing.cpp
@@ -0,0 +1,30 @@
+#include "UI9Slicing.h"
+
+UI9Slicing::UI9Slicing(ESlicing mode, Vector2 horizontal, Vector2 vertical, Vector2 texPixelSize, Vector2 size)
+{
+ m_Slicing = mode;
+ m_Horizontal = horizontal.Clamp(0, texPixelSize.x, 0, texPixelSize.x);
+ m_Vertical = vertical.Clamp(0, texPixelSize.y, 0, texPixelSize.y);
+
+ if (m_Horizontal[0] + m_Horizontal[1] > texPixelSize.x || m_Vertical[0] + m_Vertical[1] > texPixelSize.y)
+ {
+ throw UIMeshException("UI9Slicing wrong parameter.");
+ }
+ m_TexSize = texPixelSize;
+ m_Size = size;
+}
+
+void UI9Slicing::Draw()
+{
+
+
+ uint8* vb;
+ uint16* ib;
+
+ g_SharedVBO.GetChunk(sizeof(UIVertexLayout), sizeof(uint16), 4, 6, Primitive_Triangle, (void**)&vb, (void**)&ib);
+
+
+
+ g_SharedVBO.ReleaseChunk(4, 6);
+ g_SharedVBO.DrawChunk(UIMesh::s_UIVertexLayout);
+}
diff --git a/Runtime/GUI/UI9Slicing.h b/Runtime/GUI/UI9Slicing.h
new file mode 100644
index 0000000..c88ba05
--- /dev/null
+++ b/Runtime/GUI/UI9Slicing.h
@@ -0,0 +1,25 @@
+#pragma once
+
+#include "UIMesh.h"
+
+enum ESlicing
+{
+ Slicing_Simple,
+ Slicing_Tiled,
+};
+
+// Ź
+class UI9Slicing : public UIMesh
+{
+public:
+ UI9Slicing(ESlicing mode, Vector2 horizontal, Vector2 vertical, Vector2 texPixelSize, Vector2 size)/*throw UIMeshException*/;
+
+ void Draw() override;
+
+private:
+ ESlicing m_Slicing;
+ Vector2 m_Horizontal; // иߵߺұߵľ
+ Vector2 m_Vertical; // ͬ
+ Vector2 m_TexSize;
+ Vector2 m_Size;
+};
diff --git a/Runtime/GUI/UIMesh.cpp b/Runtime/GUI/UIMesh.cpp
new file mode 100644
index 0000000..a68b6fd
--- /dev/null
+++ b/Runtime/GUI/UIMesh.cpp
@@ -0,0 +1,15 @@
+#include "UIMesh.h"
+
+CustomVertexLayout UIMesh::s_UIVertexLayout;
+unsigned int UIMesh::s_SizePerVertex;
+
+InitializeStaticVariables([]() {
+ VertexAttributeDescriptor POSITION = VertexAttributeDescriptor(0, 2, VertexAttrFormat_Float, sizeof(UIVertexLayout));
+ VertexAttributeDescriptor UV = VertexAttributeDescriptor(sizeof(Vector2), 2, VertexAttrFormat_Float, sizeof(UIVertexLayout));
+ VertexAttributeDescriptor COLOR = VertexAttributeDescriptor(sizeof(Vector2) * 2, 4, VertexAttrFormat_Unsigned_Byte, sizeof(UIVertexLayout), true);
+ UIMesh::s_UIVertexLayout.attributes.push_back(POSITION);
+ UIMesh::s_UIVertexLayout.attributes.push_back(UV);
+ UIMesh::s_UIVertexLayout.attributes.push_back(COLOR);
+
+ UIMesh::s_SizePerVertex = sizeof(UIVertexLayout);
+});
diff --git a/Runtime/GUI/UIMesh.h b/Runtime/GUI/UIMesh.h
new file mode 100644
index 0000000..dd83e6e
--- /dev/null
+++ b/Runtime/GUI/UIMesh.h
@@ -0,0 +1,32 @@
+#pragma once
+
+#include "Runtime/Utilities/Exception.h"
+#include "Runtime/Rendering/DynamicMesh.h"
+#include "Runtime/Math/Math.h"
+#include "Runtime/Utilities/StaticInitiator.h"
+#include "Runtime/Graphics/CustomVertexLayout.h"
+#include "Runtime/Graphics/DefaultVertexLayout.h"
+#include "Runtime/Graphics/Color.h"
+#include "Runtime/Graphics/GfxDevice.h"
+
+struct UIVertexLayout
+{
+ Vector2 position;
+ Vector2 uv;
+ Color32 color;
+};
+
+CustomException(UIMeshException);
+
+// еUIMeshϽΪԭ
+class UIMesh : public DynamicMesh
+{
+public:
+ UIMesh() : DynamicMesh() {}
+ virtual ~UIMesh() {}
+
+ virtual void Draw() = 0;
+
+ static CustomVertexLayout s_UIVertexLayout;
+ static unsigned int s_SizePerVertex;
+};
diff --git a/Runtime/GUI/UIQuad.h b/Runtime/GUI/UIQuad.h
index bcd95a0..278848a 100644
--- a/Runtime/GUI/UIQuad.h
+++ b/Runtime/GUI/UIQuad.h
@@ -1,8 +1,8 @@
#pragma once
-#include "../Rendering/DynamicMesh.h"
#include "../Utilities/StaticInitiator.h"
+#include "UIMesh.h"
-class UIQuad : public DynamicMesh
+class UIQuad : public UIMesh
{
public :
UIQuad(float l, float r, float t, float b)
diff --git a/Runtime/GUI/TextMesh.cpp b/Runtime/GUI/UITextMesh.cpp
index 2f66170..6a10f88 100644
--- a/Runtime/GUI/TextMesh.cpp
+++ b/Runtime/GUI/UITextMesh.cpp
@@ -2,7 +2,7 @@
#include "Runtime/Utilities/StaticInitiator.h"
#include "../Math/Math.h"
#include "../Graphics/Color.h"
-#include "TextMesh.h"
+#include "UITextMesh.h"
#include "../Graphics/DefaultVertexLayout.h"
#include "Runtime/Debug/Log.h"
#include <vector>
@@ -50,9 +50,16 @@ InitializeStaticVariables([]() {
s_SizePerText = sizeof(TextMeshVBOLayout) * 4;
});
-// һܻԲͬatlasTextMeshʱú
+// һܻԲͬatlasUITextMeshʱú
-TextMesh::TextMesh(const UnicodeString& str, Font* font,int pixelSize, ETextAnchor anchor, ETextAlignment alignment)
+// Ҫ֧
+// * С
+// * ê
+// * 뷽ʽ
+// *
+// * ɫ
+
+UITextMesh::UITextMesh(const UnicodeString& str, Font* font,int pixelSize, ETextAnchor anchor, ETextAlignment alignment)
{
m_Font = font;
s_TextInfos.clear();
@@ -101,13 +108,13 @@ TextMesh::TextMesh(const UnicodeString& str, Font* font,int pixelSize, ETextAnch
TextInfo& text = texts[i];
int vOff = i * s_VertexPerText;
+ // Ͻԭ
float pos[] = {
- text.offset + text.ch->bearing.x, text.ch->bearing.y - text.ch->position.height, // bottom-left
- text.offset + text.ch->bearing.x + text.ch->position.width, text.ch->bearing.y - text.ch->position.height, // bottom-right
- text.offset + text.ch->bearing.x + text.ch->position.width, text.ch->bearing.y, // top-right
- text.offset + text.ch->bearing.x, text.ch->bearing.y, // top-left
+ text.offset + text.ch->bearing.x, pixelSize - text.ch->bearing.y + text.ch->position.height, // bottom-left
+ text.offset + text.ch->bearing.x + text.ch->position.width, pixelSize - text.ch->bearing.y + text.ch->position.height, // bottom-right
+ text.offset + text.ch->bearing.x + text.ch->position.width, pixelSize - text.ch->bearing.y, // top-right
+ text.offset + text.ch->bearing.x, pixelSize - text.ch->bearing.y, // top-left
};
- // ϽΪUVԭ㣬shaderʱҪy
Vector4 uvQuad = Vector4(text.ch->position.x / atlasSize.x, text.ch->position.y / atlasSize.y, text.ch->position.width / atlasSize.x, text.ch->position.height / atlasSize.y);
float uv[] = {
uvQuad.x, uvQuad.y + uvQuad.w,
@@ -132,14 +139,14 @@ TextMesh::TextMesh(const UnicodeString& str, Font* font,int pixelSize, ETextAnch
}
vb->FlushChunk(s_VertexPerText * textCount, s_IndicesPerText * textCount);
-
+
m_VBOs.insert(std::pair<int, VertexBuffer*>(atlasIndex, vb));
}
WipeGLError();
}
-void TextMesh::Draw()
+void UITextMesh::Draw()
{
for (auto subText : m_VBOs)
{
diff --git a/Runtime/GUI/TextMesh.h b/Runtime/GUI/UITextMesh.h
index c5f05a2..c88e52f 100644
--- a/Runtime/GUI/TextMesh.h
+++ b/Runtime/GUI/UITextMesh.h
@@ -1,13 +1,13 @@
-#pragma once
-#include "../Graphics/VertexBuffer.h"
-#include "Font.h"
-#include "Runtime/Utilities/Exception.h"
-#include <unordered_map>
-
-CustomException(TextMeshException);
-
-enum ETextAnchor
-{
+#pragma once
+#include "../Graphics/VertexBuffer.h"
+#include "Font.h"
+#include "Runtime/Utilities/Exception.h"
+#include <unordered_map>
+
+CustomException(TextMeshException);
+
+enum ETextAnchor
+{
TextAnchor_UpperLeft,
TextAnchor_UpperCenter,
TextAnchor_UpperRight,
@@ -17,9 +17,9 @@ enum ETextAnchor
TextAnchor_LowerLeft,
TextAnchor_LowerCenter,
TextAnchor_LowerRight,
- TextAnchor_DontCare
-};
-
+ TextAnchor_DontCare
+};
+
enum ETextAlignment {
TextAlignment_Left,
TextAlignment_Center,
@@ -27,19 +27,19 @@ enum ETextAlignment {
TextAlignment_Auto,
};
-typedef unsigned long long TextMeshHash;
-
-namespace TextHelper
-{
- TextMeshHash GetTextMeshHash();
-}
+typedef unsigned long long TextMeshHash;
+
+namespace TextHelper
+{
+ TextMeshHash GetTextMeshHash();
+}
-class TextMesh
+class UITextMesh
{
public:
- TextMesh(const UnicodeString& str, Font* font, int pixelSize, ETextAnchor anchor, ETextAlignment alignment)/*throw TextMeshException*/;
+ UITextMesh(const UnicodeString& str, Font* font, int pixelSize, ETextAnchor anchor, ETextAlignment alignment)/*throw TextMeshException*/;
- ~TextMesh();
+ ~UITextMesh();
void Draw();
diff --git a/Runtime/Math/Math.h b/Runtime/Math/Math.h
index aaeb264..5e08613 100644
--- a/Runtime/Math/Math.h
+++ b/Runtime/Math/Math.h
@@ -6,9 +6,7 @@
#include "Matrix44.h"
#include "FloatConversion.h"
#include "Rect.h"
-
-#define max(a, b)\
-(a)>(b)?(a):(b)
+#include "MathHelper.h"
typedef Internal::Vector2 Vector2;
typedef Internal::Vector3 Vector3;
diff --git a/Runtime/Math/MathHelper.h b/Runtime/Math/MathHelper.h
new file mode 100644
index 0000000..3f8754a
--- /dev/null
+++ b/Runtime/Math/MathHelper.h
@@ -0,0 +1,11 @@
+#pragma once
+
+#define max(a, b)\
+(a)>(b)?(a):(b)
+
+#define min(a, b)\
+(a)<(b)?(a):(b)
+
+#define clamp(v, lo, hi)\
+max((lo), min((v), (hi)))
+
diff --git a/Runtime/Math/Vector2.h b/Runtime/Math/Vector2.h
index 27cf312..9d7e4e9 100644
--- a/Runtime/Math/Vector2.h
+++ b/Runtime/Math/Vector2.h
@@ -1,4 +1,6 @@
#pragma once
+#include "MathHelper.h"
+#include "Runtime/Utilities/Assert.h"
namespace Internal
{
@@ -15,6 +17,21 @@ namespace Internal
this->y = y;
}
+ Vector2 Clamp(float xmin, float xmax, float ymin, float ymax)
+ {
+ Vector2 v;
+ v.x = clamp(x, xmin, xmax);
+ v.y = clamp(y, ymin, ymax);
+ return v;
+ }
+
+ float operator[](int i)
+ {
+ if (i == 0) return x;
+ else if (i == 1) return y;
+ Assert(false);
+ }
+
bool operator == (const Vector2& v) const
{
return v.x == x && v.y == y;
diff --git a/Runtime/Rendering/DynamicMesh.h b/Runtime/Rendering/DynamicMesh.h
index 3cbb6f6..01babfc 100644
--- a/Runtime/Rendering/DynamicMesh.h
+++ b/Runtime/Rendering/DynamicMesh.h
@@ -5,6 +5,9 @@
class DynamicMesh
{
public:
+ DynamicMesh() {};
+ virtual ~DynamicMesh() {};
+
virtual void Draw() = 0;
};
diff --git a/Runtime/Scripting/GUI/Font.bind.cpp b/Runtime/Scripting/GUI/Font.bind.cpp
index 733fcf1..2d01925 100644
--- a/Runtime/Scripting/GUI/Font.bind.cpp
+++ b/Runtime/Scripting/GUI/Font.bind.cpp
@@ -5,7 +5,7 @@
#include "Runtime/Common/DataBuffer.h"
#include "Runtime/GUI/utf8.h"
#include "Runtime/Utilities/StaticInitiator.h"
-#include "Runtime/GUI/TextMesh.h"
+#include "Runtime/GUI/UITextMesh.h"
static std::vector<character::Codepoint>* s_Codepoints;
@@ -134,7 +134,7 @@ LUA_BIND_IMPL_METHOD(Font, _GetCharacters)
WipeGLError();
- TextMesh* tm = new TextMesh(str, self, size, ETextAnchor::TextAnchor_MiddleLeft, ETextAlignment::TextAlignment_Left);
+ UITextMesh* tm = new UITextMesh(str, self, size, ETextAnchor::TextAnchor_MiddleLeft, ETextAlignment::TextAlignment_Left);
tm->Draw();
return 0;