summaryrefslogtreecommitdiff
path: root/Runtime
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-11-04 12:55:25 +0800
committerchai <chaifix@163.com>2021-11-04 12:55:25 +0800
commitd24f17b88d901b779c81c7434995675eb2a17429 (patch)
treed8f4cfee93d70598ef4b1419316b30acfff0eb04 /Runtime
parent94a9a28de16badb75e66a60efca3b01d31cc0fc6 (diff)
- Internal::
Diffstat (limited to 'Runtime')
-rw-r--r--Runtime/GUI/Font.cpp16
-rw-r--r--Runtime/GUI/UIQuad.cpp8
-rw-r--r--Runtime/Graphics/GfxDevice.cpp9
-rw-r--r--Runtime/Graphics/GfxDevice.h13
-rw-r--r--Runtime/Graphics/PolyLine.cpp6
-rw-r--r--Runtime/Graphics/Texture.cpp3
-rw-r--r--Runtime/Graphics/Texture.h3
-rw-r--r--Runtime/Lua/LuaHelper.cpp25
-rw-r--r--Runtime/Rendering/Quad.cpp7
-rw-r--r--Runtime/Scripting/GL/GL.bind.cpp2
-rw-r--r--Runtime/Scripting/GUI/Font.bind.cpp5
-rw-r--r--Runtime/Scripting/Rendering/Rendering.bind.cpp3
-rw-r--r--Runtime/Scripting/Rendering/Shader.bind.cpp9
13 files changed, 57 insertions, 52 deletions
diff --git a/Runtime/GUI/Font.cpp b/Runtime/GUI/Font.cpp
index 4425b17..a2d3078 100644
--- a/Runtime/GUI/Font.cpp
+++ b/Runtime/GUI/Font.cpp
@@ -188,10 +188,10 @@ bool Font::RenderCharacter(character::Unicode codepoint, int pixelSize)
TextHelper::print_glyph(&s_PixelBuffer[0], w, h);
- GlyphAtals* atlas = RequestAtlas(pixelSize, Internal::Vector2(w, h));
+ GlyphAtals* atlas = RequestAtlas(pixelSize, Vector2(w, h));
Assert(atlas);
- Internal::Rect rect = GetRenderChartAndMove(atlas, Internal::Vector2(w, h));
+ Rect rect = GetRenderChartAndMove(atlas, Vector2(w, h));
try
{
@@ -209,7 +209,7 @@ bool Font::RenderCharacter(character::Unicode codepoint, int pixelSize)
character.atlas = atlas->index;
character.position = rect;
- character.bearing = Internal::Vector2(m_FTFace->glyph->bitmap_left, m_FTFace->glyph->bitmap_top);
+ character.bearing = Vector2(m_FTFace->glyph->bitmap_left, m_FTFace->glyph->bitmap_top);
}
else // space¡¢tab
{
@@ -232,7 +232,7 @@ const GlyphAtals* Font::GetGlyphAtlas(int index)
return &m_Atlases[index];
}
-Internal::Rect Font::GetRenderChartAndMove(GlyphAtals* atlas, Internal::Vector2 preferSize)
+Rect Font::GetRenderChartAndMove(GlyphAtals* atlas, Vector2 preferSize)
{
Rect rect;
Vector2 space;
@@ -264,7 +264,7 @@ Internal::Rect Font::GetRenderChartAndMove(GlyphAtals* atlas, Internal::Vector2
return rect;
}
-GlyphAtals* Font::RequestAtlas(int pixelSize, Internal::Vector2 preferSize)
+GlyphAtals* Font::RequestAtlas(int pixelSize, Vector2 preferSize)
{
GlyphAtals* atlas = NULL;
auto iter = m_AtlasCache.find(pixelSize);
@@ -278,7 +278,7 @@ GlyphAtals* Font::RequestAtlas(int pixelSize, Internal::Vector2 preferSize)
newAtlas.width = m_AtlasSize.x;
newAtlas.height = m_AtlasSize.y;
newAtlas.index = m_Atlases.size();
- newAtlas.cursor = Internal::Vector2(m_AtlasMargin, m_AtlasMargin);
+ newAtlas.cursor = Vector2(m_AtlasMargin, m_AtlasMargin);
m_Atlases.push_back(newAtlas);
atlas = &m_Atlases[m_Atlases.size() - 1];
@@ -307,11 +307,11 @@ Texture* Font::CreateAtlas()
return tex;
}
-bool Font::HasEnoughSpace(GlyphAtals* atlas, Internal::Vector2 preferSize)
+bool Font::HasEnoughSpace(GlyphAtals* atlas, Vector2 preferSize)
{
if (atlas == NULL)
return false;
- Internal::Vector2 space;
+ Vector2 space;
space.x = atlas->width - atlas->cursor.x - m_AtlasMargin;
space.y = atlas->height - atlas->cursor.y - m_AtlasMargin;
if (space.x > preferSize.x && space.y > preferSize.y)
diff --git a/Runtime/GUI/UIQuad.cpp b/Runtime/GUI/UIQuad.cpp
index 089d0e1..e28a772 100644
--- a/Runtime/GUI/UIQuad.cpp
+++ b/Runtime/GUI/UIQuad.cpp
@@ -1,18 +1,18 @@
-#include "../Math/Vector2.h"
#include "../Graphics/GfxDevice.h"
#include "UIQuad.h"
+#include "Runtime/Math/Math.h"
struct UIQuadLayout
{
- Internal::Vector2 position;
- Internal::Vector2 uv;
+ Vector2 position;
+ Vector2 uv;
};
static CustomVertexLayout layout;
InitializeStaticVariables([]() {
VertexAttributeDescriptor POSITION = VertexAttributeDescriptor(0, 2, VertexAttrFormat_Float, sizeof(UIQuadLayout));
- VertexAttributeDescriptor UV = VertexAttributeDescriptor(sizeof(Internal::Vector2), 2, VertexAttrFormat_Float, sizeof(UIQuadLayout));
+ VertexAttributeDescriptor UV = VertexAttributeDescriptor(sizeof(Vector2), 2, VertexAttrFormat_Float, sizeof(UIQuadLayout));
layout.attributes.push_back(POSITION);
layout.attributes.push_back(UV);
diff --git a/Runtime/Graphics/GfxDevice.cpp b/Runtime/Graphics/GfxDevice.cpp
index 2c740ed..e172756 100644
--- a/Runtime/Graphics/GfxDevice.cpp
+++ b/Runtime/Graphics/GfxDevice.cpp
@@ -1,5 +1,6 @@
#include <vector>
#include "GfxDevice.h"
+#include "Runtime/Math/Math.h"
static bool deviceInited = false;
@@ -94,7 +95,7 @@ void GfxDevice::UnuseShader()
glUseProgram(0);
}
-void GfxDevice::SetUniformVec2(const char* name, Internal::Vector2 vec2)
+void GfxDevice::SetUniformVec2(const char* name, Vector2 vec2)
{
if (!m_Shader)
return;
@@ -102,7 +103,7 @@ void GfxDevice::SetUniformVec2(const char* name, Internal::Vector2 vec2)
glUniform2f(loc, vec2.x, vec2.y);
}
-void GfxDevice::SetUniformVec3(const char* name, Internal::Vector3 vec3)
+void GfxDevice::SetUniformVec3(const char* name, Vector3 vec3)
{
if (!m_Shader)
return;
@@ -110,7 +111,7 @@ void GfxDevice::SetUniformVec3(const char* name, Internal::Vector3 vec3)
glUniform3f(loc, vec3.x, vec3.y, vec3.z);
}
-void GfxDevice::SetUniformVec4(const char* name, Internal::Vector4 vec4)
+void GfxDevice::SetUniformVec4(const char* name, Vector4 vec4)
{
if (!m_Shader)
return;
@@ -118,7 +119,7 @@ void GfxDevice::SetUniformVec4(const char* name, Internal::Vector4 vec4)
glUniform4f(loc, vec4.x, vec4.y, vec4.z, vec4.w);
}
-void GfxDevice::SetUniformMat4(const char* name, Internal::Matrix44 mat4)
+void GfxDevice::SetUniformMat4(const char* name, Matrix44 mat4)
{
if (!m_Shader)
return;
diff --git a/Runtime/Graphics/GfxDevice.h b/Runtime/Graphics/GfxDevice.h
index 437696a..f00a58f 100644
--- a/Runtime/Graphics/GfxDevice.h
+++ b/Runtime/Graphics/GfxDevice.h
@@ -1,5 +1,6 @@
#ifndef DEVICE_H
#define DEVICE_H
+#include "Runtime/Math/Math.h"
#include "../Utilities/NonCopyable.h"
#include "../Utilities/Type.h"
@@ -63,10 +64,10 @@ public:
void UseShader(LuaBind::State& state, Shader* shader, int idx);
void UnuseShader();
- void SetUniformVec2(const char* name, Internal::Vector2 vec2);
- void SetUniformVec3(const char* name, Internal::Vector3 vec3);
- void SetUniformVec4(const char* name, Internal::Vector4 vec4);
- void SetUniformMat4(const char* name, Internal::Matrix44 mat4);
+ void SetUniformVec2(const char* name, Vector2 vec2);
+ void SetUniformVec3(const char* name, Vector3 vec3);
+ void SetUniformVec4(const char* name, Vector4 vec4);
+ void SetUniformMat4(const char* name, Matrix44 mat4);
void SetUniformTexture(const char* name, Texture* texture);
void ResetUniformsState();
@@ -79,7 +80,7 @@ public:
DynamicVertexBuffer* GetSharedVBO() { return &m_DynamicVBO; }
- GET_SET(Internal::Color, ClearColor, m_ClearColor);
+ GET_SET(Color, ClearColor, m_ClearColor);
GET_SET(ETextureFilterMode, DefaultFilterMode, m_DefaultFilterMode);
GET_SET(ETextureWrapMode, DefaultWrapMode, m_DefaultWrapMode);
@@ -88,7 +89,7 @@ private:
// äÖȾ״̬
uint m_EnableFlag;
- Internal::Color m_ClearColor;
+ Color m_ClearColor;
EDepthTest m_DepthTest;
EStencilTest m_StencilTest;
EStencilOp m_StencilOp;
diff --git a/Runtime/Graphics/PolyLine.cpp b/Runtime/Graphics/PolyLine.cpp
index 24686f9..279a493 100644
--- a/Runtime/Graphics/PolyLine.cpp
+++ b/Runtime/Graphics/PolyLine.cpp
@@ -1,9 +1,9 @@
#include "PolyLine.h"
-#include "../Math/Vector3.h"
#include "Color.h"
+#include "Runtime/Math/Math.h"
struct PolyLineVBOLayout
{
- Internal::Vector3 position;
- Internal::Color32 color;
+ Vector3 position;
+ Color32 color;
};
diff --git a/Runtime/Graphics/Texture.cpp b/Runtime/Graphics/Texture.cpp
index 0cabd07..19042e9 100644
--- a/Runtime/Graphics/Texture.cpp
+++ b/Runtime/Graphics/Texture.cpp
@@ -1,5 +1,6 @@
#include "ImageData.h"
#include "Texture.h"
+#include "Runtime/Math/Math.h"
using namespace LuaBind;
@@ -196,7 +197,7 @@ Texture::~Texture()
glDeleteTextures(1, &m_GPUID);
}
-void Texture::UpdateSubImage(Internal::Rect rect, int format, int type, const void* data)
+void Texture::UpdateSubImage(Rect rect, int format, int type, const void* data)
{
glBindTexture(GL_TEXTURE_2D, m_GPUID);
diff --git a/Runtime/Graphics/Texture.h b/Runtime/Graphics/Texture.h
index 9633db5..5c23fd7 100644
--- a/Runtime/Graphics/Texture.h
+++ b/Runtime/Graphics/Texture.h
@@ -4,6 +4,7 @@
#include "Runtime/Lua/LuaHelper.h"
#include "../Utilities/UtilMacros.h"
#include "OpenGL.h"
+#include "Runtime/Math/Math.h"
class ImageData;
@@ -66,7 +67,7 @@ public:
Texture(LuaBind::VM* vm, TextureSetting setting, ImageData* imgData)/*throw TextureException*/;
~Texture();
- void UpdateSubImage(Internal::Rect rect, int format, int type, const void* data);
+ void UpdateSubImage(Rect rect, int format, int type, const void* data);
GET(int, Width, m_Width);
GET(int, Height, m_Height);
diff --git a/Runtime/Lua/LuaHelper.cpp b/Runtime/Lua/LuaHelper.cpp
index 2c95043..951f2fe 100644
--- a/Runtime/Lua/LuaHelper.cpp
+++ b/Runtime/Lua/LuaHelper.cpp
@@ -1,17 +1,14 @@
#include "LuaHelper.h"
-#include "Runtime/Math/Vector2.h"
-#include "Runtime/Math/Vector3.h"
-#include "Runtime/Math/Vector4.h"
-#include "Runtime/Math/Matrix44.h"
+#include "Runtime/Math/Math.h"
#include "Runtime/GUI/Font.h"
using namespace LuaBind;
template <>
-Internal::Rect State::GetValue < Internal::Rect >(int idx, const Internal::Rect value)
+Rect State::GetValue < Rect >(int idx, const Rect value)
{
- Internal::Rect rect = value;
+ Rect rect = value;
if (LuaHelper::IsType(*this, "GameLab.Engine.Math.Rect", idx))
{
rect.x = GetField<float>(idx, "x", 0);
@@ -30,9 +27,9 @@ Internal::Rect State::GetValue < Internal::Rect >(int idx, const Internal::Rect
}
template <>
-Internal::Vector2 State::GetValue < Internal::Vector2 >(int idx, const Internal::Vector2 value)
+Vector2 State::GetValue < Vector2 >(int idx, const Vector2 value)
{
- Internal::Vector2 v2 = value;
+ Vector2 v2 = value;
if (LuaHelper::IsType(*this, "GameLab.Engine.Math.Vector2", idx))
{
v2.x = GetField<float>(idx, "x", 0);
@@ -47,9 +44,9 @@ Internal::Vector2 State::GetValue < Internal::Vector2 >(int idx, const Internal:
}
template <>
-Internal::Vector3 State::GetValue < Internal::Vector3 >(int idx, const Internal::Vector3 value)
+Vector3 State::GetValue < Vector3 >(int idx, const Vector3 value)
{
- Internal::Vector3 v3 = value;
+ Vector3 v3 = value;
if (LuaHelper::IsType(*this, "GameLab.Engine.Math.Vector3", idx))
{
v3.x = GetField<float>(idx, "x", 0);
@@ -66,9 +63,9 @@ Internal::Vector3 State::GetValue < Internal::Vector3 >(int idx, const Internal:
}
template <>
-Internal::Vector4 State::GetValue < Internal::Vector4 >(int idx, const Internal::Vector4 value)
+Vector4 State::GetValue < Vector4 >(int idx, const Vector4 value)
{
- Internal::Vector4 v4 = value;
+ Vector4 v4 = value;
if (LuaHelper::IsType(*this, "GameLab.Engine.Math.Vector4", idx))
{
v4.x = GetField<float>(idx, "x", 0);
@@ -87,9 +84,9 @@ Internal::Vector4 State::GetValue < Internal::Vector4 >(int idx, const Internal:
}
template <>
-Internal::Matrix44 State::GetValue < Internal::Matrix44 >(int idx, const Internal::Matrix44 value)
+Matrix44 State::GetValue < Matrix44 >(int idx, const Matrix44 value)
{
- Internal::Matrix44 m4 = value;
+ Matrix44 m4 = value;
if (LuaHelper::IsType(*this, "GameLab.Engine.Math.Matrix44", idx))
{
m4.m[0][0] = GetField<float>(idx, "m00", 0);
diff --git a/Runtime/Rendering/Quad.cpp b/Runtime/Rendering/Quad.cpp
index 4c58674..dae1152 100644
--- a/Runtime/Rendering/Quad.cpp
+++ b/Runtime/Rendering/Quad.cpp
@@ -1,18 +1,19 @@
#include "../Math/Math.h"
#include "Quad.h"
#include "../Graphics/GfxDevice.h"
+#include "Runtime/Math/Math.h"
struct QuadVBOLayout
{
- Internal::Vector3 position;
- Internal::Vector2 uv;
+ Vector3 position;
+ Vector2 uv;
};
static CustomVertexLayout layout;
InitializeStaticVariables([]() {
VertexAttributeDescriptor POSITION = VertexAttributeDescriptor(0, 3, VertexAttrFormat_Float, sizeof(QuadVBOLayout));
- VertexAttributeDescriptor UV = VertexAttributeDescriptor(sizeof(Internal::Vector3), 2, VertexAttrFormat_Float, sizeof(QuadVBOLayout));
+ VertexAttributeDescriptor UV = VertexAttributeDescriptor(sizeof(Vector3), 2, VertexAttrFormat_Float, sizeof(QuadVBOLayout));
layout.attributes.push_back(POSITION);
layout.attributes.push_back(UV);
diff --git a/Runtime/Scripting/GL/GL.bind.cpp b/Runtime/Scripting/GL/GL.bind.cpp
index f2a270b..f97b1e0 100644
--- a/Runtime/Scripting/GL/GL.bind.cpp
+++ b/Runtime/Scripting/GL/GL.bind.cpp
@@ -133,7 +133,7 @@ int Vertex(lua_State* L)
}
else
{
- state.ErrorType(1, "Internal::Vector3 or vector3 table");
+ state.ErrorType(1, "Vector3 or vector3 table");
}
return 0;
}
diff --git a/Runtime/Scripting/GUI/Font.bind.cpp b/Runtime/Scripting/GUI/Font.bind.cpp
index e749303..1928e0e 100644
--- a/Runtime/Scripting/GUI/Font.bind.cpp
+++ b/Runtime/Scripting/GUI/Font.bind.cpp
@@ -6,6 +6,7 @@
#include "Runtime/GUI/utf8.h"
#include "Runtime/Utilities/StaticInitiator.h"
#include "Runtime/GUI/UITextMesh.h"
+#include "Runtime/Math/Math.h"
static std::vector<character::Unicode>* s_Codepoints;
@@ -39,7 +40,7 @@ LUA_BIND_IMPL_METHOD(Font, _New)
{
const char* path = state.GetValue<const char*>(1, "");
TextGeneratingSettings setting;
- setting.atlasSize = state.GetValue<Internal::Vector2>(2, Internal::Vector2(128, 128));
+ setting.atlasSize = state.GetValue<Vector2>(2, Vector2(128, 128));
setting.margin = state.GetValue<int>(3, 0);
setting.padding = state.GetValue<int>(4, 0);
try {
@@ -62,7 +63,7 @@ LUA_BIND_IMPL_METHOD(Font, _New)
return 1;
}
TextGeneratingSettings setting;
- setting.atlasSize = state.GetValue<Internal::Vector2>(2, Internal::Vector2(128, 128));
+ setting.atlasSize = state.GetValue<Vector2>(2, Vector2(128, 128));
setting.margin = state.GetValue<int>(3, 0);
setting.padding = state.GetValue<int>(4, 0);
try {
diff --git a/Runtime/Scripting/Rendering/Rendering.bind.cpp b/Runtime/Scripting/Rendering/Rendering.bind.cpp
index c9332f8..58e95bc 100644
--- a/Runtime/Scripting/Rendering/Rendering.bind.cpp
+++ b/Runtime/Scripting/Rendering/Rendering.bind.cpp
@@ -4,12 +4,13 @@
#include "Runtime/Graphics/GfxDevice.h"
#include "Runtime/GUI/UIQuad.h"
#include "Runtime/GUI/UI9Slicing.h"
+#include "Runtime/Math/Math.h"
// Rendering.DrawUIQuad({})
static int DrawUIQuad(lua_State* L)
{
LUA_BIND_STATE(L);
- Internal::Rect rect = state.GetValue<Internal::Rect>(1, Internal::Rect());
+ Rect rect = state.GetValue<Rect>(1, Rect());
UIQuad quad = UIQuad(rect.x, rect.x + rect.width, rect.y, rect.y + rect.height);
quad.Draw();
return 0;
diff --git a/Runtime/Scripting/Rendering/Shader.bind.cpp b/Runtime/Scripting/Rendering/Shader.bind.cpp
index 08c96f9..4c0c321 100644
--- a/Runtime/Scripting/Rendering/Shader.bind.cpp
+++ b/Runtime/Scripting/Rendering/Shader.bind.cpp
@@ -2,6 +2,7 @@
#include "Runtime/Debug/Log.h"
#include "Runtime/Graphics/GfxDevice.h"
#include "Runtime/Common/DataBuffer.h"
+#include "Runtime/Math/Math.h"
using namespace LuaBind;
@@ -130,7 +131,7 @@ LUA_BIND_IMPL_METHOD(Shader, _SetVector2)
LUA_BIND_CHECK(L, "ST");
cc8* name = state.GetValue(1, "");
- Internal::Vector2 v2 = state.GetValue<Internal::Vector2>(2, Internal::Vector2::zero);
+ Vector2 v2 = state.GetValue<Vector2>(2, Vector2::zero);
g_GfxDevice.SetUniformVec2(name, v2);
return 1;
@@ -144,7 +145,7 @@ LUA_BIND_IMPL_METHOD(Shader, _SetVector3)
LUA_BIND_CHECK(L, "ST");
cc8* name = state.GetValue(1, "");
- Internal::Vector3 v3 = state.GetValue<Internal::Vector3>(2, Internal::Vector3::zero);
+ Vector3 v3 = state.GetValue<Vector3>(2, Vector3::zero);
g_GfxDevice.SetUniformVec3(name, v3);
return 1;
@@ -158,7 +159,7 @@ LUA_BIND_IMPL_METHOD(Shader, _SetVector4)
LUA_BIND_CHECK(L, "ST");
cc8* name = state.GetValue(1, "");
- Internal::Vector4 v4 = state.GetValue<Internal::Vector4>(2, Internal::Vector4::zero);
+ Vector4 v4 = state.GetValue<Vector4>(2, Vector4::zero);
g_GfxDevice.SetUniformVec4(name, v4);
return 1;
@@ -172,7 +173,7 @@ LUA_BIND_IMPL_METHOD(Shader, _SetMatrix4)
LUA_BIND_CHECK(L, "ST");
cc8* name = state.GetValue(1, "");
- Internal::Matrix44 m4 = state.GetValue<Internal::Matrix44>(2, Internal::Matrix44::identity);
+ Matrix44 m4 = state.GetValue<Matrix44>(2, Matrix44::identity);
g_GfxDevice.SetUniformMat4(name, m4);
return 1;