diff options
author | chai <chaifix@163.com> | 2019-03-27 09:07:54 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-03-27 09:07:54 +0800 |
commit | 66c5fdc564dd892ed265132d6c1378dbe3cebcee (patch) | |
tree | 909848ed622b35c8653c961c9ebed8c574bb150e /source/libs | |
parent | d9041d6e12ded456c17622f7f2e7bbacb9e99b1a (diff) |
*misc
Diffstat (limited to 'source/libs')
62 files changed, 827 insertions, 398 deletions
diff --git a/source/libs/asura-lib-core/application.h b/source/libs/asura-lib-core/application.h index b61154d..9606819 100644 --- a/source/libs/asura-lib-core/application.h +++ b/source/libs/asura-lib-core/application.h @@ -65,7 +65,9 @@ namespace AsuraEngine private: /// - /// ̵߳lua stateӦѭС + /// ̵߳lua state handleӦѭСһ˵ֻҪ߳һlua_State̲߳Ҫ̼߳ + /// lua̫ʹˡC++дȻעһصһ̴߳lua_Stateעắִк + /// ̵߳lua_Stateֻ֤һnativeʵ֮һlua_State /// lua_State* mMainLuaState; diff --git a/source/libs/asura-lib-core/client/client.h b/source/libs/asura-lib-core/client/client.h deleted file mode 100644 index 8df30fe..0000000 --- a/source/libs/asura-lib-core/client/client.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __ASURA_ENGINE_HOST_H__ -#define __ASURA_ENGINE_HOST_H__ - -#include <asura-lib-utils/type.h> - -/// -/// ʹйصʵ֣ǵϷĿƽ̨ʹüֱʵ֡༭벻ڿƽ̨ڿ⣬Ŀǰʹwin32APIʵϢѭ -/// -namespace AsuraEngine -{ - namespace Client - { - - /// - /// ࡣ - /// - ASURA_ABSTRACT class Client - { - - }; - - } -} - -#endif
\ No newline at end of file diff --git a/source/libs/asura-lib-core/client/sdl/sdl_application.h b/source/libs/asura-lib-core/client/sdl/sdl_application.h deleted file mode 100644 index f6f23a8..0000000 --- a/source/libs/asura-lib-core/client/sdl/sdl_application.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef __ASURA_SDL_APPLICATION_H__ -#define __ASURA_SDL_APPLICATION_H__ - -#include "sdl_config.h" - -namespace AsuraEngine -{ - namespace SDL - { - - class SDLApplication : public Application - { - - }; - -/* - -Application* editor = nullpt; -#ifdef ASURA_SDL - editor = SDLApplication(); -#endif - -*/ - - } -} - -#endif
\ No newline at end of file diff --git a/source/libs/asura-lib-core/client/sdl/sdl_window.h b/source/libs/asura-lib-core/client/sdl/sdl_window.h deleted file mode 100644 index 040c23e..0000000 --- a/source/libs/asura-lib-core/client/sdl/sdl_window.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef __ASURA_SDL_WINDOW_H__ -#define __ASURA_SDL_WINDOW_H__ - -#include "../../core_config.h" -#if ASURA_CORE_SDL - -#include <asura-lib-utils/scripting/portable.hpp> -#include "../../graphics/window.h" - -namespace AsuraEngine -{ - namespace SDL - { - - class SDLWindow ASURA_FINAL - : public Graphics::Window - , public Scripting::Portable<SDLWindow> - { - public: - - - }; - - } -} - -#endif // ASURA_CORE_SDL - -#endif // __ASURA_SDL_WINDOW_H__
\ No newline at end of file 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/client/sdl/sdl_application.cpp b/source/libs/asura-lib-core/graphics/image_decode_task.cpp index e69de29..e69de29 100644 --- a/source/libs/asura-lib-core/client/sdl/sdl_application.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/client/sdl/sdl_cursor.cpp b/source/libs/asura-lib-core/graphics/window_impl_sdl.cpp index e69de29..e69de29 100644 --- a/source/libs/asura-lib-core/client/sdl/sdl_cursor.cpp +++ b/source/libs/asura-lib-core/graphics/window_impl_sdl.cpp diff --git a/source/libs/asura-lib-core/client/sdl/sdl_cursor.h b/source/libs/asura-lib-core/graphics/window_impl_sdl.h index e69de29..e69de29 100644 --- a/source/libs/asura-lib-core/client/sdl/sdl_cursor.h +++ b/source/libs/asura-lib-core/graphics/window_impl_sdl.h diff --git a/source/libs/asura-lib-core/input/cursor.h b/source/libs/asura-lib-core/input/cursor.h index a8e53a6..553fda4 100644 --- a/source/libs/asura-lib-core/input/cursor.h +++ b/source/libs/asura-lib-core/input/cursor.h @@ -1,4 +1,3 @@ - #ifndef __ASURA_ENGINE_CURSOR_H__ #define __ASURA_ENGINE_CURSOR_H__ @@ -15,12 +14,17 @@ namespace AsuraEngine namespace Input { - class Cursor ASURA_FINAL : public AEScripting::Portable<Cursor> + class CursorImpl; + + // ָö +#include "Cursor.defs" + + class Cursor + : public AEScripting::Portable<Cursor> { public: - // ָö - #include "Cursor.defs" + LUAX_DECL_FACTORY(Cursor); Cursor(Graphics::ImageData& imageData, int hotx, int hoty); Cursor(SystemCursor cursortype); @@ -31,18 +35,20 @@ namespace AsuraEngine CursorType GetType() const; SystemCursor GetSystemType() const; - LUAX_DECL_FACTORY(Cursor); - private: - SDL_Cursor* mCursorHandle; - - CursorType mType; + CursorType mType; SystemCursor mSystemType; + CursorImpl* mImpl; + + }; + + ASURA_ABSTRACT class CursorImpl + { }; } } -#endif +#endif
\ No newline at end of file diff --git a/source/libs/asura-lib-core/client/sdl/sdl_thread.cpp b/source/libs/asura-lib-core/input/cursor_impl_sdl.cpp index e69de29..e69de29 100644 --- a/source/libs/asura-lib-core/client/sdl/sdl_thread.cpp +++ b/source/libs/asura-lib-core/input/cursor_impl_sdl.cpp diff --git a/source/libs/asura-lib-core/client/sdl/sdl_thread.h b/source/libs/asura-lib-core/input/cursor_impl_sdl.h index e69de29..e69de29 100644 --- a/source/libs/asura-lib-core/client/sdl/sdl_thread.h +++ b/source/libs/asura-lib-core/input/cursor_impl_sdl.h diff --git a/source/libs/asura-lib-utils/io/binding/_file.cpp b/source/libs/asura-lib-utils/io/binding/_file.cpp index 0baffd5..0670379 100644 --- a/source/libs/asura-lib-utils/io/binding/_file.cpp +++ b/source/libs/asura-lib-utils/io/binding/_file.cpp @@ -32,8 +32,8 @@ namespace AsuraEngine { LUAX_REGISTER_ENUM(state, "EFileMode", { "CLOSED", FILE_MODE_CLOSED }, - { "READ", FILE_MODE_READ }, - { "WRITE", FILE_MODE_WRITE }, + { "READ", FILE_MODE_READ }, + { "WRITE", FILE_MODE_WRITE }, { "APPEND", FILE_MODE_APPEND } ); @@ -130,7 +130,7 @@ namespace AsuraEngine return 1; } - // isWrite = file:Write(data buffer) + // isWrite = file:Write(data buffer[, size]) LUAX_IMPL_METHOD(File, _Write) { LUAX_PREPARE(L, File); diff --git a/source/libs/asura-lib-utils/io/file.h b/source/libs/asura-lib-utils/io/file.h index b09eaaa..4a6d38b 100644 --- a/source/libs/asura-lib-utils/io/file.h +++ b/source/libs/asura-lib-utils/io/file.h @@ -108,6 +108,9 @@ namespace AsuraEngine BufferMode mBufferMode; ///< д뻺ģʽ size_t mBufferSize; ///< д뻺С + LUAX_DECL_ENUM(FileMode); + LUAX_DECL_ENUM(BufferMode); + LUAX_DECL_METHOD(_New); LUAX_DECL_METHOD(_Open); LUAX_DECL_METHOD(_Close); diff --git a/source/libs/asura-lib-utils/io/file_data.h b/source/libs/asura-lib-utils/io/file_data.h index 106e068..9aa0e3b 100644 --- a/source/libs/asura-lib-utils/io/file_data.h +++ b/source/libs/asura-lib-utils/io/file_data.h @@ -56,10 +56,10 @@ namespace AsuraEngine std::string mExtension; ///< չ std::string mName; ///< ͺļ + LUAX_DECL_METHOD(_GetDataBuffer); LUAX_DECL_METHOD(_GetFileName); LUAX_DECL_METHOD(_GetExtension); LUAX_DECL_METHOD(_GetName); - LUAX_DECL_METHOD(_GetDataBuffer); }; diff --git a/source/libs/asura-lib-core/client/sdl/sdl_window.cpp b/source/libs/asura-lib-utils/io/io_task.cpp index e69de29..e69de29 100644 --- a/source/libs/asura-lib-core/client/sdl/sdl_window.cpp +++ b/source/libs/asura-lib-utils/io/io_task.cpp diff --git a/source/libs/asura-lib-utils/io/io_task.h b/source/libs/asura-lib-utils/io/io_task.h new file mode 100644 index 0000000..b91a88c --- /dev/null +++ b/source/libs/asura-lib-utils/io/io_task.h @@ -0,0 +1,39 @@ +#ifndef __ASURA_IO_TASK_H__ +#define __ASURA_IO_TASK_H__ + +#include <string> + +#include "../scripting/portable.hpp" +#include "../threading/thread_task.h" + +#include "data_buffer.h" + +namespace AsuraEngine +{ + namespace IO + { + + /// + /// ȡļ + /// + class IOTask + : public AEScripting::Portable<IOTask> + , public AEThreading::ThreadTask + { + public: + + LUAX_DECL_FACTORY(IOTask); + + bool Execute() override ; + + private: + + std::string mPath; + DataBuffer* mDst; + + }; + + } +} + +#endif
\ No newline at end of file diff --git a/source/libs/asura-lib-utils/io/reloadable.h b/source/libs/asura-lib-utils/io/reloadable.h index cf30296..22a721c 100644 --- a/source/libs/asura-lib-utils/io/reloadable.h +++ b/source/libs/asura-lib-utils/io/reloadable.h @@ -24,4 +24,6 @@ namespace AsuraEngine } } +namespace AEIO = AsuraEngine::IO; + #endif
\ No newline at end of file diff --git a/source/libs/asura-lib-core/threading/coroutine.cpp b/source/libs/asura-lib-utils/threading/coroutine.cpp index e69de29..e69de29 100644 --- a/source/libs/asura-lib-core/threading/coroutine.cpp +++ b/source/libs/asura-lib-utils/threading/coroutine.cpp diff --git a/source/libs/asura-lib-core/threading/coroutine.h b/source/libs/asura-lib-utils/threading/coroutine.h index f511e48..1ac6b21 100644 --- a/source/libs/asura-lib-core/threading/coroutine.h +++ b/source/libs/asura-lib-utils/threading/coroutine.h @@ -8,6 +8,9 @@ namespace AsuraEngine namespace Threading { + /// + /// luaЭ̣һЩ + /// class Coroutine ASURA_FINAL : public AEScripting::Portable<Coroutine> { @@ -17,7 +20,8 @@ namespace AsuraEngine private: - + LUAX_DECL_METHOD(_New); + LUAX_DECL_METHOD(_Run); }; diff --git a/source/libs/asura-lib-core/graphics/binding/_gif.cpp b/source/libs/asura-lib-utils/threading/mutex.cpp index e69de29..e69de29 100644 --- a/source/libs/asura-lib-core/graphics/binding/_gif.cpp +++ b/source/libs/asura-lib-utils/threading/mutex.cpp diff --git a/source/libs/asura-lib-utils/threading/mutex.h b/source/libs/asura-lib-utils/threading/mutex.h new file mode 100644 index 0000000..893c6e5 --- /dev/null +++ b/source/libs/asura-lib-utils/threading/mutex.h @@ -0,0 +1,21 @@ +#ifndef __ASURA_MUTEX_H__ +#define __ASURA_MUTEX_H__ + +namespace AsuraEngine +{ + namespace Threading + { + + class Mutex + { + public: + + void Lock(); + void Unlock(); + + }; + + } +} + +#endif
\ No newline at end of file diff --git a/source/libs/asura-lib-utils/threading/thread.cpp b/source/libs/asura-lib-utils/threading/thread.cpp new file mode 100644 index 0000000..c77f3ab --- /dev/null +++ b/source/libs/asura-lib-utils/threading/thread.cpp @@ -0,0 +1,14 @@ +#include "thread.h" + +namespace AsuraEngine +{ + namespace Threading + { + + bool Thread::Enqueue(ThreadTask* task) + { + + } + + } +}
\ No newline at end of file diff --git a/source/libs/asura-lib-utils/threading/thread.h b/source/libs/asura-lib-utils/threading/thread.h new file mode 100644 index 0000000..0058144 --- /dev/null +++ b/source/libs/asura-lib-utils/threading/thread.h @@ -0,0 +1,60 @@ +#ifndef __ASURA_THREAD_H__ +#define __ASURA_THREAD_H__ + +#include <queue> +#include <asura-lib-utils/scripting/portable.hpp> + +#include "thread_task.h" + +namespace AsuraEngine +{ + namespace Threading + { + + class ThreadImpl; + + /// + /// ߳壬ÿ߳άһtask queue + /// + class Thread ASURA_FINAL + : public AEScripting::Portable<Thread> + { + public: + + LUAX_DECL_FACTORY(Thread); + + bool Enqueue(ThreadTask* task); + + void Run(); + + private: + + /// + /// С + /// + std::queue<ThreadTask*> mTaskQueue; + + ThreadImpl* mImpl; + + LUAX_DECL_METHOD(_Enqueue); + LUAX_DECL_METHOD(_Run); + + }; + + /// + /// ̵߳ľʵ֣ûģһֲԣ + /// 1: win32 + /// 2: posix + /// 3: SDL + /// 4: std::thread + /// + ASURA_ABSTRACT class ThreadImpl + { + public: + + }; + + } +} + +#endif
\ No newline at end of file diff --git a/source/libs/asura-lib-core/threading/binding/_coroutine.cpp b/source/libs/asura-lib-utils/threading/thread_impl_posix.cpp index e69de29..e69de29 100644 --- a/source/libs/asura-lib-core/threading/binding/_coroutine.cpp +++ b/source/libs/asura-lib-utils/threading/thread_impl_posix.cpp diff --git a/source/libs/asura-lib-core/threading/binding/_thread.cpp b/source/libs/asura-lib-utils/threading/thread_impl_posix.h index e69de29..e69de29 100644 --- a/source/libs/asura-lib-core/threading/binding/_thread.cpp +++ b/source/libs/asura-lib-utils/threading/thread_impl_posix.h diff --git a/source/libs/asura-lib-core/threading/thread.cpp b/source/libs/asura-lib-utils/threading/thread_impl_sdl.cpp index e69de29..e69de29 100644 --- a/source/libs/asura-lib-core/threading/thread.cpp +++ b/source/libs/asura-lib-utils/threading/thread_impl_sdl.cpp diff --git a/source/libs/asura-lib-core/threading/thread.h b/source/libs/asura-lib-utils/threading/thread_impl_sdl.h index e69de29..e69de29 100644 --- a/source/libs/asura-lib-core/threading/thread.h +++ b/source/libs/asura-lib-utils/threading/thread_impl_sdl.h diff --git a/source/libs/asura-lib-utils/threading/thread_impl_std.cpp b/source/libs/asura-lib-utils/threading/thread_impl_std.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/libs/asura-lib-utils/threading/thread_impl_std.cpp diff --git a/source/libs/asura-lib-utils/threading/thread_impl_std.h b/source/libs/asura-lib-utils/threading/thread_impl_std.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/libs/asura-lib-utils/threading/thread_impl_std.h diff --git a/source/libs/asura-lib-utils/threading/thread_impl_win32.cpp b/source/libs/asura-lib-utils/threading/thread_impl_win32.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/libs/asura-lib-utils/threading/thread_impl_win32.cpp diff --git a/source/libs/asura-lib-utils/threading/thread_impl_win32.h b/source/libs/asura-lib-utils/threading/thread_impl_win32.h new file mode 100644 index 0000000..3dd2a8e --- /dev/null +++ b/source/libs/asura-lib-utils/threading/thread_impl_win32.h @@ -0,0 +1,35 @@ +#ifndef __ASURA_THREAD_WIN32_H__ +#define __ASURA_THREAD_WIN32_H__ + +#include "../utils_config.h" + +#if ASURA_THREAD_WIN32 + +#include <windows.h> +#include "thread.h" + +namespace AsuraEngine +{ + namespace Threading + { + + /// + /// Threadwin32ʵ֡ + /// + class ThreadImplWin32 : public ThreadImpl + { + public: + + + private: + + HANDLE mHandle; + + }; + + } +} + +#endif // #if ASURA_THREAD_WIN32 + +#endif
\ No newline at end of file diff --git a/source/libs/asura-lib-utils/threading/thread_task.cpp b/source/libs/asura-lib-utils/threading/thread_task.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/libs/asura-lib-utils/threading/thread_task.cpp diff --git a/source/libs/asura-lib-utils/threading/thread_task.h b/source/libs/asura-lib-utils/threading/thread_task.h new file mode 100644 index 0000000..35e159c --- /dev/null +++ b/source/libs/asura-lib-utils/threading/thread_task.h @@ -0,0 +1,27 @@ +#ifndef __ASURA_THRAD_TASK_H__ +#define __ASURA_THRAD_TASK_H__ + +#include <asura-lib-utils/type.h> + +namespace AsuraEngine +{ + namespace Threading + { + + /// + /// ϣһ̴̳߳TaskдExecute + /// + ASURA_ABSTRACT class ThreadTask + { + public: + + virtual bool Execute() = 0; + + }; + + } +} + +namespace AEThreading = AsuraEngine::Threading; + +#endif
\ No newline at end of file diff --git a/source/libs/asura-lib-utils/utils_config.h b/source/libs/asura-lib-utils/utils_config.h index e69de29..836eb07 100644 --- a/source/libs/asura-lib-utils/utils_config.h +++ b/source/libs/asura-lib-utils/utils_config.h @@ -0,0 +1,6 @@ +#ifndef __ASURA_UTILS_CONFIG_H__ +#define __ASURA_UTILS_CONFIG_H__ + +#define ASURA_THREAD_WIN32 1 + +#endif
\ No newline at end of file diff --git a/source/libs/asura-lib-utils/utils_module.cpp b/source/libs/asura-lib-utils/utils_module.cpp index f335ec5..a0539ed 100644 --- a/source/libs/asura-lib-utils/utils_module.cpp +++ b/source/libs/asura-lib-utils/utils_module.cpp @@ -1,6 +1,7 @@ #include "utils_module.h" using namespace AsuraEngine::IO; +using namespace AsuraEngine::Threading; namespace AsuraEngine { @@ -12,6 +13,8 @@ namespace AsuraEngine LUAX_REGISTER_FACTORY(state, DataBuffer); LUAX_REGISTER_FACTORY(state, FileData); LUAX_REGISTER_FACTORY(state, File); + // Threading + LUAX_REGISTER_FACTORY(state, Thread); } void UtilsModule::Finalize(Luax::LuaxState& state) diff --git a/source/libs/asura-lib-utils/utils_module.h b/source/libs/asura-lib-utils/utils_module.h index bf80d27..ae875b9 100644 --- a/source/libs/asura-lib-utils/utils_module.h +++ b/source/libs/asura-lib-utils/utils_module.h @@ -6,6 +6,8 @@ #include "io/file_data.h" #include "io/file.h" +#include "threading/thread.h" + #include "module.h" namespace AsuraEngine |