diff options
Diffstat (limited to 'source/libs/asura-lib-core')
-rw-r--r-- | source/libs/asura-lib-core/application.cpp | 33 | ||||
-rw-r--r-- | source/libs/asura-lib-core/application.h | 14 | ||||
-rw-r--r-- | source/libs/asura-lib-core/asura.h | 15 | ||||
-rw-r--r-- | source/libs/asura-lib-core/client/client.h | 15 | ||||
-rw-r--r-- | source/libs/asura-lib-core/client/sdl/sdl_thread.cpp | 0 | ||||
-rw-r--r-- | source/libs/asura-lib-core/client/sdl/sdl_thread.h | 0 | ||||
-rw-r--r-- | source/libs/asura-lib-core/client/sdl/sdl_window.h | 17 | ||||
-rw-r--r-- | source/libs/asura-lib-core/config.h | 4 | ||||
-rw-r--r-- | source/libs/asura-lib-core/core_config.h | 8 | ||||
-rw-r--r-- | source/libs/asura-lib-core/graphics/binding/image_data.binding.cpp | 56 | ||||
-rw-r--r-- | source/libs/asura-lib-core/graphics/canvas.h | 14 | ||||
-rw-r--r-- | source/libs/asura-lib-core/graphics/color.h | 5 | ||||
-rw-r--r-- | source/libs/asura-lib-core/graphics/gl.cpp | 2 | ||||
-rw-r--r-- | source/libs/asura-lib-core/graphics/image_data.cpp | 3 | ||||
-rw-r--r-- | source/libs/asura-lib-core/graphics/image_data.h | 24 | ||||
-rw-r--r-- | source/libs/asura-lib-core/graphics/image_decoder.h | 4 |
16 files changed, 109 insertions, 105 deletions
diff --git a/source/libs/asura-lib-core/application.cpp b/source/libs/asura-lib-core/application.cpp index 598bca8..0a1c1ef 100644 --- a/source/libs/asura-lib-core/application.cpp +++ b/source/libs/asura-lib-core/application.cpp @@ -20,40 +20,7 @@ namespace AsuraEngine bool Application::InitSubModules(uint flag) { - // ʼģ - #define TryInitSubModule(module_name, func_name) \ - if((flag&ASURA_MODULE_##module_name) && !Application::Init##func_name()) \ - throw Exception("Asura init submodule %s failed.", #module_name); - - TryInitSubModule(GRAPHICS, Graphics); - TryInitSubModule(AUDIO, Audio); - TryInitSubModule(FONT, Font); - TryInitSubModule(INPUT, Input); - TryInitSubModule(MATH, Math); - TryInitSubModule(PHYSICS, Physics); - TryInitSubModule(TIME, Time); - TryInitSubModule(WINDOW, Window); } - void Application::PortToLua() - { - LuaxState state(mLuaState); - -#define RegisterLuaFactory(T) state.RegisterFactory<T>(); - - state.SetToGlobalNamespace(); - state.PushNamespace("AsuraEngine"); - - RegisterLuaFactory(AEGraphics::Image>); - -#ifdef ASURA_AUTHOR - state.PushNamespace("Version"); - - state.PopNamespace(); // AsuraEngine.Version -#endif - - state.PopNamespace(); // AsuraEngine - } - }
\ No newline at end of file diff --git a/source/libs/asura-lib-core/application.h b/source/libs/asura-lib-core/application.h index 6ae3218..983dbce 100644 --- a/source/libs/asura-lib-core/application.h +++ b/source/libs/asura-lib-core/application.h @@ -5,7 +5,7 @@ #include <asura-lib-utils/module.h> #include <queue> -#include "config.h" +#include "core_config.h" namespace AsuraEngine { @@ -65,18 +65,6 @@ namespace AsuraEngine private: /// - /// ģʼڸģļʵ֡ - /// - bool InitGraphics(); - bool InitAudio(); - bool InitFont(); - bool InitInput(); - bool InitMath(); - bool InitPhysics(); - bool InitTime(); - bool InitWindow(); - - /// /// Lua state. /// lua_State* mLuaState; diff --git a/source/libs/asura-lib-core/asura.h b/source/libs/asura-lib-core/asura.h deleted file mode 100644 index 5ca56f3..0000000 --- a/source/libs/asura-lib-core/asura.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef __ASURA_ENGINE_H__ -#define __ASURA_ENGINE_H__ - -#include "Application.h" - -#include "Graphics/Shader.h" - -//namespace AEGraphics = AsuraEngine::Graphics; -//namespace AEMath = AsuraEngine::Math; -//namespace AETime = AsuraEngine::Time; -//namespace AEInput = AsuraEngine::Input; -//namespace AEProfiler = AsuraEngine::Profiler; -//namespace AEFont = AsuraEngine::Font; - -#endif
\ No newline at end of file diff --git a/source/libs/asura-lib-core/client/client.h b/source/libs/asura-lib-core/client/client.h index f2464a5..8df30fe 100644 --- a/source/libs/asura-lib-core/client/client.h +++ b/source/libs/asura-lib-core/client/client.h @@ -1,16 +1,23 @@ #ifndef __ASURA_ENGINE_HOST_H__ #define __ASURA_ENGINE_HOST_H__ -/** -* ʹڿйص -*/ +#include <asura-lib-utils/type.h> +/// +/// ʹйصʵ֣ǵϷĿƽ̨ʹüֱʵ֡༭벻ڿƽ̨ڿ⣬Ŀǰʹwin32APIʵϢѭ +/// namespace AsuraEngine { - namespace Host + namespace Client { + /// + /// ࡣ + /// + ASURA_ABSTRACT class Client + { + }; } } diff --git a/source/libs/asura-lib-core/client/sdl/sdl_thread.cpp b/source/libs/asura-lib-core/client/sdl/sdl_thread.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/libs/asura-lib-core/client/sdl/sdl_thread.cpp diff --git a/source/libs/asura-lib-core/client/sdl/sdl_thread.h b/source/libs/asura-lib-core/client/sdl/sdl_thread.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/source/libs/asura-lib-core/client/sdl/sdl_thread.h diff --git a/source/libs/asura-lib-core/client/sdl/sdl_window.h b/source/libs/asura-lib-core/client/sdl/sdl_window.h index 1fdef1e..040c23e 100644 --- a/source/libs/asura-lib-core/client/sdl/sdl_window.h +++ b/source/libs/asura-lib-core/client/sdl/sdl_window.h @@ -1,14 +1,29 @@ #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
\ No newline at end of file +#endif // ASURA_CORE_SDL + +#endif // __ASURA_SDL_WINDOW_H__
\ No newline at end of file diff --git a/source/libs/asura-lib-core/config.h b/source/libs/asura-lib-core/config.h deleted file mode 100644 index df7ad99..0000000 --- a/source/libs/asura-lib-core/config.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef __ASURA_CORE_CONFIG_H__ -#define __ASURA_CORE_CONFIG_H__ - -#endif
\ No newline at end of file diff --git a/source/libs/asura-lib-core/core_config.h b/source/libs/asura-lib-core/core_config.h new file mode 100644 index 0000000..06eecc7 --- /dev/null +++ b/source/libs/asura-lib-core/core_config.h @@ -0,0 +1,8 @@ +#ifndef __ASURA_CORE_CONFIG_H__ +#define __ASURA_CORE_CONFIG_H__ + +#define ASURA_CORE_SDL 1 +#define ASURA_CORE_GLUT 0 +#define ASURA_CORE_GLFW 0 + +#endif
\ No newline at end of file diff --git a/source/libs/asura-lib-core/graphics/binding/image_data.binding.cpp b/source/libs/asura-lib-core/graphics/binding/image_data.binding.cpp index 0d68c11..72e33da 100644 --- a/source/libs/asura-lib-core/graphics/binding/image_data.binding.cpp +++ b/source/libs/asura-lib-core/graphics/binding/image_data.binding.cpp @@ -1,4 +1,4 @@ -#include "../image.h" +#include "../image_data.h" using namespace Luax; @@ -7,23 +7,55 @@ namespace AsuraEngine namespace Graphics { - void Image::RegisterLuaxClass(LuaxState& state) + LUAX_REGISTRY(ImageData) { } - void Image::RegisterLuaxPostprocess(LuaxState& state) + LUAX_POSTPROCESS(ImageData) + { + LUAX_REGISTER_ENUM(state, "EBlendMode", + { "Additive", 1 } + ); + LUAX_REGISTER_ENUM(state, "EPixelFormat", + { "RGBA32", 1 } + ); + } + + // imagedata = ImageData.New(databuffer) + 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; + } + + LUAX_IMPL_METHOD(ImageData, _GetPixel) + { + + } + + LUAX_IMPL_METHOD(ImageData, _GetSize) + { + + } + + LUAX_IMPL_METHOD(ImageData, _GetWidth) + { + + } + + LUAX_IMPL_METHOD(ImageData, _GetHeight) + { + + } + + LUAX_IMPL_METHOD(ImageData, _GetPixelFormat) { - // blendö٣AsuraEngine.EBlendMode - LuaxEnum EBlendMode[] = { - { "Additive", 1 }, - { "PreBlend", 2 }, - { "Substruction", 3 }, - { "Multiplied", 4 }, - {0, 0} - }; - state.RegisterEnum("EBlendMode", EBlendMode); } } diff --git a/source/libs/asura-lib-core/graphics/canvas.h b/source/libs/asura-lib-core/graphics/canvas.h index c4e0f65..6b8b630 100644 --- a/source/libs/asura-lib-core/graphics/canvas.h +++ b/source/libs/asura-lib-core/graphics/canvas.h @@ -1,12 +1,14 @@ #ifndef __ASURA_ENGINE_CANVAS_H__ #define __ASURA_ENGINE_CANVAS_H__ -#include <Scripting/Luax.hpp> +#include <asura-lib-utils/scripting/portable.hpp> +#include <asura-lib-utils/math/rect.hpp> +#include <asura-lib-utils/math/vector2.hpp> -#include "Math/Rect.hpp" -#include "GL.h" -#include "Texture.h" -#include "RenderTarget.h" +#include "gl.h" +#include "texture.h" +#include "render_target.h" +#include "render_state.h" namespace AsuraEngine { @@ -19,7 +21,7 @@ namespace AsuraEngine class Canvas ASURA_FINAL : public Drawable , public RenderTarget - , public Scripting::Portable + , public Scripting::Portable<Canvas> { public: diff --git a/source/libs/asura-lib-core/graphics/color.h b/source/libs/asura-lib-core/graphics/color.h index a18c682..74cf8f3 100644 --- a/source/libs/asura-lib-core/graphics/color.h +++ b/source/libs/asura-lib-core/graphics/color.h @@ -1,8 +1,9 @@ #ifndef __ASURA_ENGINE_COLOR_H__ #define __ASURA_ENGINE_COLOR_H__ -#include "config.h" -#include "scripting/portable.hpp" +#include <asura-lib-utils/scripting/portable.hpp> + +#include "../core_config.h" namespace AsuraEngine { diff --git a/source/libs/asura-lib-core/graphics/gl.cpp b/source/libs/asura-lib-core/graphics/gl.cpp index 01c90de..7c68c8f 100644 --- a/source/libs/asura-lib-core/graphics/gl.cpp +++ b/source/libs/asura-lib-core/graphics/gl.cpp @@ -1,4 +1,4 @@ -#include "config.h" +#include "../core_config.h" #include "gl.h" namespace AsuraEngine diff --git a/source/libs/asura-lib-core/graphics/image_data.cpp b/source/libs/asura-lib-core/graphics/image_data.cpp index 821bfd6..28c706a 100644 --- a/source/libs/asura-lib-core/graphics/image_data.cpp +++ b/source/libs/asura-lib-core/graphics/image_data.cpp @@ -1,6 +1,7 @@ #include "image_data.h" #include "png_decoder.h" #include "stb_decoder.h" +#include "image_decoder.h" namespace AsuraEngine { @@ -35,7 +36,7 @@ namespace AsuraEngine { if (decoder->CanDecode(buffer)) { - decoder->Decode(buffer, this); + decoder->Decode(buffer, *this); return; } } diff --git a/source/libs/asura-lib-core/graphics/image_data.h b/source/libs/asura-lib-core/graphics/image_data.h index 1e711a8..53a9e85 100644 --- a/source/libs/asura-lib-core/graphics/image_data.h +++ b/source/libs/asura-lib-core/graphics/image_data.h @@ -3,9 +3,10 @@ #include <list> -#include "scripting/luax.hpp" -#include "filesystem/decoded_data.h" -#include "image_decoder.h" +#include <asura-lib-utils/scripting/portable.hpp> +#include <asura-lib-utils/filesystem/decoded_data.h> +#include <asura-lib-utils/filesystem/data_buffer.h> + #include "pixel_format.h" #include "color.h" @@ -14,9 +15,11 @@ namespace AsuraEngine namespace Graphics { + class ImageDecoder; + class ImageData ASURA_FINAL : public Filesystem::DecodedData - , public Scripting::Portable + , public Scripting::Portable<ImageData> { public: @@ -24,7 +27,6 @@ namespace AsuraEngine /// ͼƬļϢʧܣ׳쳣 /// ImageData(const Filesystem::DataBuffer& buffer); - ~ImageData(); Color GetPixel(uint x, uint y); @@ -45,14 +47,14 @@ namespace AsuraEngine public: - //---------------------------------------------------------------------------------------------------------- - LUAX_DECL_FACTORY(ImageData); - LUAX_DECL_METHOD(l_GetPixel); - LUAX_DECL_METHOD(l_GetSize); - - //---------------------------------------------------------------------------------------------------------- + LUAX_DECL_METHOD(_New); + LUAX_DECL_METHOD(_GetPixel); + LUAX_DECL_METHOD(_GetSize); + LUAX_DECL_METHOD(_GetWidth); + LUAX_DECL_METHOD(_GetHeight); + LUAX_DECL_METHOD(_GetPixelFormat); }; diff --git a/source/libs/asura-lib-core/graphics/image_decoder.h b/source/libs/asura-lib-core/graphics/image_decoder.h index 2c73fd1..921d129 100644 --- a/source/libs/asura-lib-core/graphics/image_decoder.h +++ b/source/libs/asura-lib-core/graphics/image_decoder.h @@ -1,9 +1,9 @@ #ifndef __ASURA_ENGINE_IMAGE_DECODER_H__ #define __ASURA_ENGINE_IMAGE_DECODER_H__ -#include "FileSystem/DataBuffer.h" +#include <asura-lib-utils/filesystem/data_buffer.h> -#include "ImageData.h" +#include "image_data.h" namespace AsuraEngine { |