diff options
Diffstat (limited to 'Source/Asura.Engine/Graphics')
23 files changed, 305 insertions, 121 deletions
diff --git a/Source/Asura.Engine/Graphics/Application.Graphics.cpp b/Source/Asura.Engine/Graphics/Application.Graphics.cpp index 64b9e09..4d3102f 100644 --- a/Source/Asura.Engine/Graphics/Application.Graphics.cpp +++ b/Source/Asura.Engine/Graphics/Application.Graphics.cpp @@ -15,6 +15,5 @@ namespace AsuraEngine return false; } - - + }
\ No newline at end of file diff --git a/Source/Asura.Engine/Graphics/Canvas.h b/Source/Asura.Engine/Graphics/Canvas.h index c258793..c4e0f65 100644 --- a/Source/Asura.Engine/Graphics/Canvas.h +++ b/Source/Asura.Engine/Graphics/Canvas.h @@ -8,15 +8,18 @@ #include "Texture.h" #include "RenderTarget.h" -namespace AsuraEngine +namespace AsuraEngine { - namespace Graphics + namespace Graphics { - + /// /// CanvasҲԳΪrender textureҲΪtextureȾ /// - class Canvas final : public Drawable, public RenderTarget, public Scripting::Portable + class Canvas ASURA_FINAL + : public Drawable + , public RenderTarget + , public Scripting::Portable { public: @@ -29,25 +32,17 @@ namespace AsuraEngine /// void SetSize(uint w, uint h); - /// - /// ȾtexturertϣԭϽǣң - /// - void Render(const RenderTarget* rt, const Math::Vector2i& pos, const Math::Vector2i& scale, const Math::Vector2i& center, float rot); + void Clear(const Color& col = Color::Black) override; - /// - /// ȾtextureһֵrtϣԭϽǣң졣 - /// - void Render(const RenderTarget* rt, const Math::Rectf& quad, const Math::Vector2i& pos, const Math::Vector2i& scale, const Math::Vector2i& center, float rot); + void Clear(const Math::Recti& quad, const Color& col = Color::Black) override; - //---------------------------------------------------------------------------------------------------------- + void Render(const RenderTarget* rt, const Math::Vector2i& pos, const Math::Vector2i& scale, const Math::Vector2i& center, float rot); - LUAX_DECL_FACTORY(SimCanvas); + void Render(const RenderTarget* rt, const Math::Rectf& quad, const Math::Vector2i& pos, const Math::Vector2i& scale, const Math::Vector2i& center, float rot); - LUAX_DECL_METHOD(l_SetSize); - LUAX_DECL_METHOD(l_Bind); - LUAX_DECL_METHOD(l_Unbind); + void Draw(const Drawable* texture, const RenderState& state); - //---------------------------------------------------------------------------------------------------------- + void Draw(const Drawable* texture, const Math::Recti& quad, const RenderState& state); private: @@ -61,8 +56,20 @@ namespace AsuraEngine /// uint mWidth, mHeight; + public: + + //---------------------------------------------------------------------------------------------------------- + + LUAX_DECL_FACTORY(SimCanvas); + + LUAX_DECL_METHOD(l_SetSize); + LUAX_DECL_METHOD(l_Bind); + LUAX_DECL_METHOD(l_Unbind); + + //---------------------------------------------------------------------------------------------------------- + }; - + /// /// CanvasΪRenderTexture /// diff --git a/Source/Asura.Engine/Graphics/Color.h b/Source/Asura.Engine/Graphics/Color.h index d8f39a0..0d65cb1 100644 --- a/Source/Asura.Engine/Graphics/Color.h +++ b/Source/Asura.Engine/Graphics/Color.h @@ -2,8 +2,8 @@ #define __ASURA_ENGINE_COLOR_H__ #include "Scripting/Luax.hpp" -#include "Object.h" -#include "Type.h" +#include "Scripting/Portable.h" +#include "Config.h" namespace AsuraEngine { @@ -15,12 +15,14 @@ namespace AsuraEngine /// /// 32bitsɫ /// - class Color32 : virtual public Object + class Color32 ASURA_FINAL: public Scripting::Portable { public: Color32(); + ~Color32(); + Color32(const Color32& c); Color32(const Color& c); @@ -33,6 +35,7 @@ namespace AsuraEngine LUAX_DECL_FACTORY(Color32); + LUAX_DECL_METHOD(l_ToColor); LUAX_DECL_METHOD(l_GetRed); LUAX_DECL_METHOD(l_GetGreen); LUAX_DECL_METHOD(l_GetBlue); @@ -48,7 +51,7 @@ namespace AsuraEngine /// /// 淶ɫ /// - class Color : virtual public Object + class Color ASURA_FINAL: public Scripting::Portable { public: @@ -66,6 +69,8 @@ namespace AsuraEngine Color(const Color32& c); + ~Color(); + Color operator *(const Color& c); float r, g, b, a; @@ -74,6 +79,7 @@ namespace AsuraEngine LUAX_DECL_FACTORY(Color); + LUAX_DECL_METHOD(l_ToColor32); LUAX_DECL_METHOD(l_SetColor); LUAX_DECL_METHOD(l_GetColor); LUAX_DECL_METHOD(l_Multiply); // ɫ˷ diff --git a/Source/Asura.Engine/Graphics/Image.cpp b/Source/Asura.Engine/Graphics/Image.cpp index 8287d76..e704945 100644 --- a/Source/Asura.Engine/Graphics/Image.cpp +++ b/Source/Asura.Engine/Graphics/Image.cpp @@ -1,3 +1,4 @@ +#include "Config.h" #include "Image.h" #include "GL.h" @@ -7,7 +8,6 @@ namespace AsuraEngine { Image::Image() - : Texture() { } @@ -16,18 +16,17 @@ namespace AsuraEngine } //\Ϣ - bool Image::Load(const ImageData* data) + bool Image::Load(ImageData* data) { - if (!data) - return false; - if (mImageData) - delete mImageData; - mImageData = data; + ASSERT(data); + glBindTexture(GL_TEXTURE_2D, mTextureHandle); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, data->width, data->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data->pixels); glBindTexture(GL_TEXTURE_2D, 0); return true; + + RRA(data, mImageData); } } -} +}
\ No newline at end of file diff --git a/Source/Asura.Engine/Graphics/Image.h b/Source/Asura.Engine/Graphics/Image.h index 7897f74..6d12303 100644 --- a/Source/Asura.Engine/Graphics/Image.h +++ b/Source/Asura.Engine/Graphics/Image.h @@ -1,12 +1,12 @@ #ifndef __ASURA_ENGINE_IMAGE_H__ #define __ASURA_ENGINE_IMAGE_H__ +#include "Math/Vector2.hpp" #include "FileSystem/Reloadable.h" #include "StringMap.hpp" #include "Manager.hpp" #include "Texture.h" #include "Color.h" -#include "Factory.h" #include "ImageData.h" namespace AsuraEngine @@ -20,46 +20,55 @@ namespace AsuraEngine /// ImageͼƬڴȡϷĽһImageڴ桢ԴֻᱣһݣҪ /// imageêλãźתǶȣʹspriteһֻࡣҪǿǵeditorengineʹòͬķװ /// - class Image final : public Drawable, public Scripting::Portable, public Filesystem::Reloadable + class Image ASURA_FINAL + : public Drawable + , public Scripting::Portable + , public Filesystem::Reloadable { public: Image(); + ~Image(); /// /// bufferimageϢmPixelsΪգݡ¹imageʹglTexImage2Dύimage /// ݡ /// - bool Load(const ImageData* data); + bool Load(ImageData* data); uint GetWidth(); uint GetHeight(); + Math::Vector2u GetSize(); /// /// ijһλõ /// Color32 GetPixel(uint x, uint y); - virtual void Render(const RenderTarget* rt, const RenderState& state) override; + void Render(const RenderTarget* rt, const RenderState& state) override; + + void Render(const RenderTarget* rt, const Math::Rectf& quad, const RenderState& state) override; + + private: + + ImageData* mImageData; - virtual void Render(const RenderTarget* rt, const Math::Rectf& quad, const RenderState& state) override; + Math::Vector2u mSize; + + public: //---------------------------------------------------------------------------------------------------------- LUAX_DECL_FACTORY(SimImage); LUAX_DECL_METHOD(l_Load); - LUAX_DECL_METHOD(l_GetPixel); LUAX_DECL_METHOD(l_GetWidth); LUAX_DECL_METHOD(l_GetHeight); + LUAX_DECL_METHOD(l_GetSize); //---------------------------------------------------------------------------------------------------------- - private: - - const ImageData* mImageData; - }; } diff --git a/Source/Asura.Engine/Graphics/ImageData.cpp b/Source/Asura.Engine/Graphics/ImageData.cpp index 002de67..68781a1 100644 --- a/Source/Asura.Engine/Graphics/ImageData.cpp +++ b/Source/Asura.Engine/Graphics/ImageData.cpp @@ -15,7 +15,7 @@ namespace AsuraEngine new STBDecoder() // jpeg, tga, bmp }; - ImageData::ImageData(const Filesystem::DataBuffer* buffer) + ImageData::ImageData(const Filesystem::DataBuffer& buffer) : DecodedData(buffer) { } @@ -29,7 +29,7 @@ namespace AsuraEngine /// /// ɹ׳쳣 /// - void ImageData::Decode(const Filesystem::DataBuffer* buffer) + void ImageData::Decode(const Filesystem::DataBuffer& buffer) { for (ImageDecoder* decoder : ImageDecoders) { diff --git a/Source/Asura.Engine/Graphics/ImageData.h b/Source/Asura.Engine/Graphics/ImageData.h index 925a5a0..931eaa3 100644 --- a/Source/Asura.Engine/Graphics/ImageData.h +++ b/Source/Asura.Engine/Graphics/ImageData.h @@ -13,43 +13,47 @@ namespace AsuraEngine { namespace Graphics { - - class ImageData final : public Filesystem::DecodedData, public Scripting::Portable + + class ImageData ASURA_FINAL + : public Filesystem::DecodedData + , public Scripting::Portable { public: /// /// ͼƬļϢʧܣ׳쳣 /// - ImageData(const Filesystem::DataBuffer* buffer); + ImageData(const Filesystem::DataBuffer& buffer); + ~ImageData(); Color GetPixel(uint x, uint y); - uint width, height; + uint width, height; PixelFormat format; std::size_t size; byte* pixels; - //---------------------------------------------------------------------------------------------------------- - - LUAX_DECL_FACTORY(ImageData); - - LUAX_DECL_METHOD(l_GetPixel); - LUAX_DECL_METHOD(l_GetSize); - - //---------------------------------------------------------------------------------------------------------- - private: - // stbJPEGTGABMP,lodePNGpngͼƬ - void Decode(const Filesystem::DataBuffer* buffer) override; + void Decode(const Filesystem::DataBuffer& buffer) override; /// /// ڵһimage dataʱṩdecoderڼdecodersмѡԡ /// static std::list<ImageDecoder*> ImageDecoders; + public: + + //---------------------------------------------------------------------------------------------------------- + + LUAX_DECL_FACTORY(ImageData); + + LUAX_DECL_METHOD(l_GetPixel); + LUAX_DECL_METHOD(l_GetSize); + + //---------------------------------------------------------------------------------------------------------- + }; } diff --git a/Source/Asura.Engine/Graphics/ImageDecoder.h b/Source/Asura.Engine/Graphics/ImageDecoder.h index 9dc2188..2c73fd1 100644 --- a/Source/Asura.Engine/Graphics/ImageDecoder.h +++ b/Source/Asura.Engine/Graphics/ImageDecoder.h @@ -10,7 +10,7 @@ namespace AsuraEngine namespace Graphics { - class ImageDecoder : virtual public Object + class ImageDecoder { public: @@ -20,12 +20,12 @@ namespace AsuraEngine /// /// жڴǷñdecoderѹ /// - virtual bool CanDecode(const Filesystem::DataBuffer* buffer) = 0; + virtual bool CanDecode(const Filesystem::DataBuffer& buffer) = 0; /// /// һڴ棬һѹImage dataѹʧܷnullptr /// - virtual void Decode(const Filesystem::DataBuffer* buffer, ImageData* data) = 0; + virtual void Decode(const Filesystem::DataBuffer& buffer, ImageData& data) = 0; }; diff --git a/Source/Asura.Engine/Graphics/Mesh2D.h b/Source/Asura.Engine/Graphics/Mesh2D.h index cadbec1..de4a0c8 100644 --- a/Source/Asura.Engine/Graphics/Mesh2D.h +++ b/Source/Asura.Engine/Graphics/Mesh2D.h @@ -3,7 +3,7 @@ #include "Scripting/Luax.hpp" -#include "Object.h" +#include "Scripting/Portable.h" namespace AsuraEngine { @@ -13,8 +13,13 @@ namespace AsuraEngine /// /// 2D meshһЩ㶯 /// - class Mesh2D : virtual public Object, public Scripting::Portable + class Mesh2D ASURA_FINAL: public Scripting::Portable { + public: + + Mesh2D(); + + ~Mesh2D(); }; diff --git a/Source/Asura.Engine/Graphics/PNGDecoder.cpp b/Source/Asura.Engine/Graphics/PNGDecoder.cpp index 363d478..f919090 100644 --- a/Source/Asura.Engine/Graphics/PNGDecoder.cpp +++ b/Source/Asura.Engine/Graphics/PNGDecoder.cpp @@ -5,12 +5,12 @@ namespace AsuraEngine namespace Graphics { - bool PNGDecoder::CanDecode(const Filesystem::DataBuffer* buffer) + bool PNGDecoder::CanDecode(const Filesystem::DataBuffer& buffer) { return false; } - void PNGDecoder::Decode(const Filesystem::DataBuffer* buffer, ImageData* data) + void PNGDecoder::Decode(const Filesystem::DataBuffer& buffer, ImageData& data) { } diff --git a/Source/Asura.Engine/Graphics/PNGDecoder.h b/Source/Asura.Engine/Graphics/PNGDecoder.h index dc5bb60..980753f 100644 --- a/Source/Asura.Engine/Graphics/PNGDecoder.h +++ b/Source/Asura.Engine/Graphics/PNGDecoder.h @@ -11,13 +11,13 @@ namespace AsuraEngine /// /// ʹlodepngѹpngļ /// - class PNGDecoder final : public ImageDecoder + class PNGDecoder ASURA_FINAL: public ImageDecoder { public: - bool CanDecode(const Filesystem::DataBuffer* buffer) override; + bool CanDecode(const Filesystem::DataBuffer& buffer) override; - void Decode(const Filesystem::DataBuffer* buffer, ImageData* data) override; + void Decode(const Filesystem::DataBuffer& buffer, ImageData& data) override; }; diff --git a/Source/Asura.Engine/Graphics/Port/Window.cpp b/Source/Asura.Engine/Graphics/Port/Window.cpp new file mode 100644 index 0000000..3befc8c --- /dev/null +++ b/Source/Asura.Engine/Graphics/Port/Window.cpp @@ -0,0 +1,11 @@ +#include "../Window.h" + +namespace AsuraEngine +{ + namespace Graphics + { + + + + } +} diff --git a/Source/Asura.Engine/Graphics/Quad.cpp b/Source/Asura.Engine/Graphics/Quad.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Source/Asura.Engine/Graphics/Quad.cpp diff --git a/Source/Asura.Engine/Graphics/Quad.h b/Source/Asura.Engine/Graphics/Quad.h new file mode 100644 index 0000000..b7dd3d9 --- /dev/null +++ b/Source/Asura.Engine/Graphics/Quad.h @@ -0,0 +1 @@ +// Quadrectڣrectǵıƫᣬquadһ diff --git a/Source/Asura.Engine/Graphics/RenderState.h b/Source/Asura.Engine/Graphics/RenderState.h index 9524ef6..f313296 100644 --- a/Source/Asura.Engine/Graphics/RenderState.h +++ b/Source/Asura.Engine/Graphics/RenderState.h @@ -16,10 +16,8 @@ namespace AsuraEngine /// /// Ⱦǰķʽ /// - class RenderState final : virtual public Object + struct RenderState ASURA_FINAL { - public: - /// /// Ĭϵrender state /// diff --git a/Source/Asura.Engine/Graphics/RenderTarget.h b/Source/Asura.Engine/Graphics/RenderTarget.h index afa8967..d6de164 100644 --- a/Source/Asura.Engine/Graphics/RenderTarget.h +++ b/Source/Asura.Engine/Graphics/RenderTarget.h @@ -3,7 +3,7 @@ #include "Math/Rect.hpp" #include "Texture.h" -#include "Object.h" +#include "Scripting/Portable.h" #include "Color.h" namespace AsuraEngine @@ -18,7 +18,7 @@ namespace AsuraEngine /// Canvas(RenderTexture) /// Window(RenderWindow) /// - class RenderTarget : virtual public Object + class RenderTarget { public: diff --git a/Source/Asura.Engine/Graphics/STBDecoder.cpp b/Source/Asura.Engine/Graphics/STBDecoder.cpp index d4d578f..b14d0f3 100644 --- a/Source/Asura.Engine/Graphics/STBDecoder.cpp +++ b/Source/Asura.Engine/Graphics/STBDecoder.cpp @@ -8,25 +8,21 @@ namespace AsuraEngine namespace Graphics { - bool STBDecoder::CanDecode(const Filesystem::DataBuffer* buffer) + bool STBDecoder::CanDecode(const Filesystem::DataBuffer& buffer) { int w = 0; int h = 0; int comp = 0; - int status = stbi_info_from_memory((const stbi_uc *)buffer->data, buffer->size, &w, &h, &comp); + int status = stbi_info_from_memory((const stbi_uc*)buffer.data, buffer.size, &w, &h, &comp); return status == 1 && w > 0 && h > 0; } - void STBDecoder::Decode(const Filesystem::DataBuffer* db, ImageData* imageData) + void STBDecoder::Decode(const Filesystem::DataBuffer& db, ImageData& imageData) { - if (!db) - throw Exception("Could not decode image with stb decoder because of null databuffer."); - if (!imageData) - throw Exception("Could not decode image with stb decoder because of null output image data."); - const stbi_uc *buffer = (const stbi_uc *)db->data; - int bufferlen = db->size; + const stbi_uc *buffer = (const stbi_uc *)db.data; + int bufferlen = db.size; int width, height; int comp = 0; byte* data = nullptr; @@ -49,12 +45,12 @@ namespace AsuraEngine if (data) { // ֤ڴ汻ͷţһϲûͷŵΪimage dataһԵģimageǶεġ - if (imageData->pixels) - delete[] imageData->pixels; - imageData->pixels = (byte*)data; - imageData->format = format; - imageData->width = width; - imageData->height = height; + if (imageData.pixels) + delete[] imageData.pixels; + imageData.pixels = (byte*)data; + imageData.format = format; + imageData.width = width; + imageData.height = height; } else { diff --git a/Source/Asura.Engine/Graphics/STBDecoder.h b/Source/Asura.Engine/Graphics/STBDecoder.h index d89042e..5567466 100644 --- a/Source/Asura.Engine/Graphics/STBDecoder.h +++ b/Source/Asura.Engine/Graphics/STBDecoder.h @@ -11,13 +11,13 @@ namespace AsuraEngine /// /// ʹstb_imageѹJPEGTGABMPļ /// - class STBDecoder final : public ImageDecoder + class STBDecoder ASURA_FINAL: public ImageDecoder { public: - bool CanDecode(const Filesystem::DataBuffer* buffer) override; + bool CanDecode(const Filesystem::DataBuffer& buffer) override; - void Decode(const Filesystem::DataBuffer* buffer, ImageData* data) override; + void Decode(const Filesystem::DataBuffer& buffer, ImageData& data) override; }; diff --git a/Source/Asura.Engine/Graphics/Shader.h b/Source/Asura.Engine/Graphics/Shader.h index 7dbfb0d..932cc42 100644 --- a/Source/Asura.Engine/Graphics/Shader.h +++ b/Source/Asura.Engine/Graphics/Shader.h @@ -11,7 +11,7 @@ #include "Math/Vector4.h" #include "Math/Matrix44.h" #include "StringMap.hpp" -#include "Object.h" +#include "Scripting/Portable.h" #include "Color.h" #include "Manager.hpp" #include "Texture.h" @@ -26,13 +26,16 @@ namespace AsuraEngine /// һshaderһڲʼ乲ijShaderuniformsͶݣֻṩuniformsuseɫķ༭ /// ÿshaderͨshaderҵuniforms¶frameworkmaterialá /// - class Shader final : virtual public Object, public Filesystem::Reloadable + class Shader ASURA_FINAL + : public Scripting::Portable + , public Filesystem::Reloadable { public: Shader(); + ~Shader(); - + /// /// ӴshaderʱȼǷϴλuniforms location mapʹglAttachShader±ɫ /// ɫ @@ -42,12 +45,12 @@ namespace AsuraEngine /// /// shaderΪ /// - void Use(); + void Use(); /// /// shaderΪǻ /// - void Unuse(); + void Unuse(); /// /// Ѿ֪uniform location£ֵ @@ -71,25 +74,6 @@ namespace AsuraEngine /// static uint GetGLTextureUnitCount(); - //---------------------------------------------------------------------------------------------------------- - - 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); - - //---------------------------------------------------------------------------------------------------------- - private: /// @@ -110,6 +94,27 @@ namespace AsuraEngine /// GLuint mProgramHandle; + public: + + //---------------------------------------------------------------------------------------------------------- + + 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); + + //---------------------------------------------------------------------------------------------------------- + }; } diff --git a/Source/Asura.Engine/Graphics/SpriteBatch.h b/Source/Asura.Engine/Graphics/SpriteBatch.h index a571775..353bf77 100644 --- a/Source/Asura.Engine/Graphics/SpriteBatch.h +++ b/Source/Asura.Engine/Graphics/SpriteBatch.h @@ -1,7 +1,7 @@ #ifndef __ASURA_ENGINE_SPRITE_BATCH_H__ #define __ASURA_ENGINE_SPRITE_BATCH_H__ -#include "Object.h" +#include "Scripting/Portable.h" namespace AsuraEngine { @@ -11,12 +11,14 @@ namespace AsuraEngine /// /// Sprite batchȾͼƬĵطϵͳ /// - class SpriteBatch : virtual public Object + class SpriteBatch ASURA_FINAL : public Scripting::Portable { public: SpriteBatch(); + ~SpriteBatch(); + }; } diff --git a/Source/Asura.Engine/Graphics/Texture.h b/Source/Asura.Engine/Graphics/Texture.h index c1411fc..81aa469 100644 --- a/Source/Asura.Engine/Graphics/Texture.h +++ b/Source/Asura.Engine/Graphics/Texture.h @@ -1,6 +1,7 @@ #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" @@ -18,7 +19,7 @@ namespace AsuraEngine /// 2D࣬2d meshrender targetбʹáTextureȾԭϽǣϷϲԵѿϵΪ /// EditorҲϽΪԭ㣬Ϊ˷㡣 /// - class Texture : virtual public Object + ASURA_ABSTRACT class Texture { public: @@ -48,7 +49,7 @@ namespace AsuraEngine /// void SetRepeated(); - protected: + protected: /// /// OpenGL texture handle diff --git a/Source/Asura.Engine/Graphics/Window.cpp b/Source/Asura.Engine/Graphics/Window.cpp new file mode 100644 index 0000000..bb941e1 --- /dev/null +++ b/Source/Asura.Engine/Graphics/Window.cpp @@ -0,0 +1,56 @@ +#include "Config.h" +#include "Window.h" + +namespace AsuraEngine +{ + namespace Graphics + { + + Window::Window(WindowStyle style) + { + //mWindowHandle = SDL_CreateWindow(); + } + + Window::~Window() + { + + } + + SDL_Window* Window::GetSDLWindowHandle() + { + return mWindowHandle; + } + + void Window::SetPosition(int x, int y) + { + ASSERT(mWindowHandle); + SDL_SetWindowPosition(mWindowHandle, x, 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/Graphics/Window.h b/Source/Asura.Engine/Graphics/Window.h new file mode 100644 index 0000000..973fd98 --- /dev/null +++ b/Source/Asura.Engine/Graphics/Window.h @@ -0,0 +1,85 @@ +#ifndef __ASURA_ENGINE_WINDOW_H__ +#define __ASURA_ENGINE_WINDOW_H__ + +#include "SDL2/Sdl.h" +#include "Graphics/RenderTarget.h" +#include "Math/Vector2.hpp" +#include "Scripting/Portable.h" + +namespace AsuraEngine +{ + namespace Graphics + { + + enum WindowStyle + { + WINDOW_STYLE_FULLSCREEN = 1 << 1, + }; + + /// + /// ڣֶ֧രڡڱ༭Ҫ֧֣runnerֻҪһڡ + /// + class Window ASURA_FINAL + : public RenderTarget + , public Scripting::Portable + { + public: + + Window(WindowStyle style); + + ~Window(); + + SDL_Window* GetSDLWindowHandle(); + + void SetSize(uint width, uint height); + + void SetPosition(int x, int y); + + void SetTitle(const std::string& title); + + void SetWindowStyle(WindowStyle style); + + void Show(); + + void Hide(); + + /// + /// ǿ˫ĴڣҪչʾǰ̨ + /// + void SwapRenderBuffer(); + + void Clear(const Color& col = Color::Black) override; + + void Clear(const Math::Recti& quad, const Color& col = Color::Black) override; + + void Draw(const Drawable* texture, const RenderState& state) override; + + void Draw(const Drawable* texture, const Math::Recti& quad, const RenderState& state) override; + + private: + + /// + /// SDL window handle. + /// + SDL_Window* mWindowHandle; + + Math::Vector2i mPosition; + + Math::Vector2i mSize; + + public: + + //---------------------------------------------------------------------------------------------------------- + + LUAX_DECL_FACTORY(Window); + + //---------------------------------------------------------------------------------------------------------- + + }; + + using RenderWindow = Window; + + } +} + +#endif
\ No newline at end of file |