summaryrefslogtreecommitdiff
path: root/source/libs/asura-lib-core/graphics
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-03-27 09:07:54 +0800
committerchai <chaifix@163.com>2019-03-27 09:07:54 +0800
commit66c5fdc564dd892ed265132d6c1378dbe3cebcee (patch)
tree909848ed622b35c8653c961c9ebed8c574bb150e /source/libs/asura-lib-core/graphics
parentd9041d6e12ded456c17622f7f2e7bbacb9e99b1a (diff)
*misc
Diffstat (limited to 'source/libs/asura-lib-core/graphics')
-rw-r--r--source/libs/asura-lib-core/graphics/binding/_canvas.cpp46
-rw-r--r--source/libs/asura-lib-core/graphics/binding/_color.cpp54
-rw-r--r--source/libs/asura-lib-core/graphics/binding/_color32.cpp86
-rw-r--r--source/libs/asura-lib-core/graphics/binding/_image.cpp54
-rw-r--r--source/libs/asura-lib-core/graphics/binding/_image_data.cpp42
-rw-r--r--source/libs/asura-lib-core/graphics/binding/_mesh2d.cpp21
-rw-r--r--source/libs/asura-lib-core/graphics/binding/_mesh2d_data.cpp9
-rw-r--r--source/libs/asura-lib-core/graphics/binding/_shader.cpp116
-rw-r--r--source/libs/asura-lib-core/graphics/binding/_sprite_batch.cpp21
-rw-r--r--source/libs/asura-lib-core/graphics/binding/_window.cpp11
-rw-r--r--source/libs/asura-lib-core/graphics/canvas.h6
-rw-r--r--source/libs/asura-lib-core/graphics/color.cpp89
-rw-r--r--source/libs/asura-lib-core/graphics/color.h51
-rw-r--r--source/libs/asura-lib-core/graphics/color32.cpp39
-rw-r--r--source/libs/asura-lib-core/graphics/color32.h51
-rw-r--r--source/libs/asura-lib-core/graphics/image.h21
-rw-r--r--source/libs/asura-lib-core/graphics/image_decode_task.cpp (renamed from source/libs/asura-lib-core/graphics/binding/_gif.cpp)0
-rw-r--r--source/libs/asura-lib-core/graphics/image_decode_task.h25
-rw-r--r--source/libs/asura-lib-core/graphics/image_decoder.h6
-rw-r--r--source/libs/asura-lib-core/graphics/mesh2d.h4
-rw-r--r--source/libs/asura-lib-core/graphics/png_decoder.h4
-rw-r--r--source/libs/asura-lib-core/graphics/render_state.h5
-rw-r--r--source/libs/asura-lib-core/graphics/render_target.h10
-rw-r--r--source/libs/asura-lib-core/graphics/shader.h51
-rw-r--r--source/libs/asura-lib-core/graphics/sprite_batch.h2
-rw-r--r--source/libs/asura-lib-core/graphics/stb_decoder.h4
-rw-r--r--source/libs/asura-lib-core/graphics/texture.h14
-rw-r--r--source/libs/asura-lib-core/graphics/window.h45
-rw-r--r--source/libs/asura-lib-core/graphics/window_impl_sdl.cpp0
-rw-r--r--source/libs/asura-lib-core/graphics/window_impl_sdl.h0
30 files changed, 587 insertions, 300 deletions
diff --git a/source/libs/asura-lib-core/graphics/binding/_canvas.cpp b/source/libs/asura-lib-core/graphics/binding/_canvas.cpp
index e69de29..7927995 100644
--- a/source/libs/asura-lib-core/graphics/binding/_canvas.cpp
+++ b/source/libs/asura-lib-core/graphics/binding/_canvas.cpp
@@ -0,0 +1,46 @@
+#include "../canvas.h"
+
+using namespace std;
+
+namespace AsuraEngine
+{
+ namespace Graphics
+ {
+
+ LUAX_REGISTRY(Canvas)
+ {
+ LUAX_REGISTER_METHODS(state,
+ { "SetSize", _SetSize },
+ { "Bind", _Bind },
+ { "Unbind", _Unbind }
+ );
+ }
+
+ LUAX_POSTPROCESS(Canvas)
+ {
+
+ }
+
+ // canvas:SetSize()
+ LUAX_IMPL_METHOD(Canvas, _SetSize)
+ {
+ LUAX_PREPARE(L, Canvas);
+
+ }
+
+ // canvas:Bind()
+ LUAX_IMPL_METHOD(Canvas, _Bind)
+ {
+ LUAX_PREPARE(L, Canvas);
+
+ }
+
+ // canvas:Unbind()
+ LUAX_IMPL_METHOD(Canvas, _Unbind)
+ {
+ LUAX_PREPARE(L, Canvas);
+
+ }
+
+ }
+}
diff --git a/source/libs/asura-lib-core/graphics/binding/_color.cpp b/source/libs/asura-lib-core/graphics/binding/_color.cpp
index e69de29..11e80a1 100644
--- a/source/libs/asura-lib-core/graphics/binding/_color.cpp
+++ b/source/libs/asura-lib-core/graphics/binding/_color.cpp
@@ -0,0 +1,54 @@
+#include "../color.h"
+
+using namespace std;
+
+namespace AsuraEngine
+{
+ namespace Graphics
+ {
+
+ LUAX_REGISTRY(Color)
+ {
+ LUAX_REGISTER_METHODS(state,
+ { "ToColor32", _ToColor32 },
+ { "SetColor", _SetColor },
+ { "GetColor", _GetColor },
+ { "Multiply", _Multiply }
+ );
+ }
+
+ LUAX_POSTPROCESS(Color)
+ {
+
+ }
+
+ // color:ToColor32()
+ LUAX_IMPL_METHOD(Color, _ToColor32)
+ {
+ LUAX_PREPARE(L, Color);
+
+ }
+
+ // color:SetColor()
+ LUAX_IMPL_METHOD(Color, _SetColor)
+ {
+ LUAX_PREPARE(L, Color);
+
+ }
+
+ // color:GetColor()
+ LUAX_IMPL_METHOD(Color, _GetColor)
+ {
+ LUAX_PREPARE(L, Color);
+
+ }
+
+ // color:Multiply()
+ LUAX_IMPL_METHOD(Color, _Multiply)
+ {
+ LUAX_PREPARE(L, Color);
+
+ }
+
+ }
+}
diff --git a/source/libs/asura-lib-core/graphics/binding/_color32.cpp b/source/libs/asura-lib-core/graphics/binding/_color32.cpp
new file mode 100644
index 0000000..7095866
--- /dev/null
+++ b/source/libs/asura-lib-core/graphics/binding/_color32.cpp
@@ -0,0 +1,86 @@
+#include "../color32.h"
+
+using namespace std;
+
+namespace AsuraEngine
+{
+ namespace Graphics
+ {
+
+ LUAX_REGISTRY(Color32)
+ {
+ LUAX_REGISTER_METHODS(state,
+ { "ToColor", _ToColor },
+ { "GetRed", _GetRed },
+ { "GetGreen", _GetGreen },
+ { "GetBlue", _GetBlue },
+ { "GetAlpha", _GetAlpha },
+ { "Multiply", _Multiply },
+ { "Index", _Index },
+ { "NewIndex", _NewIndex }
+ );
+ }
+
+ LUAX_POSTPROCESS(Color32)
+ {
+
+ }
+
+ // color32:ToColor()
+ LUAX_IMPL_METHOD(Color32, _ToColor)
+ {
+ LUAX_PREPARE(L, Color32);
+
+ }
+
+ // color32:GetRed()
+ LUAX_IMPL_METHOD(Color32, _GetRed)
+ {
+ LUAX_PREPARE(L, Color32);
+
+ }
+
+ // color32:GetGreen()
+ LUAX_IMPL_METHOD(Color32, _GetGreen)
+ {
+ LUAX_PREPARE(L, Color32);
+
+ }
+
+ // color32:GetBlue()
+ LUAX_IMPL_METHOD(Color32, _GetBlue)
+ {
+ LUAX_PREPARE(L, Color32);
+
+ }
+
+ // color32:GetAlpha()
+ LUAX_IMPL_METHOD(Color32, _GetAlpha)
+ {
+ LUAX_PREPARE(L, Color32);
+
+ }
+
+ // color32:Multiply()
+ LUAX_IMPL_METHOD(Color32, _Multiply)
+ {
+ LUAX_PREPARE(L, Color32);
+
+ }
+
+ // color32:Index()
+ LUAX_IMPL_METHOD(Color32, _Index)
+ {
+ LUAX_PREPARE(L, Color32);
+
+ }
+
+ // color32:NewIndex()
+ LUAX_IMPL_METHOD(Color32, _NewIndex)
+ {
+ LUAX_PREPARE(L, Color32);
+
+ }
+
+ }
+}
diff --git a/source/libs/asura-lib-core/graphics/binding/_image.cpp b/source/libs/asura-lib-core/graphics/binding/_image.cpp
index e69de29..7c1034c 100644
--- a/source/libs/asura-lib-core/graphics/binding/_image.cpp
+++ b/source/libs/asura-lib-core/graphics/binding/_image.cpp
@@ -0,0 +1,54 @@
+#include "../image.h"
+
+using namespace std;
+
+namespace AsuraEngine
+{
+ namespace Graphics
+ {
+
+ LUAX_REGISTRY(Image)
+ {
+ LUAX_REGISTER_METHODS(state,
+ { "Load", _Load },
+ { "GetWidth", _GetWidth },
+ { "GetHeight", _GetHeight },
+ { "GetSize", _GetSize }
+ );
+ }
+
+ LUAX_POSTPROCESS(Image)
+ {
+
+ }
+
+ // image:Load()
+ LUAX_IMPL_METHOD(Image, _Load)
+ {
+ LUAX_PREPARE(L, Image);
+
+ }
+
+ // image:GetWidth()
+ LUAX_IMPL_METHOD(Image, _GetWidth)
+ {
+ LUAX_PREPARE(L, Image);
+
+ }
+
+ // image:GetHeight()
+ LUAX_IMPL_METHOD(Image, _GetHeight)
+ {
+ LUAX_PREPARE(L, Image);
+
+ }
+
+ // image:GetSize()
+ LUAX_IMPL_METHOD(Image, _GetSize)
+ {
+ LUAX_PREPARE(L, Image);
+
+ }
+
+ }
+}
diff --git a/source/libs/asura-lib-core/graphics/binding/_image_data.cpp b/source/libs/asura-lib-core/graphics/binding/_image_data.cpp
index 72e33da..3ff38f9 100644
--- a/source/libs/asura-lib-core/graphics/binding/_image_data.cpp
+++ b/source/libs/asura-lib-core/graphics/binding/_image_data.cpp
@@ -1,62 +1,70 @@
#include "../image_data.h"
-using namespace Luax;
+using namespace std;
-namespace AsuraEngine
+namespace AsuraEngine
{
- namespace Graphics
+ namespace Graphics
{
-
+
LUAX_REGISTRY(ImageData)
{
-
+ LUAX_REGISTER_METHODS(state,
+ { "New", _New },
+ { "GetPixel", _GetPixel },
+ { "GetSize", _GetSize },
+ { "GetWidth", _GetWidth },
+ { "GetHeight", _GetHeight },
+ { "GetPixelFormat", _GetPixelFormat }
+ );
}
LUAX_POSTPROCESS(ImageData)
{
- LUAX_REGISTER_ENUM(state, "EBlendMode",
- { "Additive", 1 }
- );
- LUAX_REGISTER_ENUM(state, "EPixelFormat",
- { "RGBA32", 1 }
- );
+
}
- // imagedata = ImageData.New(databuffer)
+ // ImageData.New()
LUAX_IMPL_METHOD(ImageData, _New)
{
LUAX_STATE(L);
- Filesystem::DataBuffer* db = state.CheckUserdata<Filesystem::DataBuffer>(1);
- ImageData* image = new ImageData(*db);
- image->PushLuaxUserdata(state);
- return 1;
}
+ // imagedata:GetPixel()
LUAX_IMPL_METHOD(ImageData, _GetPixel)
{
+ LUAX_PREPARE(L, ImageData);
}
+ // imagedata:GetSize()
LUAX_IMPL_METHOD(ImageData, _GetSize)
{
+ LUAX_PREPARE(L, ImageData);
}
+ // imagedata:GetWidth()
LUAX_IMPL_METHOD(ImageData, _GetWidth)
{
+ LUAX_PREPARE(L, ImageData);
}
+ // imagedata:GetHeight()
LUAX_IMPL_METHOD(ImageData, _GetHeight)
{
+ LUAX_PREPARE(L, ImageData);
}
+ // imagedata:GetPixelFormat()
LUAX_IMPL_METHOD(ImageData, _GetPixelFormat)
{
+ LUAX_PREPARE(L, ImageData);
}
}
-} \ No newline at end of file
+}
diff --git a/source/libs/asura-lib-core/graphics/binding/_mesh2d.cpp b/source/libs/asura-lib-core/graphics/binding/_mesh2d.cpp
index e69de29..07e9f12 100644
--- a/source/libs/asura-lib-core/graphics/binding/_mesh2d.cpp
+++ b/source/libs/asura-lib-core/graphics/binding/_mesh2d.cpp
@@ -0,0 +1,21 @@
+#include "../mesh2d.h"
+
+using namespace std;
+
+namespace AsuraEngine
+{
+ namespace Graphics
+ {
+
+ LUAX_REGISTRY(Mesh2D)
+ {
+
+ }
+
+ LUAX_POSTPROCESS(Mesh2D)
+ {
+
+ }
+
+ }
+}
diff --git a/source/libs/asura-lib-core/graphics/binding/_mesh2d_data.cpp b/source/libs/asura-lib-core/graphics/binding/_mesh2d_data.cpp
deleted file mode 100644
index 6e15052..0000000
--- a/source/libs/asura-lib-core/graphics/binding/_mesh2d_data.cpp
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace AsuraEngine
-{
- namespace Graphics
- {
-
-
-
- }
-} \ No newline at end of file
diff --git a/source/libs/asura-lib-core/graphics/binding/_shader.cpp b/source/libs/asura-lib-core/graphics/binding/_shader.cpp
index 2f2f507..a06e54b 100644
--- a/source/libs/asura-lib-core/graphics/binding/_shader.cpp
+++ b/source/libs/asura-lib-core/graphics/binding/_shader.cpp
@@ -1,114 +1,126 @@
#include "../shader.h"
-using namespace Luax;
+using namespace std;
-namespace AsuraEngine
+namespace AsuraEngine
{
- namespace Graphics
+ namespace Graphics
{
-
- void Shader::RegisterLuaxClass(LuaxState& state)
+
+ LUAX_REGISTRY(Shader)
{
+ LUAX_REGISTER_METHODS(state,
+ { "New", _New },
+ { "Use", _Use },
+ { "Unuse", _Unuse },
+ { "Load", _Load },
+ { "HasUniform", _HasUniform },
+ { "GetUniformLocation", _GetUniformLocation },
+ { "SetBuiltInUniforms", _SetBuiltInUniforms },
+ { "SetUniformFloat", _SetUniformFloat },
+ { "SetUniformTexture", _SetUniformTexture },
+ { "SetUniformVector2", _SetUniformVector2 },
+ { "SetUniformVector3", _SetUniformVector3 },
+ { "SetUniformVector4", _SetUniformVector4 },
+ { "SetUniformColor", _SetUniformColor }
+ );
+ }
- LuaxEnum EBuiltIn[] = {
- {0, 0}
- };
-
- state.RegisterEnum("EBuiltIn", EBuiltIn);
+ LUAX_POSTPROCESS(Shader)
+ {
}
- void Shader::RegisterLuaxPostprocess(LuaxState& state)
+ // Shader.New()
+ LUAX_IMPL_METHOD(Shader, _New)
{
+ LUAX_STATE(L);
}
- ///
- /// shaderΪ
- ///
- int Shader::l_Use(lua_State* L)
+ // shader:Use()
+ LUAX_IMPL_METHOD(Shader, _Use)
{
- LUAX_STATE(L);
+ LUAX_PREPARE(L, Shader);
}
- ///
- /// shaderΪǻ
- ///
- int Shader::l_Unuse(lua_State* L)
+ // shader:Unuse()
+ LUAX_IMPL_METHOD(Shader, _Unuse)
{
- LUAX_STATE(L);
+ LUAX_PREPARE(L, Shader);
}
- ///
- /// ɫйshaderɹtrueʧܷfalse
- ///
- int Shader::l_Load(lua_State* L)
+ // shader:Load()
+ LUAX_IMPL_METHOD(Shader, _Load)
{
- LUAX_STATE(L);
+ LUAX_PREPARE(L, Shader);
}
- ///
- /// жshaderǷuniformзtrue,򷵻false
- ///
- int Shader::l_HasUniform(lua_State* L)
+ // shader:HasUniform()
+ LUAX_IMPL_METHOD(Shader, _HasUniform)
{
- LUAX_STATE(L);
+ LUAX_PREPARE(L, Shader);
}
- ///
- /// uniformslocationûuniformnil򷵻ضӦloc
- ///
- int Shader::l_GetUniformLocation(lua_State* L)
+ // shader:GetUniformLocation()
+ LUAX_IMPL_METHOD(Shader, _GetUniformLocation)
{
- LUAX_STATE(L);
+ LUAX_PREPARE(L, Shader);
}
- int Shader::l_SetBuiltInUniforms(lua_State* L)
+ // shader:SetBuiltInUniforms()
+ LUAX_IMPL_METHOD(Shader, _SetBuiltInUniforms)
{
- LUAX_STATE(L);
-
+ LUAX_PREPARE(L, Shader);
+
}
- int Shader::l_SetUniformFloat(lua_State* L)
+ // shader:SetUniformFloat()
+ LUAX_IMPL_METHOD(Shader, _SetUniformFloat)
{
- LUAX_STATE(L);
+ LUAX_PREPARE(L, Shader);
}
- int Shader::l_SetUniformTexture(lua_State* L)
+ // shader:SetUniformTexture()
+ LUAX_IMPL_METHOD(Shader, _SetUniformTexture)
{
- LUAX_STATE(L);
+ LUAX_PREPARE(L, Shader);
}
- int Shader::l_SetUniformVector2(lua_State* L)
+ // shader:SetUniformVector2()
+ LUAX_IMPL_METHOD(Shader, _SetUniformVector2)
{
- LUAX_STATE(L);
+ LUAX_PREPARE(L, Shader);
}
- int Shader::l_SetUniformVector3(lua_State* L)
+ // shader:SetUniformVector3()
+ LUAX_IMPL_METHOD(Shader, _SetUniformVector3)
{
- LUAX_STATE(L);
+ LUAX_PREPARE(L, Shader);
}
- int Shader::l_SetUniformVector4(lua_State* L)
+ // shader:SetUniformVector4()
+ LUAX_IMPL_METHOD(Shader, _SetUniformVector4)
{
- LUAX_STATE(L);
+ LUAX_PREPARE(L, Shader);
}
- int Shader::l_SetUniformColor(lua_State* L)
+ // shader:SetUniformColor()
+ LUAX_IMPL_METHOD(Shader, _SetUniformColor)
{
- LUAX_STATE(L);
+ LUAX_PREPARE(L, Shader);
}
}
-} \ No newline at end of file
+}
diff --git a/source/libs/asura-lib-core/graphics/binding/_sprite_batch.cpp b/source/libs/asura-lib-core/graphics/binding/_sprite_batch.cpp
index e69de29..8556c02 100644
--- a/source/libs/asura-lib-core/graphics/binding/_sprite_batch.cpp
+++ b/source/libs/asura-lib-core/graphics/binding/_sprite_batch.cpp
@@ -0,0 +1,21 @@
+#include "../sprite_batch.h"
+
+using namespace std;
+
+namespace AsuraEngine
+{
+ namespace Graphics
+ {
+
+ LUAX_REGISTRY(SpriteBatch)
+ {
+
+ }
+
+ LUAX_POSTPROCESS(SpriteBatch)
+ {
+
+ }
+
+ }
+}
diff --git a/source/libs/asura-lib-core/graphics/binding/_window.cpp b/source/libs/asura-lib-core/graphics/binding/_window.cpp
deleted file mode 100644
index 3befc8c..0000000
--- a/source/libs/asura-lib-core/graphics/binding/_window.cpp
+++ /dev/null
@@ -1,11 +0,0 @@
-#include "../Window.h"
-
-namespace AsuraEngine
-{
- namespace Graphics
- {
-
-
-
- }
-}
diff --git a/source/libs/asura-lib-core/graphics/canvas.h b/source/libs/asura-lib-core/graphics/canvas.h
index 6b8b630..5b188ca 100644
--- a/source/libs/asura-lib-core/graphics/canvas.h
+++ b/source/libs/asura-lib-core/graphics/canvas.h
@@ -64,9 +64,9 @@ namespace AsuraEngine
LUAX_DECL_FACTORY(SimCanvas);
- LUAX_DECL_METHOD(l_SetSize);
- LUAX_DECL_METHOD(l_Bind);
- LUAX_DECL_METHOD(l_Unbind);
+ LUAX_DECL_METHOD(_SetSize);
+ LUAX_DECL_METHOD(_Bind);
+ LUAX_DECL_METHOD(_Unbind);
//----------------------------------------------------------------------------------------------------------
diff --git a/source/libs/asura-lib-core/graphics/color.cpp b/source/libs/asura-lib-core/graphics/color.cpp
index 106493d..4d3691e 100644
--- a/source/libs/asura-lib-core/graphics/color.cpp
+++ b/source/libs/asura-lib-core/graphics/color.cpp
@@ -1,61 +1,11 @@
-#include "Color.h"
+#include "color.h"
+#include "color32.h"
namespace AsuraEngine
{
namespace Graphics
{
- Color32::Color32()
- {
- r = g = b = a = 0;
- }
-
- Color32::Color32(const Color32& c)
- {
- r = c.r;
- g = c.g;
- b = c.b;
- a = c.a;
- }
-
- Color32::Color32(const Color& c)
- {
- r = 255.f * c.r;
- g = 255.f * c.g;
- b = 255.f * c.b;
- a = 255.f * c.a;
- }
-
- Color32::Color32(byte r, byte g, byte b, byte a)
- {
- this->r = r;
- this->g = g;
- this->b = b;
- this->a = a;
- }
-
- int Color32::l_GetRed(lua_State* L)
- {
-
- }
-
- int Color32::l_GetGreen(lua_State* L)
- {
-
- }
-
- int Color32::l_GetBlue(lua_State* L)
- {
-
- }
-
- int Color32::l_GetAlpha(lua_State* L)
- {
-
- }
-
- //------------------------------------------------------------------------------------------------------------
-
Color::Color()
{
r = g = b = a = 0;
@@ -93,40 +43,5 @@ namespace AsuraEngine
a *= c.a;
}
- int Color::l_GetRed(lua_State* L)
- {
-
- }
-
- int Color::l_GetGreen(lua_State* L)
- {
-
- }
-
- int Color::l_GetBlue(lua_State* L)
- {
-
- }
-
- int Color::l_GetAlpha(lua_State* L)
- {
-
- }
-
- int Color::l_Add(lua_State* L)
- {
-
- }
-
- int Color::l_Minus(lua_State* L)
- {
-
- }
-
- int Color::l_Multiply(lua_State* L)
- {
-
- }
-
}
} \ No newline at end of file
diff --git a/source/libs/asura-lib-core/graphics/color.h b/source/libs/asura-lib-core/graphics/color.h
index 74cf8f3..607314b 100644
--- a/source/libs/asura-lib-core/graphics/color.h
+++ b/source/libs/asura-lib-core/graphics/color.h
@@ -10,44 +10,7 @@ namespace AsuraEngine
namespace Graphics
{
- class Color;
-
- ///
- /// 32bitsɫ
- ///
- class Color32 ASURA_FINAL
- : public Scripting::Portable<Color32>
- {
- public:
-
- Color32();
-
- ~Color32();
-
- Color32(const Color32& c);
-
- Color32(const Color& c);
-
- Color32(byte r, byte g, byte b, byte a);
-
- byte r, g, b, a;
-
- //----------------------------------------------------------------------------------------------------------
-
- LUAX_DECL_FACTORY(Color32);
-
- LUAX_DECL_METHOD(l_ToColor);
- LUAX_DECL_METHOD(l_GetRed);
- LUAX_DECL_METHOD(l_GetGreen);
- LUAX_DECL_METHOD(l_GetBlue);
- LUAX_DECL_METHOD(l_GetAlpha);
- LUAX_DECL_METHOD(l_Multiply);
- LUAX_DECL_METHOD(l_Index); //r,g,b,a
- LUAX_DECL_METHOD(l_NewIndex); //޸r,g,b,a
-
- //----------------------------------------------------------------------------------------------------------
-
- };
+ class Color32;
///
/// 淶ɫ
@@ -77,16 +40,12 @@ namespace AsuraEngine
float r, g, b, a;
- //----------------------------------------------------------------------------------------------------------
-
LUAX_DECL_FACTORY(Color);
- LUAX_DECL_METHOD(l_ToColor32);
- LUAX_DECL_METHOD(l_SetColor);
- LUAX_DECL_METHOD(l_GetColor);
- LUAX_DECL_METHOD(l_Multiply); // ɫ˷
-
- //----------------------------------------------------------------------------------------------------------
+ LUAX_DECL_METHOD(_ToColor32);
+ LUAX_DECL_METHOD(_SetColor);
+ LUAX_DECL_METHOD(_GetColor);
+ LUAX_DECL_METHOD(_Multiply); // ɫ˷
};
diff --git a/source/libs/asura-lib-core/graphics/color32.cpp b/source/libs/asura-lib-core/graphics/color32.cpp
new file mode 100644
index 0000000..0ebc77c
--- /dev/null
+++ b/source/libs/asura-lib-core/graphics/color32.cpp
@@ -0,0 +1,39 @@
+#include "color.h"
+#include "color32.h"
+
+namespace AsuraEngine
+{
+ namespace Graphics
+ {
+
+ Color32::Color32()
+ {
+ r = g = b = a = 0;
+ }
+
+ Color32::Color32(const Color32& c)
+ {
+ r = c.r;
+ g = c.g;
+ b = c.b;
+ a = c.a;
+ }
+
+ Color32::Color32(const Color& c)
+ {
+ r = 255.f * c.r;
+ g = 255.f * c.g;
+ b = 255.f * c.b;
+ a = 255.f * c.a;
+ }
+
+ Color32::Color32(byte r, byte g, byte b, byte a)
+ {
+ this->r = r;
+ this->g = g;
+ this->b = b;
+ this->a = a;
+ }
+
+ }
+} \ No newline at end of file
diff --git a/source/libs/asura-lib-core/graphics/color32.h b/source/libs/asura-lib-core/graphics/color32.h
new file mode 100644
index 0000000..c64a9b9
--- /dev/null
+++ b/source/libs/asura-lib-core/graphics/color32.h
@@ -0,0 +1,51 @@
+#ifndef __ASURA_ENGINE_COLOR32_H__
+#define __ASURA_ENGINE_COLOR32_H__
+
+#include <asura-lib-utils/scripting/portable.hpp>
+
+#include "../core_config.h"
+
+namespace AsuraEngine
+{
+ namespace Graphics
+ {
+
+ class Color;
+
+ ///
+ /// 32bitsɫ
+ ///
+ class Color32 ASURA_FINAL
+ : public Scripting::Portable<Color32>
+ {
+ public:
+
+ LUAX_DECL_FACTORY(Color32);
+
+ Color32();
+
+ ~Color32();
+
+ Color32(const Color32& c);
+
+ Color32(const Color& c);
+
+ Color32(byte r, byte g, byte b, byte a);
+
+ byte r, g, b, a;
+
+ LUAX_DECL_METHOD(_ToColor);
+ LUAX_DECL_METHOD(_GetRed);
+ LUAX_DECL_METHOD(_GetGreen);
+ LUAX_DECL_METHOD(_GetBlue);
+ LUAX_DECL_METHOD(_GetAlpha);
+ LUAX_DECL_METHOD(_Multiply);
+ LUAX_DECL_METHOD(_Index); //r,g,b,a
+ LUAX_DECL_METHOD(_NewIndex); //޸r,g,b,a
+
+ };
+
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-core/graphics/image.h b/source/libs/asura-lib-core/graphics/image.h
index d8577ad..0e4ea0a 100644
--- a/source/libs/asura-lib-core/graphics/image.h
+++ b/source/libs/asura-lib-core/graphics/image.h
@@ -1,11 +1,12 @@
#ifndef __ASURA_ENGINE_IMAGE_H__
#define __ASURA_ENGINE_IMAGE_H__
-#include "../math/vector2.hpp"
-#include "../scripting/portable.hpp"
-#include "../fileSystem/reloadable.h"
-#include "../stringmap.hpp"
-#include "../manager.hpp"
+#include <asura-lib-utils/math/rect.hpp>
+#include <asura-lib-utils/math/vector2.hpp>
+#include <asura-lib-utils/scripting/portable.hpp>
+#include <asura-lib-utils/io/reloadable.h>
+#include <asura-lib-utils/stringmap.hpp>
+#include <asura-lib-utils/manager.hpp>
#include "texture.h"
#include "color.h"
@@ -26,7 +27,7 @@ namespace AsuraEngine
class Image ASURA_FINAL
: public Drawable
, public Scripting::Portable<Image>
- , public Filesystem::Reloadable
+ , public AEIO::Reloadable
{
public:
@@ -63,10 +64,10 @@ namespace AsuraEngine
LUAX_DECL_FACTORY(SimImage);
- LUAX_DECL_METHOD(l_Load);
- LUAX_DECL_METHOD(l_GetWidth);
- LUAX_DECL_METHOD(l_GetHeight);
- LUAX_DECL_METHOD(l_GetSize);
+ LUAX_DECL_METHOD(_Load);
+ LUAX_DECL_METHOD(_GetWidth);
+ LUAX_DECL_METHOD(_GetHeight);
+ LUAX_DECL_METHOD(_GetSize);
};
diff --git a/source/libs/asura-lib-core/graphics/binding/_gif.cpp b/source/libs/asura-lib-core/graphics/image_decode_task.cpp
index e69de29..e69de29 100644
--- a/source/libs/asura-lib-core/graphics/binding/_gif.cpp
+++ b/source/libs/asura-lib-core/graphics/image_decode_task.cpp
diff --git a/source/libs/asura-lib-core/graphics/image_decode_task.h b/source/libs/asura-lib-core/graphics/image_decode_task.h
new file mode 100644
index 0000000..a721b3e
--- /dev/null
+++ b/source/libs/asura-lib-core/graphics/image_decode_task.h
@@ -0,0 +1,25 @@
+#ifndef __ASURA_IMAGE_DECODE_TASK_H__
+#define __ASURA_IMAGE_DECODE_TASK_H__
+
+#include <asura-lib-utils/threading/thread_task.h>
+#include <asura-lib-utils/scripting/portable.hpp>
+
+namespace AsuraEngine
+{
+ namespace Graphics
+ {
+
+ class ImageDecodeTask
+ : public AEScripting::Portable<ImageDecodeTask>
+ , public AEThreading::ThreadTask
+ {
+ public:
+
+ LUAX_DECL_FACTORY(ImageDecodeTask);
+
+ };
+
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-core/graphics/image_decoder.h b/source/libs/asura-lib-core/graphics/image_decoder.h
index 921d129..6f2049a 100644
--- a/source/libs/asura-lib-core/graphics/image_decoder.h
+++ b/source/libs/asura-lib-core/graphics/image_decoder.h
@@ -1,7 +1,7 @@
#ifndef __ASURA_ENGINE_IMAGE_DECODER_H__
#define __ASURA_ENGINE_IMAGE_DECODER_H__
-#include <asura-lib-utils/filesystem/data_buffer.h>
+#include <asura-lib-utils/io/data_buffer.h>
#include "image_data.h"
@@ -20,12 +20,12 @@ namespace AsuraEngine
///
/// жڴǷñdecoderѹ
///
- virtual bool CanDecode(const Filesystem::DataBuffer& buffer) = 0;
+ virtual bool CanDecode(const AEIO::DataBuffer& buffer) = 0;
///
/// һڴ棬һѹImage dataѹʧܷnullptr
///
- virtual void Decode(const Filesystem::DataBuffer& buffer, ImageData& data) = 0;
+ virtual void Decode(const AEIO::DataBuffer& buffer, ImageData& data) = 0;
};
diff --git a/source/libs/asura-lib-core/graphics/mesh2d.h b/source/libs/asura-lib-core/graphics/mesh2d.h
index 2c58f00..48b461d 100644
--- a/source/libs/asura-lib-core/graphics/mesh2d.h
+++ b/source/libs/asura-lib-core/graphics/mesh2d.h
@@ -1,9 +1,7 @@
#ifndef __ASURA_ENGINE_MESH2D_H__
#define __ASURA_ENGINE_MESH2D_H__
-#include "Scripting/Luax.hpp"
-
-#include "scripting/portable.hpp"
+#include <asura-lib-utils/scripting/portable.hpp>
namespace AsuraEngine
{
diff --git a/source/libs/asura-lib-core/graphics/png_decoder.h b/source/libs/asura-lib-core/graphics/png_decoder.h
index bb82032..bc871fa 100644
--- a/source/libs/asura-lib-core/graphics/png_decoder.h
+++ b/source/libs/asura-lib-core/graphics/png_decoder.h
@@ -15,9 +15,9 @@ namespace AsuraEngine
{
public:
- bool CanDecode(const Filesystem::DataBuffer& buffer) override;
+ bool CanDecode(const AEIO::DataBuffer& buffer) override;
- void Decode(const Filesystem::DataBuffer& buffer, ImageData& data) override;
+ void Decode(const AEIO::DataBuffer& buffer, ImageData& data) override;
};
diff --git a/source/libs/asura-lib-core/graphics/render_state.h b/source/libs/asura-lib-core/graphics/render_state.h
index a80efd3..4d1831c 100644
--- a/source/libs/asura-lib-core/graphics/render_state.h
+++ b/source/libs/asura-lib-core/graphics/render_state.h
@@ -1,9 +1,8 @@
#ifndef __ASURA_ENGINE_RENDER_STATE_H__
#define __ASURA_ENGINE_RENDER_STATE_H__
-#include "Math/Vector2.hpp"
-#include "Math/Rect.hpp"
-#include "Math/Transform.h"
+#include <asura-lib-utils/math/vector2.hpp>
+#include <asura-lib-utils/math/transform.h>
#include "Shader.h"
#include "blend_mode.h"
diff --git a/source/libs/asura-lib-core/graphics/render_target.h b/source/libs/asura-lib-core/graphics/render_target.h
index d6de164..afa5c6a 100644
--- a/source/libs/asura-lib-core/graphics/render_target.h
+++ b/source/libs/asura-lib-core/graphics/render_target.h
@@ -1,10 +1,12 @@
#ifndef __ASURA_ENGINE_RENDERTARGET_H__
#define __ASURA_ENGINE_RENDERTARGET_H__
-#include "Math/Rect.hpp"
-#include "Texture.h"
-#include "Scripting/Portable.h"
-#include "Color.h"
+#include <asura-lib-utils/math/vector2.hpp>
+#include <asura-lib-utils/math/rect.hpp>
+#include <asura-lib-utils/scripting/portable.hpp>
+
+#include "texture.h"
+#include "color.h"
namespace AsuraEngine
{
diff --git a/source/libs/asura-lib-core/graphics/shader.h b/source/libs/asura-lib-core/graphics/shader.h
index 65f214e..575a37e 100644
--- a/source/libs/asura-lib-core/graphics/shader.h
+++ b/source/libs/asura-lib-core/graphics/shader.h
@@ -4,18 +4,18 @@
#include <map>
#include <string>
-#include "FileSystem/Reloadable.h"
-#include "Scripting/Luax.hpp"
-#include "Math/Vector2.hpp"
-#include "Math/Vector3.hpp"
-#include "Math/Vector4.h"
-#include "Math/Matrix44.h"
-#include "StringMap.hpp"
-#include "scripting/portable.hpp"
-#include "Color.h"
-#include "Manager.hpp"
-#include "Texture.h"
-#include "GL.h"
+#include <asura-lib-utils/scripting/portable.hpp>
+#include <asura-lib-utils/io/reloadable.h>
+#include <asura-lib-utils/math/vector2.hpp>
+#include <asura-lib-utils/math/vector3.hpp>
+#include <asura-lib-utils/math/vector4.h>
+#include <asura-lib-utils/math/matrix44.h>
+#include <asura-lib-utils/stringmap.hpp>
+#include <asura-lib-utils/manager.hpp>
+
+#include "color.h"
+#include "texture.h"
+#include "gl.h"
namespace AsuraEngine
{
@@ -28,7 +28,7 @@ namespace AsuraEngine
///
class Shader ASURA_FINAL
: public Scripting::Portable<Shader>
- , public Filesystem::Reloadable
+ , public AEIO::Reloadable
{
public:
@@ -100,18 +100,19 @@ namespace AsuraEngine
LUAX_DECL_FACTORY(SimShader);
- LUAX_DECL_METHOD(l_Use);
- LUAX_DECL_METHOD(l_Unuse);
- LUAX_DECL_METHOD(l_Load);
- LUAX_DECL_METHOD(l_HasUniform);
- LUAX_DECL_METHOD(l_GetUniformLocation);
- LUAX_DECL_METHOD(l_SetBuiltInUniforms);
- LUAX_DECL_METHOD(l_SetUniformFloat);
- LUAX_DECL_METHOD(l_SetUniformTexture);
- LUAX_DECL_METHOD(l_SetUniformVector2);
- LUAX_DECL_METHOD(l_SetUniformVector3);
- LUAX_DECL_METHOD(l_SetUniformVector4);
- LUAX_DECL_METHOD(l_SetUniformColor);
+ LUAX_DECL_METHOD(_New);
+ LUAX_DECL_METHOD(_Use);
+ LUAX_DECL_METHOD(_Unuse);
+ LUAX_DECL_METHOD(_Load);
+ LUAX_DECL_METHOD(_HasUniform);
+ LUAX_DECL_METHOD(_GetUniformLocation);
+ LUAX_DECL_METHOD(_SetBuiltInUniforms);
+ LUAX_DECL_METHOD(_SetUniformFloat);
+ LUAX_DECL_METHOD(_SetUniformTexture);
+ LUAX_DECL_METHOD(_SetUniformVector2);
+ LUAX_DECL_METHOD(_SetUniformVector3);
+ LUAX_DECL_METHOD(_SetUniformVector4);
+ LUAX_DECL_METHOD(_SetUniformColor);
private:
diff --git a/source/libs/asura-lib-core/graphics/sprite_batch.h b/source/libs/asura-lib-core/graphics/sprite_batch.h
index 7909519..d8d9ca6 100644
--- a/source/libs/asura-lib-core/graphics/sprite_batch.h
+++ b/source/libs/asura-lib-core/graphics/sprite_batch.h
@@ -1,7 +1,7 @@
#ifndef __ASURA_ENGINE_SPRITE_BATCH_H__
#define __ASURA_ENGINE_SPRITE_BATCH_H__
-#include "Scripting/Portable.h"
+#include <asura-lib-utils/scripting/portable.hpp>
namespace AsuraEngine
{
diff --git a/source/libs/asura-lib-core/graphics/stb_decoder.h b/source/libs/asura-lib-core/graphics/stb_decoder.h
index 57b247c..85bad21 100644
--- a/source/libs/asura-lib-core/graphics/stb_decoder.h
+++ b/source/libs/asura-lib-core/graphics/stb_decoder.h
@@ -16,9 +16,9 @@ namespace AsuraEngine
{
public:
- bool CanDecode(const Filesystem::DataBuffer& buffer) override;
+ bool CanDecode(const AEIO::DataBuffer& buffer) override;
- void Decode(const Filesystem::DataBuffer& buffer, ImageData& data) override;
+ void Decode(const AEIO::DataBuffer& buffer, ImageData& data) override;
};
diff --git a/source/libs/asura-lib-core/graphics/texture.h b/source/libs/asura-lib-core/graphics/texture.h
index 81aa469..c412b2e 100644
--- a/source/libs/asura-lib-core/graphics/texture.h
+++ b/source/libs/asura-lib-core/graphics/texture.h
@@ -1,12 +1,14 @@
#ifndef __ASURA_ENGINE_TEXTURE_H__
#define __ASURA_ENGINE_TEXTURE_H__
-#include "Config.h"
-#include "Math/Rect.hpp"
-#include "Math/Vector2.hpp"
-#include "Scripting/Luax.hpp"
-#include "RenderState.h"
-#include "GL.h"
+#include <asura-lib-utils/math/rect.hpp>
+#include <asura-lib-utils/math/vector2.hpp>
+#include <asura-lib-utils/scripting/portable.hpp>
+
+#include "../core_config.h"
+
+#include "render_state.h"
+#include "gl.h"
namespace AsuraEngine
{
diff --git a/source/libs/asura-lib-core/graphics/window.h b/source/libs/asura-lib-core/graphics/window.h
index cb036f1..0bfd6a1 100644
--- a/source/libs/asura-lib-core/graphics/window.h
+++ b/source/libs/asura-lib-core/graphics/window.h
@@ -1,8 +1,9 @@
#ifndef __ASURA_ENGINE_WINDOW_H__
#define __ASURA_ENGINE_WINDOW_H__
-#include "../scripting/portable.hpp"
-#include "../math/vector2.hpp"
+#include <asura-lib-utils/scripting/portable.hpp>
+#include <asura-lib-utils/math/vector2.hpp>
+
#include "render_state.h"
#include "render_target.h"
@@ -16,52 +17,64 @@ namespace AsuraEngine
WINDOW_STYLE_FULLSCREEN = 1 << 1,
};
+ class WindowImpl;
+
///
/// ڣֶ֧രڡڱ༭Ҫ֧֣runnerֻҪһڡͬĿͻʵִ˽ӿڲֶעᵽlua
///
- ASURA_ABSTRACT class Window
+ class Window
: public RenderTarget
+ , public AEScripting::Portable<Window>
{
public:
+ LUAX_DECL_SINGLETON(Window);
+
Window(WindowStyle style);
~Window();
- virtual void SetSize(uint width, uint height) = 0;
+ void SetSize(uint width, uint height);
- virtual void SetPosition(int x, int y) = 0;
+ void SetPosition(int x, int y);
- virtual void SetTitle(const std::string& title) = 0;
+ void SetTitle(const std::string& title);
- virtual void SetWindowStyle(WindowStyle style) = 0;
+ void SetWindowStyle(WindowStyle style);
- virtual void Show() = 0;
+ void Show();
- virtual void Hide() = 0;
+ void Hide();
///
/// ǿ˫ĴڣҪչʾǰ̨
///
- virtual void SwapRenderBuffer() = 0;
+ void SwapRenderBuffer();
- virtual void Clear(const Color& col = Color::Black) = 0;
+ void Clear(const Color& col = Color::Black);
- virtual void Clear(const Math::Recti& quad, const Color& col = Color::Black) = 0;
+ void Clear(const Math::Recti& quad, const Color& col = Color::Black);
- virtual void Draw(const Drawable* texture, const RenderState& state) = 0;
+ void Draw(const Drawable* texture, const RenderState& state);
- virtual void Draw(const Drawable* texture, const Math::Recti& quad, const RenderState& state) = 0;
+ void Draw(const Drawable* texture, const Math::Recti& quad, const RenderState& state);
protected:
- Math::Vector2i mPosition;
- Math::Vector2i mSize;
+ WindowImpl* mImpl;
};
using RenderWindow = Window;
+ ASURA_ABSTRACT class WindowImpl
+ {
+ public:
+
+
+
+ };
+
}
}
diff --git a/source/libs/asura-lib-core/graphics/window_impl_sdl.cpp b/source/libs/asura-lib-core/graphics/window_impl_sdl.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/source/libs/asura-lib-core/graphics/window_impl_sdl.cpp
diff --git a/source/libs/asura-lib-core/graphics/window_impl_sdl.h b/source/libs/asura-lib-core/graphics/window_impl_sdl.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/source/libs/asura-lib-core/graphics/window_impl_sdl.h