diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/Asura.Engine/Application.cpp | 29 | ||||
-rw-r--r-- | Source/Asura.Engine/Application.h | 33 | ||||
-rw-r--r-- | Source/Asura.Engine/FileSystem/DecodedData.cpp | 1 | ||||
-rw-r--r-- | Source/Asura.Engine/FileSystem/Reloadable.h | 24 | ||||
-rw-r--r-- | Source/Asura.Engine/FileSystem/新建文本文档.txt | 0 | ||||
-rw-r--r-- | Source/Asura.Engine/Graphics/Application.Graphics.cpp | 20 | ||||
-rw-r--r-- | Source/Asura.Engine/Graphics/Image.h | 3 | ||||
-rw-r--r-- | Source/Asura.Engine/Graphics/ImageData.cpp | 6 | ||||
-rw-r--r-- | Source/Asura.Engine/Graphics/Shader.h | 3 | ||||
-rw-r--r-- | Source/Asura.Engine/Window/Window.cpp | 39 | ||||
-rw-r--r-- | Source/Asura.Engine/Window/Window.h | 16 | ||||
-rw-r--r-- | Source/Asura.Runner/Runner.h | 15 | ||||
-rw-r--r-- | Source/Asura.Runner/main.cpp | 11 |
13 files changed, 159 insertions, 41 deletions
diff --git a/Source/Asura.Engine/Application.cpp b/Source/Asura.Engine/Application.cpp index ba5feaa..59f5aae 100644 --- a/Source/Asura.Engine/Application.cpp +++ b/Source/Asura.Engine/Application.cpp @@ -1,4 +1,6 @@ #include "Application.h" +#include "Sdl2/SDL.h" +#include "Exceptions/Exception.h" namespace AsuraEngine { @@ -13,18 +15,23 @@ namespace AsuraEngine } - bool InitGraphics(bool init) + bool Application::Application::InitSubModules(uint flag) { - if (!init) return true; - - } + // ʼģ + #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); - bool Application::Init(int flag) - { - if (!InitGraphics(flag & ASURA_MODULE_GRAPHICS)) - { - - } + } -} +}
\ No newline at end of file diff --git a/Source/Asura.Engine/Application.h b/Source/Asura.Engine/Application.h index 68db22b..431924a 100644 --- a/Source/Asura.Engine/Application.h +++ b/Source/Asura.Engine/Application.h @@ -11,18 +11,18 @@ namespace AsuraEngine /// enum SubModules { - ASURA_MODULE_NONE = 0x00000000, + ASURA_MODULE_NONE = 0X00000000U, ASURA_MODULE_GRAPHICS = 1 << 1, - ASURA_MODULE_AUDIO = 1 << 2, - ASURA_MODULE_FONT = 1 << 3, - ASURA_MODULE_INPUT = 1 << 4, - ASURA_MODULE_MATH = 1 << 5, - ASURA_MODULE_PHYSICS = 1 << 6, - ASURA_MODULE_TIME = 1 << 7, - ASURA_MODULE_WINDOW = 1 << 8, - - ASURA_MODULE_ALL = 0XFFFFFFFF + ASURA_MODULE_AUDIO = 1 << 2, + ASURA_MODULE_FONT = 1 << 3, + ASURA_MODULE_INPUT = 1 << 4, + ASURA_MODULE_MATH = 1 << 5, + ASURA_MODULE_PHYSICS = 1 << 6, + ASURA_MODULE_TIME = 1 << 7, + ASURA_MODULE_WINDOW = 1 << 8, + + ASURA_MODULE_ALL = 0XFFFFFFFFU }; /// @@ -39,10 +39,21 @@ namespace AsuraEngine /// /// ʼǰϵͳ /// - bool Init(int subsystems = ASURA_MODULE_ALL); + bool InitSubModules(uint flag = ASURA_MODULE_ALL); virtual void Run(); + private: + + bool InitGraphics(); + bool InitAudio(); + bool InitFont(); + bool InitInput(); + bool InitMath(); + bool InitPhysics(); + bool InitTime(); + bool InitWindow(); + }; } diff --git a/Source/Asura.Engine/FileSystem/DecodedData.cpp b/Source/Asura.Engine/FileSystem/DecodedData.cpp index 90726cf..125c652 100644 --- a/Source/Asura.Engine/FileSystem/DecodedData.cpp +++ b/Source/Asura.Engine/FileSystem/DecodedData.cpp @@ -1,4 +1,5 @@ #include "DecodedData.h" +#include "Exceptions/Exception.h" namespace AsuraEngine { diff --git a/Source/Asura.Engine/FileSystem/Reloadable.h b/Source/Asura.Engine/FileSystem/Reloadable.h new file mode 100644 index 0000000..e07b094 --- /dev/null +++ b/Source/Asura.Engine/FileSystem/Reloadable.h @@ -0,0 +1,24 @@ +#ifndef __ASURA_ENGINE_RELOADABLE_H__ +#define __ASURA_ENGINE_RELOADABLE_H__ + +#include "Object.h" + +namespace AsuraEngine +{ + namespace Filesystem + { + + class Reloadable : virtual public Object + { + public: + Reloadable(); + ~Reloadable(); + + virtual bool Load(); + + }; + + } +} + +#endif
\ No newline at end of file diff --git a/Source/Asura.Engine/FileSystem/新建文本文档.txt b/Source/Asura.Engine/FileSystem/新建文本文档.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Source/Asura.Engine/FileSystem/新建文本文档.txt diff --git a/Source/Asura.Engine/Graphics/Application.Graphics.cpp b/Source/Asura.Engine/Graphics/Application.Graphics.cpp new file mode 100644 index 0000000..64b9e09 --- /dev/null +++ b/Source/Asura.Engine/Graphics/Application.Graphics.cpp @@ -0,0 +1,20 @@ +#include "Application.h" +#include "Sdl2/SDL.h" +#include "Exceptions/Exception.h" + +namespace AsuraEngine +{ + + /// + /// ʼgraphicsģ + /// + bool Application::InitGraphics() + { + + if (SDL_Init(SDL_INIT_VIDEO) < 0) + return false; + + } + + +}
\ No newline at end of file diff --git a/Source/Asura.Engine/Graphics/Image.h b/Source/Asura.Engine/Graphics/Image.h index da881aa..7897f74 100644 --- a/Source/Asura.Engine/Graphics/Image.h +++ b/Source/Asura.Engine/Graphics/Image.h @@ -1,6 +1,7 @@ #ifndef __ASURA_ENGINE_IMAGE_H__ #define __ASURA_ENGINE_IMAGE_H__ +#include "FileSystem/Reloadable.h" #include "StringMap.hpp" #include "Manager.hpp" #include "Texture.h" @@ -19,7 +20,7 @@ namespace AsuraEngine /// ImageͼƬڴȡϷĽһImageڴ桢ԴֻᱣһݣҪ /// imageêλãźתǶȣʹspriteһֻࡣҪǿǵeditorengineʹòͬķװ /// - class Image final : public Drawable, public Scripting::Portable + class Image final : public Drawable, public Scripting::Portable, public Filesystem::Reloadable { public: diff --git a/Source/Asura.Engine/Graphics/ImageData.cpp b/Source/Asura.Engine/Graphics/ImageData.cpp index af448bd..002de67 100644 --- a/Source/Asura.Engine/Graphics/ImageData.cpp +++ b/Source/Asura.Engine/Graphics/ImageData.cpp @@ -15,12 +15,6 @@ namespace AsuraEngine new STBDecoder() // jpeg, tga, bmp }; - void ImageData::ReleaseAllDecoders() - { - for (ImageDecoder* decoder : ImageDecoders) - decoder->Release(); - } - ImageData::ImageData(const Filesystem::DataBuffer* buffer) : DecodedData(buffer) { diff --git a/Source/Asura.Engine/Graphics/Shader.h b/Source/Asura.Engine/Graphics/Shader.h index 831f5c3..7dbfb0d 100644 --- a/Source/Asura.Engine/Graphics/Shader.h +++ b/Source/Asura.Engine/Graphics/Shader.h @@ -4,6 +4,7 @@ #include <map> #include <string> +#include "FileSystem/Reloadable.h" #include "Scripting/Luax.hpp" #include "Math/Vector2.hpp" #include "Math/Vector3.hpp" @@ -25,7 +26,7 @@ namespace AsuraEngine /// һshaderһڲʼ乲ijShaderuniformsͶݣֻṩuniformsuseɫķ༭ /// ÿshaderͨshaderҵuniforms¶frameworkmaterialá /// - class Shader final : virtual public Object + class Shader final : virtual public Object, public Filesystem::Reloadable { public: diff --git a/Source/Asura.Engine/Window/Window.cpp b/Source/Asura.Engine/Window/Window.cpp index 5e800e0..6e9300f 100644 --- a/Source/Asura.Engine/Window/Window.cpp +++ b/Source/Asura.Engine/Window/Window.cpp @@ -5,9 +5,9 @@ namespace AsuraEngine namespace Graphics { - Window::Window() + Window::Window(WindowStyle style) { - + //mWindowHandle = SDL_CreateWindow(); } Window::~Window() @@ -15,5 +15,40 @@ namespace AsuraEngine } + SDL_Window* Window::GetSDLWindowHandle() + { + return mWindowHandle; + } + + void Window::SetPosition(int x, int y) + { + + } + + void Window::SetTitle(const std::string& title) + { + + } + + void Window::Show() + { + + } + + void Window::Hide() + { + + } + + void Window::SetWindowStyle(WindowStyle style) + { + + } + + void Window::SwapRenderBuffer() + { + + } + } } diff --git a/Source/Asura.Engine/Window/Window.h b/Source/Asura.Engine/Window/Window.h index 3456d75..71aaf0e 100644 --- a/Source/Asura.Engine/Window/Window.h +++ b/Source/Asura.Engine/Window/Window.h @@ -12,21 +12,21 @@ namespace AsuraEngine enum WindowStyle { - + WINDOW_STYLE_FULLSCREEN = 1 << 1, }; /// /// ڣֶ֧രڡڱ༭Ҫ֧֣runnerֻҪһڡ /// - class Window final : public RenderTarget + class Window : public RenderTarget { public: - Window(); + Window(WindowStyle style); ~Window(); - SDL_Window* GetSDLHandle(); + SDL_Window* GetSDLWindowHandle(); void SetSize(uint width, uint height); @@ -45,6 +45,14 @@ namespace AsuraEngine /// void SwapRenderBuffer(); + void Clear(const Color& col = Color::Black); + + void Clear(const Math::Recti& quad, const Color& col = Color::Black); + + void Draw(const Drawable* texture, const RenderState& state); + + void Draw(const Drawable* texture, const Math::Recti& quad, const RenderState& state); + private: /// diff --git a/Source/Asura.Runner/Runner.h b/Source/Asura.Runner/Runner.h new file mode 100644 index 0000000..45d9028 --- /dev/null +++ b/Source/Asura.Runner/Runner.h @@ -0,0 +1,15 @@ +#ifndef __ASURA_RUNNER_H__ +#define __ASURA_RUNNER_H__ + +#include "Asura.h" + +using namespace AsuraEngine; + +class Runner : public Application +{ +public: + + +}; + +#endif
\ No newline at end of file diff --git a/Source/Asura.Runner/main.cpp b/Source/Asura.Runner/main.cpp index 96b17bb..3947f65 100644 --- a/Source/Asura.Runner/main.cpp +++ b/Source/Asura.Runner/main.cpp @@ -1,11 +1,12 @@ -#include "Asura.h" +#include "Runner.h" // ϷᱻһԴļrunnerȡݣϷ // RunnerֻܶȡpackerϷļeditorֱϷassetsRunnerһСл int main() { - - Applicatoin runner; - runner.Init(ASURAMODULE_ALL); - + Runner runner; + runner.Init(); + runner.Run(); + runner.Exit(); + return 0; }
\ No newline at end of file |