diff options
Diffstat (limited to 'Source/Asura.Engine')
57 files changed, 2069 insertions, 161 deletions
diff --git a/Source/Asura.Engine/Application.cpp b/Source/Asura.Engine/Application.cpp new file mode 100644 index 0000000..2f0b8d0 --- /dev/null +++ b/Source/Asura.Engine/Application.cpp @@ -0,0 +1,24 @@ +#include "Application.h" + +namespace AsuraEngine +{ + + Application::Application() + { + + } + + Application::~Application() + { + + } + + bool Application::Init(int flag) + { + if (flag & Asura_Graphics) + { + + } + } + +} diff --git a/Source/Asura.Engine/Application.h b/Source/Asura.Engine/Application.h new file mode 100644 index 0000000..174ab91 --- /dev/null +++ b/Source/Asura.Engine/Application.h @@ -0,0 +1,50 @@ +#ifndef __ASURA_ENGINE_APPLICATION_H__ +#define __ASURA_ENGINE_APPLICATION_H__ + +#include "Object.h" + +namespace AsuraEngine +{ + + /// + /// ģ + /// + enum SubModules + { + ASURA_NOMODULE = 0x00000000, + + 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, + + ASURAMODULE_ALL = 0XFFFFFFFF + }; + + /// + /// ѭ + /// + class Application : public Object + { + public: + + Application(); + + virtual ~Application(); + + /// + /// ʼǰϵͳ + /// + bool Init(int subsystems = Asura_All); + + virtual void Run(); + + }; + +} + +#endif
\ No newline at end of file diff --git a/Source/Asura.Engine/Asura.h b/Source/Asura.Engine/Asura.h index ae6f68e..e1d8940 100644 --- a/Source/Asura.Engine/Asura.h +++ b/Source/Asura.Engine/Asura.h @@ -1,12 +1,14 @@ #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 AETime = AsuraEngine::Time; +//namespace AEInput = AsuraEngine::Input; +//namespace AEProfiler = AsuraEngine::Profiler; #endif
\ No newline at end of file diff --git a/Source/Asura.Engine/Audio/Sound.h b/Source/Asura.Engine/Audio/Sound.h index e69de29..3bacd09 100644 --- a/Source/Asura.Engine/Audio/Sound.h +++ b/Source/Asura.Engine/Audio/Sound.h @@ -0,0 +1,19 @@ +#ifndef __ASURA_ENGINE_SOUND_H__ +#define __ASURA_ENGINE_SOUND_H__ + +#include "Object.h" + +namespace AsuraEngine +{ + namespace Audio + { + + class Sound : virtual public Object, public Scripting::Portable + { + + }; + + } +} + +#endif
\ No newline at end of file diff --git a/Source/Asura.Engine/Audio/SoundDecoder.h b/Source/Asura.Engine/Audio/SoundDecoder.h new file mode 100644 index 0000000..7b8eb59 --- /dev/null +++ b/Source/Asura.Engine/Audio/SoundDecoder.h @@ -0,0 +1,29 @@ +#ifndef __ASURA_ENGINE_SOUND_DECODER_H__ +#define __ASURA_ENGINE_SOUND_DECODER_H__ + +#include "Sound.h" +#include "FileSystem/DataBuffer.h" + +namespace AsuraEngine +{ + namespace Audio + { + + /// + /// Ƶļ + /// + class SoundDecoder : virtual public Object + { + public: + + SoundDecoder(); + virtual ~SoundDecoder(); + + virtual Sound* Decode(const Filesystem::DataBuffer* db); + + }; + + } +} + +#endif
\ No newline at end of file diff --git a/Source/Asura.Engine/Exceptions/Exception.cpp b/Source/Asura.Engine/Exceptions/Exception.cpp index e69de29..dbb36ca 100644 --- a/Source/Asura.Engine/Exceptions/Exception.cpp +++ b/Source/Asura.Engine/Exceptions/Exception.cpp @@ -0,0 +1,47 @@ +#include "Exception.h" + +#include <cstdarg> +#include <iostream> + +namespace AsuraEngine +{ + + Exception::Exception(const char *fmt, ...) + { + va_list args; + int size_buffer = 256, size_out; + char *buffer; + while (true) + { + buffer = new char[size_buffer]; + memset(buffer, 0, size_buffer); + + va_start(args, fmt); + size_out = vsnprintf(buffer, size_buffer, fmt, args); + va_end(args); + + // see http://perfec.to/vsnprintf/pasprintf.c + // if size_out ... + // == -1 --> output was truncated + // == size_buffer --> output was truncated + // == size_buffer-1 --> ambiguous, /may/ have been truncated + // > size_buffer --> output was truncated, and size_out + // bytes would have been written + if (size_out == size_buffer || size_out == -1 || size_out == size_buffer - 1) + size_buffer *= 2; + else if (size_out > size_buffer) + size_buffer = size_out + 2; // to avoid the ambiguous case + else + break; + + delete[] buffer; + } + message = std::string(buffer); + delete[] buffer; + } + + Exception::~Exception() throw() + { + } + +} diff --git a/Source/Asura.Engine/Exceptions/Exception.h b/Source/Asura.Engine/Exceptions/Exception.h index e69de29..bed8a9a 100644 --- a/Source/Asura.Engine/Exceptions/Exception.h +++ b/Source/Asura.Engine/Exceptions/Exception.h @@ -0,0 +1,43 @@ +#ifndef __ASURA_ENGINE_EXCEPTION_H__ +#define __ASURA_ENGINE_EXCEPTION_H__ + +#include <exception> + +namespace AsuraEngine +{ + + /** + * A convenient vararg-enabled exception class. + **/ + class Exception : public std::exception + { + public: + + /** + * Creates a new Exception according to printf-rules. + * + * See: http://www.cplusplus.com/reference/clibrary/cstdio/printf/ + * + * @param fmt The format string (see printf). + **/ + Exception(const char *fmt, ...); + virtual ~Exception() throw(); + + /** + * Returns a string containing reason for the exception. + * @return A description of the exception. + **/ + inline virtual const char *what() const throw() + { + return message.c_str(); + } + + private: + + std::string message; + + }; // Exception + +} + +#endif
\ No newline at end of file diff --git a/Source/Asura.Engine/FileSystem/DataBuffer.cpp b/Source/Asura.Engine/FileSystem/DataBuffer.cpp new file mode 100644 index 0000000..ec2995a --- /dev/null +++ b/Source/Asura.Engine/FileSystem/DataBuffer.cpp @@ -0,0 +1,14 @@ +#include "DataBuffer.h" + +namespace AsuraEngine +{ + namespace Filesystem + { + + DataBuffer::~DataBuffer() + { + delete[] data; + } + + } +}
\ No newline at end of file diff --git a/Source/Asura.Engine/FileSystem/DataBuffer.h b/Source/Asura.Engine/FileSystem/DataBuffer.h new file mode 100644 index 0000000..f7d8cba --- /dev/null +++ b/Source/Asura.Engine/FileSystem/DataBuffer.h @@ -0,0 +1,39 @@ +#ifndef __ASURA_ENGINE_DATABUFFER_H__ +#define __ASURA_ENGINE_DATABUFFER_H__ + +#include <cstdlib> + +#include "Scripting/Luax.hpp" +#include "Object.h" + +namespace AsuraEngine +{ + namespace Filesystem + { + + /// + /// ڴݵķװеʹData bufferװֱʹconst void*ͨresource managerȡ + /// + class DataBuffer final : virtual public Object, public Scripting::Portable + { + public: + + DataBuffer(const void* data, std::size_t size); + + virtual ~DataBuffer(); + + const void* data; + std::size_t size; + + //---------------------------------------------------------------------------------------------------------- + + LUAX_DECL_FACTORY(DataBuffer); + + //---------------------------------------------------------------------------------------------------------- + + }; + + } +} + +#endif
\ No newline at end of file diff --git a/Source/Asura.Engine/FileSystem/DecodedData.cpp b/Source/Asura.Engine/FileSystem/DecodedData.cpp new file mode 100644 index 0000000..90726cf --- /dev/null +++ b/Source/Asura.Engine/FileSystem/DecodedData.cpp @@ -0,0 +1,19 @@ +#include "DecodedData.h" + +namespace AsuraEngine +{ + namespace Filesystem + { + + DecodedData::DecodedData(const DataBuffer* databuffer) + { + Decode(databuffer); + } + + DecodedData::~DecodedData() + { + + } + + } +} diff --git a/Source/Asura.Engine/FileSystem/DecodedData.h b/Source/Asura.Engine/FileSystem/DecodedData.h new file mode 100644 index 0000000..927052f --- /dev/null +++ b/Source/Asura.Engine/FileSystem/DecodedData.h @@ -0,0 +1,41 @@ +#ifndef __ASURA_ENGINE_DATA_H__ +#define __ASURA_ENGINE_DATA_H__ + +#include <cstdlib> + +#include "DataBuffer.h" +#include "Object.h" + +namespace AsuraEngine +{ + namespace Filesystem + { + + /// + /// һ̹߳data̳дࡣͼƬݡƵݵȣһ߳нԭļڲݸʽ + /// ȡ + /// + class DecodedData : virtual public Object + { + public: + + /// + /// ڴйdataԷһ߳棬Դϵͳء + /// + DecodedData(const DataBuffer* databuffer); + + virtual ~DecodedData(); + + protected: + + /// + /// ڴеݡ + /// + virtual void Decode(const DataBuffer* buffer) = 0; + + }; + + } +} + +#endif
\ No newline at end of file diff --git a/Source/Asura.Engine/FileSystem/File.cpp b/Source/Asura.Engine/FileSystem/ResourceManager.cpp index e69de29..e69de29 100644 --- a/Source/Asura.Engine/FileSystem/File.cpp +++ b/Source/Asura.Engine/FileSystem/ResourceManager.cpp diff --git a/Source/Asura.Engine/FileSystem/ResourceManager.h b/Source/Asura.Engine/FileSystem/ResourceManager.h new file mode 100644 index 0000000..b4aef54 --- /dev/null +++ b/Source/Asura.Engine/FileSystem/ResourceManager.h @@ -0,0 +1,44 @@ +#ifndef __ASURA_ENGINE_RESOURCE_MANAGER_H__ +#define __ASURA_ENGINE_RESOURCE_MANAGER_H__ + +#include <string> + +#include "DataBuffer.h" +#include "Object.h" + +namespace AsuraEngine +{ + namespace Filesystem + { + + /// + /// Դء洢ԴָĿ¼ȡ + /// + class ResourceManager final : virtual public Object + { + public: + + ResourceManager(); + ~ResourceManager(); + + /// + /// װظĿ¼ + /// + void Mount(const std::string& root); + + /// + /// ȡļһdata bufferעҪȷȷڴ棬ڵôʹunique_ptr + /// + DataBuffer* LoadFile(const std::string& path); + + /// + /// data buffer + /// + void SaveFile(const std::string& path, const DataBuffer* buffer); + + }; + + } +} + +#endif
\ No newline at end of file diff --git a/Source/Asura.Engine/Graphics/BlendMode.h b/Source/Asura.Engine/Graphics/BlendMode.h new file mode 100644 index 0000000..775cc45 --- /dev/null +++ b/Source/Asura.Engine/Graphics/BlendMode.h @@ -0,0 +1,17 @@ +#ifndef __ASURA_ENGINE_BLEND_MODE_H__ +#define __ASURA_ENGINE_BLEND_MODE_H__ + +namespace AsuraEngine +{ + namespace Graphics + { + + enum BlendMode + { + + }; + + } +} + +#endif
\ No newline at end of file diff --git a/Source/Asura.Engine/Graphics/Canvas.cpp b/Source/Asura.Engine/Graphics/Canvas.cpp index 8ca6fb2..61787b6 100644 --- a/Source/Asura.Engine/Graphics/Canvas.cpp +++ b/Source/Asura.Engine/Graphics/Canvas.cpp @@ -5,7 +5,37 @@ namespace AsuraEngine namespace Graphics { - + Canvas::Canvas() + : Texture() + , mWidth(0) + , mHeight(0) + { + glGenFramebuffers(1, &mFBO); + GLint current_fbo; + glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, ¤t_fbo); + glBindFramebuffer(GL_FRAMEBUFFER, mFBO); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTextureHandle, 0); + glBindFramebuffer(GL_FRAMEBUFFER, current_fbo); + } + + void Canvas::SetSize(uint w, uint h) + { + GLint current_tex; + glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤t_tex); + glBindTexture(GL_TEXTURE_2D, mTextureHandle); + + glBindTexture(GL_TEXTURE_2D, current_tex); + } + + void Canvas::Bind() + { + + } + + void Canvas::Unbind() + { + + } } }
\ No newline at end of file diff --git a/Source/Asura.Engine/Graphics/Canvas.h b/Source/Asura.Engine/Graphics/Canvas.h index c8faacf..c258793 100644 --- a/Source/Asura.Engine/Graphics/Canvas.h +++ b/Source/Asura.Engine/Graphics/Canvas.h @@ -3,8 +3,8 @@ #include <Scripting/Luax.hpp> +#include "Math/Rect.hpp" #include "GL.h" -#include "SimClass.h" #include "Texture.h" #include "RenderTarget.h" @@ -16,35 +16,34 @@ namespace AsuraEngine /// /// CanvasҲԳΪrender textureҲΪtextureȾ /// - class Canvas final : public Texture, public RenderTarget, public SimClass + class Canvas final : public Drawable, public RenderTarget, public Scripting::Portable { public: Canvas(); - /// - /// render textureĴС - /// - void Init(uint w, uint h); + ~Canvas(); /// - /// canvasΪ + /// render textureĴС /// - void Bind(); + void SetSize(uint w, uint h); /// - /// Ϊǻscreen + /// ȾtexturertϣԭϽǣң /// - void Unbind(); + void Render(const RenderTarget* rt, const Math::Vector2i& pos, const Math::Vector2i& scale, const Math::Vector2i& center, float rot); - void Render(int x, int y, int sx, int sy, int ox, int oy, int r) override; - - void Render(const Math::Rect& quad, int x, int y, int sx, int sy, int ox, int oy, int r) 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); //---------------------------------------------------------------------------------------------------------- LUAX_DECL_FACTORY(SimCanvas); + LUAX_DECL_METHOD(l_SetSize); LUAX_DECL_METHOD(l_Bind); LUAX_DECL_METHOD(l_Unbind); @@ -57,6 +56,11 @@ namespace AsuraEngine /// GLuint mFBO; + /// + /// canvasĴС + /// + uint mWidth, mHeight; + }; /// diff --git a/Source/Asura.Engine/Graphics/Color.h b/Source/Asura.Engine/Graphics/Color.h index 6383602..d8f39a0 100644 --- a/Source/Asura.Engine/Graphics/Color.h +++ b/Source/Asura.Engine/Graphics/Color.h @@ -52,6 +52,12 @@ namespace AsuraEngine { public: + static Color Black; + static Color White; + static Color Red; + static Color Green; + static Color Blue; + Color(); Color(const Color& c); @@ -68,12 +74,9 @@ namespace AsuraEngine LUAX_DECL_FACTORY(Color); - LUAX_DECL_METHOD(l_GetRed); // color.r - LUAX_DECL_METHOD(l_GetGreen); // color.g - LUAX_DECL_METHOD(l_GetBlue); // color.b - LUAX_DECL_METHOD(l_GetAlpha); // color.a + LUAX_DECL_METHOD(l_SetColor); + LUAX_DECL_METHOD(l_GetColor); LUAX_DECL_METHOD(l_Multiply); // ɫ˷ - LUAX_DECL_METHOD(l_NewIndex); // r,g,b,a //---------------------------------------------------------------------------------------------------------- diff --git a/Source/Asura.Engine/Graphics/Image.cpp b/Source/Asura.Engine/Graphics/Image.cpp index e19d57f..8287d76 100644 --- a/Source/Asura.Engine/Graphics/Image.cpp +++ b/Source/Asura.Engine/Graphics/Image.cpp @@ -1,4 +1,5 @@ #include "Image.h" +#include "GL.h" namespace AsuraEngine { @@ -7,30 +8,25 @@ namespace AsuraEngine Image::Image() : Texture() - , mPixels(nullptr) - , mWidth(0) - , mHeight(0) { } Image::~Image() { - delete mPixels; } - bool Image::Load(const void* data, size_t size) + //\Ϣ + bool Image::Load(const ImageData* data) { - - } - - void Image::Render(int x, int y, int sx, int sy, int ox, int oy, int r) - { - - } - - void Image::Render(const Math::Rect& quad, int x, int y, int sx, int sy, int ox, int oy, int r) - { - + if (!data) + return false; + if (mImageData) + delete mImageData; + mImageData = 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; } } diff --git a/Source/Asura.Engine/Graphics/Image.h b/Source/Asura.Engine/Graphics/Image.h index 391d1c4..da881aa 100644 --- a/Source/Asura.Engine/Graphics/Image.h +++ b/Source/Asura.Engine/Graphics/Image.h @@ -1,13 +1,12 @@ #ifndef __ASURA_ENGINE_IMAGE_H__ #define __ASURA_ENGINE_IMAGE_H__ -#include "Math/Vector2.h" #include "StringMap.hpp" #include "Manager.hpp" #include "Texture.h" #include "Color.h" #include "Factory.h" -#include "SimClass.h" +#include "ImageData.h" namespace AsuraEngine { @@ -20,7 +19,7 @@ namespace AsuraEngine /// ImageͼƬڴȡϷĽһImageڴ桢ԴֻᱣһݣҪ /// imageêλãźתǶȣʹspriteһֻࡣҪǿǵeditorengineʹòͬķװ /// - class Image final : public Texture, public SimClass + class Image final : public Drawable, public Scripting::Portable { public: @@ -28,10 +27,10 @@ namespace AsuraEngine ~Image(); /// - /// bufferimagemPixelsΪգݡ¹imageʹglTexImage2Dύimage - /// ݡ + /// bufferimageϢmPixelsΪգݡ¹imageʹglTexImage2Dύimage + /// ݡ /// - bool Load(const void* data, size_t size); + bool Load(const ImageData* data); uint GetWidth(); uint GetHeight(); @@ -39,11 +38,11 @@ namespace AsuraEngine /// /// ijһλõ /// - Color GetPixel(uint x, uint y); + Color32 GetPixel(uint x, uint y); - void Render(int x, int y, int sx, int sy, int ox, int oy, int r) override; + virtual void Render(const RenderTarget* rt, const RenderState& state) override; - void Render(const Math::Rect& quad, int x, int y, int sx, int sy, int ox, int oy, int r) override; + virtual void Render(const RenderTarget* rt, const Math::Rectf& quad, const RenderState& state) override; //---------------------------------------------------------------------------------------------------------- @@ -58,12 +57,7 @@ namespace AsuraEngine private: - /// - /// СΪλ - /// - uint mWidth, mHeight; - - Color* mPixels; + const ImageData* mImageData; }; diff --git a/Source/Asura.Engine/Graphics/ImageData.cpp b/Source/Asura.Engine/Graphics/ImageData.cpp new file mode 100644 index 0000000..af448bd --- /dev/null +++ b/Source/Asura.Engine/Graphics/ImageData.cpp @@ -0,0 +1,56 @@ +#include "ImageData.h" +#include "PNGDecoder.h" +#include "STBDecoder.h" + +namespace AsuraEngine +{ + namespace Graphics + { + + using namespace std; + + // imagedecoderΪԡ + list<ImageDecoder*> ImageData::ImageDecoders = { + new PNGDecoder(), // png + new STBDecoder() // jpeg, tga, bmp + }; + + void ImageData::ReleaseAllDecoders() + { + for (ImageDecoder* decoder : ImageDecoders) + decoder->Release(); + } + + ImageData::ImageData(const Filesystem::DataBuffer* buffer) + : DecodedData(buffer) + { + } + + ImageData::~ImageData() + { + if (pixels) + delete[] pixels; + } + + /// + /// ɹ׳쳣 + /// + void ImageData::Decode(const Filesystem::DataBuffer* buffer) + { + for (ImageDecoder* decoder : ImageDecoders) + { + if (decoder->CanDecode(buffer)) + { + decoder->Decode(buffer, this); + return; + } + } + } + + Color ImageData::GetPixel(uint x, uint y) + { + + } + + } +}
\ No newline at end of file diff --git a/Source/Asura.Engine/Graphics/ImageData.h b/Source/Asura.Engine/Graphics/ImageData.h new file mode 100644 index 0000000..925a5a0 --- /dev/null +++ b/Source/Asura.Engine/Graphics/ImageData.h @@ -0,0 +1,58 @@ +#ifndef __ASURA_ENGINE_IMAGEDATA_H__ +#define __ASURA_ENGINE_IMAGEDATA_H__ + +#include <list> + +#include "Scripting/Luax.hpp" +#include "Filesystem/DecodedData.h" +#include "ImageDecoder.h" +#include "PixelFormat.h" +#include "Color.h" + +namespace AsuraEngine +{ + namespace Graphics + { + + class ImageData final : public Filesystem::DecodedData, public Scripting::Portable + { + public: + + /// + /// ͼƬļϢʧܣ׳쳣 + /// + ImageData(const Filesystem::DataBuffer* buffer); + ~ImageData(); + + Color GetPixel(uint x, uint y); + + 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; + + /// + /// ڵһimage dataʱṩdecoderڼdecodersмѡԡ + /// + static std::list<ImageDecoder*> ImageDecoders; + + }; + + } +} + +#endif
\ No newline at end of file diff --git a/Source/Asura.Engine/Graphics/ImageDecoder.h b/Source/Asura.Engine/Graphics/ImageDecoder.h new file mode 100644 index 0000000..9dc2188 --- /dev/null +++ b/Source/Asura.Engine/Graphics/ImageDecoder.h @@ -0,0 +1,35 @@ +#ifndef __ASURA_ENGINE_IMAGE_DECODER_H__ +#define __ASURA_ENGINE_IMAGE_DECODER_H__ + +#include "FileSystem/DataBuffer.h" + +#include "ImageData.h" + +namespace AsuraEngine +{ + namespace Graphics + { + + class ImageDecoder : virtual public Object + { + public: + + ImageDecoder(); + virtual ~ImageDecoder(); + + /// + /// жڴǷñdecoderѹ + /// + virtual bool CanDecode(const Filesystem::DataBuffer* buffer) = 0; + + /// + /// һڴ棬һѹImage dataѹʧܷnullptr + /// + virtual void Decode(const Filesystem::DataBuffer* buffer, ImageData* data) = 0; + + }; + + } +} + +#endif
\ No newline at end of file diff --git a/Source/Asura.Engine/Graphics/Mesh2D.h b/Source/Asura.Engine/Graphics/Mesh2D.h index 921ae80..cadbec1 100644 --- a/Source/Asura.Engine/Graphics/Mesh2D.h +++ b/Source/Asura.Engine/Graphics/Mesh2D.h @@ -1,8 +1,9 @@ #ifndef __ASURA_ENGINE_MESH2D_H__ #define __ASURA_ENGINE_MESH2D_H__ +#include "Scripting/Luax.hpp" + #include "Object.h" -#include "SimClass.h" namespace AsuraEngine { @@ -12,7 +13,7 @@ namespace AsuraEngine /// /// 2D meshһЩ㶯 /// - class Mesh2D : virtual public Object, public SimClass + class Mesh2D : virtual public Object, public Scripting::Portable { }; diff --git a/Source/Asura.Engine/Graphics/PNGDecoder.cpp b/Source/Asura.Engine/Graphics/PNGDecoder.cpp new file mode 100644 index 0000000..363d478 --- /dev/null +++ b/Source/Asura.Engine/Graphics/PNGDecoder.cpp @@ -0,0 +1,19 @@ +#include "PNGDecoder.h" + +namespace AsuraEngine +{ + namespace Graphics + { + + bool PNGDecoder::CanDecode(const Filesystem::DataBuffer* buffer) + { + return false; + } + + 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 new file mode 100644 index 0000000..dc5bb60 --- /dev/null +++ b/Source/Asura.Engine/Graphics/PNGDecoder.h @@ -0,0 +1,27 @@ +#ifndef __ASURA_ENGINE_PNGDECODER_H__ +#define __ASURA_ENGINE_PNGDECODER_H__ + +#include "ImageDecoder.h" + +namespace AsuraEngine +{ + namespace Graphics + { + + /// + /// ʹlodepngѹpngļ + /// + class PNGDecoder final : public ImageDecoder + { + public: + + bool CanDecode(const Filesystem::DataBuffer* buffer) override; + + void Decode(const Filesystem::DataBuffer* buffer, ImageData* data) override; + + }; + + } +} + +#endif
\ No newline at end of file diff --git a/Source/Asura.Engine/Graphics/PixelFormat.h b/Source/Asura.Engine/Graphics/PixelFormat.h new file mode 100644 index 0000000..8df07d5 --- /dev/null +++ b/Source/Asura.Engine/Graphics/PixelFormat.h @@ -0,0 +1,91 @@ +namespace AsuraEngine +{ + namespace Graphics + { + + /// + /// ظʽ + /// + enum PixelFormat + { + PIXELFORMAT_UNKNOWN, + + // these are converted to an actual format by love + PIXELFORMAT_NORMAL, + PIXELFORMAT_HDR, + + // "regular" formats + PIXELFORMAT_R8, + PIXELFORMAT_RG8, + PIXELFORMAT_RGBA8, + PIXELFORMAT_sRGBA8, + PIXELFORMAT_R16, + PIXELFORMAT_RG16, + PIXELFORMAT_RGBA16, + PIXELFORMAT_R16F, + PIXELFORMAT_RG16F, + PIXELFORMAT_RGBA16F, + PIXELFORMAT_R32F, + PIXELFORMAT_RG32F, + PIXELFORMAT_RGBA32F, + + PIXELFORMAT_LA8, // Same as RG8, but accessed as (L, L, L, A) + + // packed formats + PIXELFORMAT_RGBA4, + PIXELFORMAT_RGB5A1, + PIXELFORMAT_RGB565, + PIXELFORMAT_RGB10A2, + PIXELFORMAT_RG11B10F, + + // depth/stencil formats + PIXELFORMAT_STENCIL8, + PIXELFORMAT_DEPTH16, + PIXELFORMAT_DEPTH24, + PIXELFORMAT_DEPTH32F, + PIXELFORMAT_DEPTH24_STENCIL8, + PIXELFORMAT_DEPTH32F_STENCIL8, + + // compressed formats + PIXELFORMAT_DXT1, + PIXELFORMAT_DXT3, + PIXELFORMAT_DXT5, + PIXELFORMAT_BC4, + PIXELFORMAT_BC4s, + PIXELFORMAT_BC5, + PIXELFORMAT_BC5s, + PIXELFORMAT_BC6H, + PIXELFORMAT_BC6Hs, + PIXELFORMAT_BC7, + PIXELFORMAT_PVR1_RGB2, + PIXELFORMAT_PVR1_RGB4, + PIXELFORMAT_PVR1_RGBA2, + PIXELFORMAT_PVR1_RGBA4, + PIXELFORMAT_ETC1, + PIXELFORMAT_ETC2_RGB, + PIXELFORMAT_ETC2_RGBA, + PIXELFORMAT_ETC2_RGBA1, + PIXELFORMAT_EAC_R, + PIXELFORMAT_EAC_Rs, + PIXELFORMAT_EAC_RG, + PIXELFORMAT_EAC_RGs, + PIXELFORMAT_ASTC_4x4, + PIXELFORMAT_ASTC_5x4, + PIXELFORMAT_ASTC_5x5, + PIXELFORMAT_ASTC_6x5, + PIXELFORMAT_ASTC_6x6, + PIXELFORMAT_ASTC_8x5, + PIXELFORMAT_ASTC_8x6, + PIXELFORMAT_ASTC_8x8, + PIXELFORMAT_ASTC_10x5, + PIXELFORMAT_ASTC_10x6, + PIXELFORMAT_ASTC_10x8, + PIXELFORMAT_ASTC_10x10, + PIXELFORMAT_ASTC_12x10, + PIXELFORMAT_ASTC_12x12, + + PIXELFORMAT_MAX_ENUM + }; + + } +} diff --git a/Source/Asura.Engine/Math/Rect.cpp b/Source/Asura.Engine/Graphics/Port/ImageData.cpp index e69de29..e69de29 100644 --- a/Source/Asura.Engine/Math/Rect.cpp +++ b/Source/Asura.Engine/Graphics/Port/ImageData.cpp diff --git a/Source/Asura.Engine/Math/Vector2.cpp b/Source/Asura.Engine/Graphics/Port/Mesh2DData.cpp index e69de29..e69de29 100644 --- a/Source/Asura.Engine/Math/Vector2.cpp +++ b/Source/Asura.Engine/Graphics/Port/Mesh2DData.cpp diff --git a/Source/Asura.Engine/Graphics/Port/Shader.cpp b/Source/Asura.Engine/Graphics/Port/Shader.cpp index 887cfae..2253a56 100644 --- a/Source/Asura.Engine/Graphics/Port/Shader.cpp +++ b/Source/Asura.Engine/Graphics/Port/Shader.cpp @@ -12,7 +12,7 @@ namespace AsuraEngine /// int Shader::l_Use(lua_State* L) { - LuaxState state = LuaxState(L); + LuaxState state(L); } @@ -21,7 +21,7 @@ namespace AsuraEngine /// int Shader::l_Unuse(lua_State* L) { - LuaxState state = LuaxState(L); + LuaxState state(L); } @@ -30,7 +30,7 @@ namespace AsuraEngine /// int Shader::l_Load(lua_State* L) { - LuaxState state = LuaxState(L); + LuaxState state(L); } @@ -39,7 +39,7 @@ namespace AsuraEngine /// int Shader::l_HasUniform(lua_State* L) { - LuaxState state = LuaxState(L); + LuaxState state(L); } @@ -48,56 +48,56 @@ namespace AsuraEngine /// int Shader::l_GetUniformLocation(lua_State* L) { - LuaxState state = LuaxState(L); + LuaxState state(L); } int Shader::l_SetBuiltInUniforms(lua_State* L) { - LuaxState state = LuaxState(L); + LuaxState state(L); } int Shader::l_SetUniformFloat(lua_State* L) { - LuaxState state = LuaxState(L); + LuaxState state(L); } int Shader::l_SetUniformTexture(lua_State* L) { - LuaxState state = LuaxState(L); + LuaxState state(L); } int Shader::l_SetUniformVector2(lua_State* L) { - LuaxState state = LuaxState(L); + LuaxState state(L); } int Shader::l_SetUniformVector3(lua_State* L) { - LuaxState state = LuaxState(L); + LuaxState state(L); } int Shader::l_SetUniformVector4(lua_State* L) { - LuaxState state = LuaxState(L); + LuaxState state(L); } int Shader::l_SetUniformColor(lua_State* L) { - LuaxState state = LuaxState(L); + LuaxState state(L); } //עluaijԱ int Shader::RegisterLuaClass(lua_State* L) { - LuaxState state = LuaxState(L); + LuaxState state(L); } diff --git a/Source/Asura.Engine/Graphics/RenderState.h b/Source/Asura.Engine/Graphics/RenderState.h new file mode 100644 index 0000000..9524ef6 --- /dev/null +++ b/Source/Asura.Engine/Graphics/RenderState.h @@ -0,0 +1,52 @@ +#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 "Shader.h" +#include "BlendMode.h" + +namespace AsuraEngine +{ + namespace Graphics + { + + /// + /// Ⱦǰķʽ + /// + class RenderState final : virtual public Object + { + public: + + /// + /// Ĭϵrender state + /// + static RenderState Default; + + RenderState(); + ~RenderState(); + + /// + /// λášλúת + /// + + Math::Transform transform; + + /// + /// ɫ + /// + Shader* shader; + + /// + /// Ϸʽ + /// + BlendMode blendMode; + + }; + + } +} + +#endif
\ No newline at end of file diff --git a/Source/Asura.Engine/Graphics/RenderTarget.h b/Source/Asura.Engine/Graphics/RenderTarget.h index 05d7068..afa8967 100644 --- a/Source/Asura.Engine/Graphics/RenderTarget.h +++ b/Source/Asura.Engine/Graphics/RenderTarget.h @@ -1,20 +1,24 @@ #ifndef __ASURA_ENGINE_RENDERTARGET_H__ #define __ASURA_ENGINE_RENDERTARGET_H__ +#include "Math/Rect.hpp" #include "Texture.h" #include "Object.h" +#include "Color.h" namespace AsuraEngine { namespace Graphics { + class Drawable; + /// /// ɱΪȾĿ࣬ /// Canvas(RenderTexture) /// Window(RenderWindow) /// - class RenderTarget : virtual public Object + class RenderTarget : virtual public Object { public: @@ -22,6 +26,26 @@ namespace AsuraEngine virtual ~RenderTarget() {}; + /// + /// ɫcolRT + /// + virtual void Clear(const Color& col = Color::Black) = 0; + + /// + /// ɫcolղRT + /// + virtual void Clear(const Math::Recti& quad, const Color& col = Color::Black) = 0; + + /// + /// textureRT + /// + virtual void Draw(const Drawable* texture, const RenderState& state) = 0; + + /// + /// һtextureRT + /// + virtual void Draw(const Drawable* texture, const Math::Recti& quad, const RenderState& state) = 0; + }; } diff --git a/Source/Asura.Engine/Graphics/STBDecoder.cpp b/Source/Asura.Engine/Graphics/STBDecoder.cpp new file mode 100644 index 0000000..d4d578f --- /dev/null +++ b/Source/Asura.Engine/Graphics/STBDecoder.cpp @@ -0,0 +1,69 @@ +#include "STBDecoder.h" + +#include "Exceptions/Exception.h" +#include "stb/stb_image.h" + +namespace AsuraEngine +{ + namespace Graphics + { + + 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); + + return status == 1 && w > 0 && h > 0; + } + + 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; + int width, height; + int comp = 0; + byte* data = nullptr; + PixelFormat format = PIXELFORMAT_UNKNOWN; + std::size_t size = 0; + + if (stbi_is_hdr_from_memory(buffer, bufferlen)) + { + // 4channelfloat + data = (byte*)stbi_loadf_from_memory(buffer, bufferlen, &width, &height, &comp, STBI_rgb_alpha); + format = PIXELFORMAT_RGBA32F; + size = width * height * 4 * sizeof(float); + } + else + { + data = (byte*)stbi_load_from_memory(buffer, bufferlen, &width, &height, &comp, STBI_rgb_alpha); + format = PIXELFORMAT_ASTC_8x5; + size = width * height * 4; + } + if (data) + { + // ֤ڴ汻ͷţһϲûͷŵΪimage dataһԵģimageǶεġ + if (imageData->pixels) + delete[] imageData->pixels; + imageData->pixels = (byte*)data; + imageData->format = format; + imageData->width = width; + imageData->height = height; + } + else + { + const char *err = stbi_failure_reason(); + if (err == nullptr) + err = "unknown error"; + throw Exception("Could not decode image with stb_image (%s).", err); + } + } + + } +}
\ No newline at end of file diff --git a/Source/Asura.Engine/Graphics/STBDecoder.h b/Source/Asura.Engine/Graphics/STBDecoder.h new file mode 100644 index 0000000..d89042e --- /dev/null +++ b/Source/Asura.Engine/Graphics/STBDecoder.h @@ -0,0 +1,27 @@ +#ifndef __ASURA_ENGINE_STBDECODER_H__ +#define __ASURA_ENGINE_STBDECODER_H__ + +#include "ImageDecoder.h" + +namespace AsuraEngine +{ + namespace Graphics + { + + /// + /// ʹstb_imageѹJPEGTGABMPļ + /// + class STBDecoder final : public ImageDecoder + { + public: + + bool CanDecode(const Filesystem::DataBuffer* buffer) override; + + void Decode(const Filesystem::DataBuffer* buffer, ImageData* data) override; + + }; + + } +} + +#endif
\ No newline at end of file diff --git a/Source/Asura.Engine/Graphics/Shader.cpp b/Source/Asura.Engine/Graphics/Shader.cpp index 6cf65e0..1a85866 100644 --- a/Source/Asura.Engine/Graphics/Shader.cpp +++ b/Source/Asura.Engine/Graphics/Shader.cpp @@ -55,17 +55,17 @@ namespace AsuraEngine } - void Shader::SetUniformVector2(uint loc, const Math::Vector2& vec2) + void Shader::SetUniformVector2(uint loc, const Math::Vector2f& vec2) { } - void Shader::SetUniformVector3(uint loc, const Math::Vector3& vec3) + void Shader::SetUniformVector3(uint loc, const Math::Vector3f& vec3) { } - void Shader::SetUniformVector4(uint loc, const Math::Vector4& vec4) + void Shader::SetUniformVector4(uint loc, const Math::Vector4f& vec4) { } diff --git a/Source/Asura.Engine/Graphics/Shader.h b/Source/Asura.Engine/Graphics/Shader.h index 2cc482b..831f5c3 100644 --- a/Source/Asura.Engine/Graphics/Shader.h +++ b/Source/Asura.Engine/Graphics/Shader.h @@ -5,8 +5,8 @@ #include <string> #include "Scripting/Luax.hpp" -#include "Math/Vector2.h" -#include "Math/Vector3.h" +#include "Math/Vector2.hpp" +#include "Math/Vector3.hpp" #include "Math/Vector4.h" #include "Math/Matrix44.h" #include "StringMap.hpp" @@ -15,7 +15,6 @@ #include "Manager.hpp" #include "Texture.h" #include "GL.h" -#include "SimClass.h" namespace AsuraEngine { @@ -26,7 +25,7 @@ namespace AsuraEngine /// һshaderһڲʼ乲ijShaderuniformsͶݣֻṩuniformsuseɫķ༭ /// ÿshaderͨshaderҵuniforms¶frameworkmaterialá /// - class Shader final : virtual public Object, public SimClass + class Shader final : virtual public Object { public: @@ -54,9 +53,9 @@ namespace AsuraEngine /// void SetUniformFloat(uint loc, float value); void SetUniformTexture(uint loc, const Texture& texture); - void SetUniformVector2(uint loc, const Math::Vector2& vec2); - void SetUniformVector3(uint loc, const Math::Vector3& vec3); - void SetUniformVector4(uint loc, const Math::Vector4& vec4); + void SetUniformVector2(uint loc, const Math::Vector2f& vec2); + void SetUniformVector3(uint loc, const Math::Vector3f& vec3); + void SetUniformVector4(uint loc, const Math::Vector4f& vec4); void SetUniformColor(uint loc, const Color& color); void SetUniformMatrix44(uint loc, const Math::Matrix44& mat44); diff --git a/Source/Asura.Engine/Graphics/Texture.h b/Source/Asura.Engine/Graphics/Texture.h index e5b713c..c1411fc 100644 --- a/Source/Asura.Engine/Graphics/Texture.h +++ b/Source/Asura.Engine/Graphics/Texture.h @@ -1,9 +1,10 @@ #ifndef __ASURA_ENGINE_TEXTURE_H__ #define __ASURA_ENGINE_TEXTURE_H__ -#include "Math/Rect.h" +#include "Math/Rect.hpp" +#include "Math/Vector2.hpp" #include "Scripting/Luax.hpp" -#include "Object.h" +#include "RenderState.h" #include "GL.h" namespace AsuraEngine @@ -11,6 +12,8 @@ namespace AsuraEngine namespace Graphics { + class RenderTarget; + /// /// 2D࣬2d meshrender targetбʹáTextureȾԭϽǣϷϲԵѿϵΪ /// EditorҲϽΪԭ㣬Ϊ˷㡣 @@ -28,12 +31,22 @@ namespace AsuraEngine /// /// ȾtexturertϣԭϽǣң /// - virtual void Render(int x, int y, int sx, int sy, int ox, int oy, int r) = 0; + virtual void Render(const RenderTarget* rt, const RenderState& state) = 0; /// /// ȾtextureһֵrtϣԭϽǣң졣 /// - virtual void Render(const Math::Rect& quad, int x, int y, int sx, int sy, int ox, int oy, int r) = 0; + virtual void Render(const RenderTarget* rt, const Math::Rectf& quad, const RenderState& state) = 0; + + /// + /// ù˷ʽ + /// + void SetSmooth(bool smooth); + + /// + /// ظʽ + /// + void SetRepeated(); protected: @@ -44,7 +57,7 @@ namespace AsuraEngine }; - using Renderable = Texture; + using Drawable = Texture; } } diff --git a/Source/Asura.Engine/Math/Rect.h b/Source/Asura.Engine/Math/Rect.h deleted file mode 100644 index 5dd8631..0000000 --- a/Source/Asura.Engine/Math/Rect.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef __ASURA_ENGINE_RECT_H__ -#define __ASURA_ENGINE_RECT_H__ - -namespace AsuraEngine -{ - namespace Math - { - - struct Rect - { - int x, y, w, h; - }; - - } -} - -#endif
\ No newline at end of file diff --git a/Source/Asura.Engine/Math/Rect.hpp b/Source/Asura.Engine/Math/Rect.hpp new file mode 100644 index 0000000..f635007 --- /dev/null +++ b/Source/Asura.Engine/Math/Rect.hpp @@ -0,0 +1,32 @@ +#ifndef __ASURA_ENGINE_RECT_H__ +#define __ASURA_ENGINE_RECT_H__ + +namespace AsuraEngine +{ + namespace Math + { + + template<typename T> + struct Rect + { + public: + Rect(); + ~Rect(T x, T y, T w, T h); + + template <typename U> + explicit Rect(const Rect<U>& rect); + + T x, y, w, h; + }; + +#include "Rect.inl" + + // Define the most common types + typedef Rect<int> Recti; + typedef Rect<unsigned int> Rectu; + typedef Rect<float> Rectf; + + } +} + +#endif
\ No newline at end of file diff --git a/Source/Asura.Engine/Math/Rect.inl b/Source/Asura.Engine/Math/Rect.inl new file mode 100644 index 0000000..891a3f8 --- /dev/null +++ b/Source/Asura.Engine/Math/Rect.inl @@ -0,0 +1,19 @@ +template <typename T> +inline Rect<T>::Rect() + : x(0) + , y(0) + , w(0) + , h(0) +{ + +} + +template <typename T> +inline Rect<T>::Rect(T X, T Y, T W, T H) + : x(X) + , y(Y) + , w(W) + , h(H) +{ + +} diff --git a/Source/Asura.Engine/Math/Vector3.cpp b/Source/Asura.Engine/Math/Transform.cpp index e69de29..e69de29 100644 --- a/Source/Asura.Engine/Math/Vector3.cpp +++ b/Source/Asura.Engine/Math/Transform.cpp diff --git a/Source/Asura.Engine/Math/Transform.h b/Source/Asura.Engine/Math/Transform.h new file mode 100644 index 0000000..aafb66c --- /dev/null +++ b/Source/Asura.Engine/Math/Transform.h @@ -0,0 +1,30 @@ +#ifndef __ASURA_ENGINE_TRANSFORM_H__ +#define __ASURA_ENGINE_TRANSFORM_H__ + +#include "Object.h" + +namespace AsuraEngine +{ + namespace Math + { + + class Transform : virtual public Object + { + public: + + void Set(float x, float y, float sx, float sy, float ox, float oy, float r); + + void LoadIdentity(); + + void Move(float dx = 0, float dy = 0); + void Rotate(float r); + void Scale(float sx, float sy); + + float m[16]; //4x4 matrix + + }; + + } +} + +#endif
\ No newline at end of file diff --git a/Source/Asura.Engine/Math/Vector2.h b/Source/Asura.Engine/Math/Vector2.h deleted file mode 100644 index 875cef3..0000000 --- a/Source/Asura.Engine/Math/Vector2.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef __ASURA_ENGINE_VECTOR2_H__ -#define __ASURA_ENGINE_VECTOR2_H__ - -namespace AsuraEngine -{ - namespace Math - { - - class Vector2 - { - - }; - - } -} - -#endif
\ No newline at end of file diff --git a/Source/Asura.Engine/Math/Vector2.hpp b/Source/Asura.Engine/Math/Vector2.hpp new file mode 100644 index 0000000..df78255 --- /dev/null +++ b/Source/Asura.Engine/Math/Vector2.hpp @@ -0,0 +1,70 @@ +#ifndef __ASURA_ENGINE_VECTOR2_H__ +#define __ASURA_ENGINE_VECTOR2_H__ + +namespace AsuraEngine +{ + namespace Math + { + template <typename T> + class Vector2 + { + public: + Vector2(); + Vector2(T X, T Y); + + template <typename U> + explicit Vector2(const Vector2<U>& vector); + + Set(T X, T Y); + + T x; ///< X coordinate of the vector + T y; ///< Y coordinate of the vector + }; + + template <typename T> + Vector2<T> operator -(const Vector2<T>& right); + + template <typename T> + Vector2<T>& operator +=(Vector2<T>& left, const Vector2<T>& right); + + template <typename T> + Vector2<T>& operator -=(Vector2<T>& left, const Vector2<T>& right); + + template <typename T> + Vector2<T> operator +(const Vector2<T>& left, const Vector2<T>& right); + + template <typename T> + Vector2<T> operator -(const Vector2<T>& left, const Vector2<T>& right); + + template <typename T> + Vector2<T> operator *(const Vector2<T>& left, T right); + + template <typename T> + Vector2<T> operator *(T left, const Vector2<T>& right); + + template <typename T> + Vector2<T>& operator *=(Vector2<T>& left, T right); + + template <typename T> + Vector2<T> operator /(const Vector2<T>& left, T right); + + template <typename T> + Vector2<T>& operator /=(Vector2<T>& left, T right); + + template <typename T> + bool operator ==(const Vector2<T>& left, const Vector2<T>& right); + + template <typename T> + bool operator !=(const Vector2<T>& left, const Vector2<T>& right); + +#include "Vector2.inl" + + // Define the most common types + typedef Vector2<int> Vector2i; + typedef Vector2<unsigned int> Vector2u; + typedef Vector2<float> Vector2f; + + } +} + +#endif
\ No newline at end of file diff --git a/Source/Asura.Engine/Math/Vector2.inl b/Source/Asura.Engine/Math/Vector2.inl new file mode 100644 index 0000000..9e131a7 --- /dev/null +++ b/Source/Asura.Engine/Math/Vector2.inl @@ -0,0 +1,114 @@ +template <typename T> +inline Vector2<T>::Vector2() : + x(0), + y(0) +{ + +} + +template <typename T> +inline Vector2<T>::Vector2(T X, T Y) : + x(X), + y(Y) +{ + +} + +template <typename T> +template <typename U> +inline Vector2<T>::Vector2(const Vector2<U>& vector) : + x(static_cast<T>(vector.x)), + y(static_cast<T>(vector.y)) +{ +} + +template <typename T> +inline Vector2<T>::Set(T X, T Y) +{ + x = X; + y = Y; +} + +template <typename T> +inline Vector2<T> operator -(const Vector2<T>& right) +{ + return Vector2<T>(-right.x, -right.y); +} + +template <typename T> +inline Vector2<T>& operator +=(Vector2<T>& left, const Vector2<T>& right) +{ + left.x += right.x; + left.y += right.y; + + return left; +} + +template <typename T> +inline Vector2<T>& operator -=(Vector2<T>& left, const Vector2<T>& right) +{ + left.x -= right.x; + left.y -= right.y; + + return left; +} + +template <typename T> +inline Vector2<T> operator +(const Vector2<T>& left, const Vector2<T>& right) +{ + return Vector2<T>(left.x + right.x, left.y + right.y); +} + +template <typename T> +inline Vector2<T> operator -(const Vector2<T>& left, const Vector2<T>& right) +{ + return Vector2<T>(left.x - right.x, left.y - right.y); +} + +template <typename T> +inline Vector2<T> operator *(const Vector2<T>& left, T right) +{ + return Vector2<T>(left.x * right, left.y * right); +} + +template <typename T> +inline Vector2<T> operator *(T left, const Vector2<T>& right) +{ + return Vector2<T>(right.x * left, right.y * left); +} + +template <typename T> +inline Vector2<T>& operator *=(Vector2<T>& left, T right) +{ + left.x *= right; + left.y *= right; + + return left; +} + +template <typename T> +inline Vector2<T> operator /(const Vector2<T>& left, T right) +{ + return Vector2<T>(left.x / right, left.y / right); +} + +template <typename T> +inline Vector2<T>& operator /=(Vector2<T>& left, T right) +{ + left.x /= right; + left.y /= right; + + return left; +} + +template <typename T> +inline bool operator ==(const Vector2<T>& left, const Vector2<T>& right) +{ + return (left.x == right.x) && (left.y == right.y); +} + +template <typename T> +inline bool operator !=(const Vector2<T>& left, const Vector2<T>& right) +{ + return (left.x != right.x) || (left.y != right.y); +} diff --git a/Source/Asura.Engine/Math/Vector3.h b/Source/Asura.Engine/Math/Vector3.h deleted file mode 100644 index f0e48e4..0000000 --- a/Source/Asura.Engine/Math/Vector3.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef __ASURA_ENGINE_VECTOR3_H__ -#define __ASURA_ENGINE_VECTOR3_H__ - -namespace AsuraEngine -{ - namespace Math - { - - class Vector3 - { - - }; - - } -} - -#endif
\ No newline at end of file diff --git a/Source/Asura.Engine/Math/Vector3.hpp b/Source/Asura.Engine/Math/Vector3.hpp new file mode 100644 index 0000000..2b23406 --- /dev/null +++ b/Source/Asura.Engine/Math/Vector3.hpp @@ -0,0 +1,233 @@ +#ifndef __ASURA_ENGINE_VECTOR3_H__ +#define __ASURA_ENGINE_VECTOR3_H__ + +namespace AsuraEngine +{ + namespace Math + { + template <typename T> + class Vector3 + { + public: + + //////////////////////////////////////////////////////////// + /// \brief Default constructor + /// + /// Creates a Vector3(0, 0, 0). + /// + //////////////////////////////////////////////////////////// + Vector3(); + + //////////////////////////////////////////////////////////// + /// \brief Construct the vector from its coordinates + /// + /// \param X X coordinate + /// \param Y Y coordinate + /// \param Z Z coordinate + /// + //////////////////////////////////////////////////////////// + Vector3(T X, T Y, T Z); + + //////////////////////////////////////////////////////////// + /// \brief Construct the vector from another type of vector + /// + /// This constructor doesn't replace the copy constructor, + /// it's called only when U != T. + /// A call to this constructor will fail to compile if U + /// is not convertible to T. + /// + /// \param vector Vector to convert + /// + //////////////////////////////////////////////////////////// + template <typename U> + explicit Vector3(const Vector3<U>& vector); + + //////////////////////////////////////////////////////////// + // Member data + //////////////////////////////////////////////////////////// + T x; ///< X coordinate of the vector + T y; ///< Y coordinate of the vector + T z; ///< Z coordinate of the vector + }; + + //////////////////////////////////////////////////////////// + /// \relates Vector3 + /// \brief Overload of unary operator - + /// + /// \param left Vector to negate + /// + /// \return Memberwise opposite of the vector + /// + //////////////////////////////////////////////////////////// + template <typename T> + Vector3<T> operator -(const Vector3<T>& left); + + //////////////////////////////////////////////////////////// + /// \relates Vector3 + /// \brief Overload of binary operator += + /// + /// This operator performs a memberwise addition of both vectors, + /// and assigns the result to \a left. + /// + /// \param left Left operand (a vector) + /// \param right Right operand (a vector) + /// + /// \return Reference to \a left + /// + //////////////////////////////////////////////////////////// + template <typename T> + Vector3<T>& operator +=(Vector3<T>& left, const Vector3<T>& right); + + //////////////////////////////////////////////////////////// + /// \relates Vector3 + /// \brief Overload of binary operator -= + /// + /// This operator performs a memberwise subtraction of both vectors, + /// and assigns the result to \a left. + /// + /// \param left Left operand (a vector) + /// \param right Right operand (a vector) + /// + /// \return Reference to \a left + /// + //////////////////////////////////////////////////////////// + template <typename T> + Vector3<T>& operator -=(Vector3<T>& left, const Vector3<T>& right); + + //////////////////////////////////////////////////////////// + /// \relates Vector3 + /// \brief Overload of binary operator + + /// + /// \param left Left operand (a vector) + /// \param right Right operand (a vector) + /// + /// \return Memberwise addition of both vectors + /// + //////////////////////////////////////////////////////////// + template <typename T> + Vector3<T> operator +(const Vector3<T>& left, const Vector3<T>& right); + + //////////////////////////////////////////////////////////// + /// \relates Vector3 + /// \brief Overload of binary operator - + /// + /// \param left Left operand (a vector) + /// \param right Right operand (a vector) + /// + /// \return Memberwise subtraction of both vectors + /// + //////////////////////////////////////////////////////////// + template <typename T> + Vector3<T> operator -(const Vector3<T>& left, const Vector3<T>& right); + + //////////////////////////////////////////////////////////// + /// \relates Vector3 + /// \brief Overload of binary operator * + /// + /// \param left Left operand (a vector) + /// \param right Right operand (a scalar value) + /// + /// \return Memberwise multiplication by \a right + /// + //////////////////////////////////////////////////////////// + template <typename T> + Vector3<T> operator *(const Vector3<T>& left, T right); + + //////////////////////////////////////////////////////////// + /// \relates Vector3 + /// \brief Overload of binary operator * + /// + /// \param left Left operand (a scalar value) + /// \param right Right operand (a vector) + /// + /// \return Memberwise multiplication by \a left + /// + //////////////////////////////////////////////////////////// + template <typename T> + Vector3<T> operator *(T left, const Vector3<T>& right); + + //////////////////////////////////////////////////////////// + /// \relates Vector3 + /// \brief Overload of binary operator *= + /// + /// This operator performs a memberwise multiplication by \a right, + /// and assigns the result to \a left. + /// + /// \param left Left operand (a vector) + /// \param right Right operand (a scalar value) + /// + /// \return Reference to \a left + /// + //////////////////////////////////////////////////////////// + template <typename T> + Vector3<T>& operator *=(Vector3<T>& left, T right); + + //////////////////////////////////////////////////////////// + /// \relates Vector3 + /// \brief Overload of binary operator / + /// + /// \param left Left operand (a vector) + /// \param right Right operand (a scalar value) + /// + /// \return Memberwise division by \a right + /// + //////////////////////////////////////////////////////////// + template <typename T> + Vector3<T> operator /(const Vector3<T>& left, T right); + + //////////////////////////////////////////////////////////// + /// \relates Vector3 + /// \brief Overload of binary operator /= + /// + /// This operator performs a memberwise division by \a right, + /// and assigns the result to \a left. + /// + /// \param left Left operand (a vector) + /// \param right Right operand (a scalar value) + /// + /// \return Reference to \a left + /// + //////////////////////////////////////////////////////////// + template <typename T> + Vector3<T>& operator /=(Vector3<T>& left, T right); + + //////////////////////////////////////////////////////////// + /// \relates Vector3 + /// \brief Overload of binary operator == + /// + /// This operator compares strict equality between two vectors. + /// + /// \param left Left operand (a vector) + /// \param right Right operand (a vector) + /// + /// \return True if \a left is equal to \a right + /// + //////////////////////////////////////////////////////////// + template <typename T> + bool operator ==(const Vector3<T>& left, const Vector3<T>& right); + + //////////////////////////////////////////////////////////// + /// \relates Vector3 + /// \brief Overload of binary operator != + /// + /// This operator compares strict difference between two vectors. + /// + /// \param left Left operand (a vector) + /// \param right Right operand (a vector) + /// + /// \return True if \a left is not equal to \a right + /// + //////////////////////////////////////////////////////////// + template <typename T> + bool operator !=(const Vector3<T>& left, const Vector3<T>& right); + +#include "Vector3.inl" + + // Define the most common types + typedef Vector3<int> Vector3i; + typedef Vector3<float> Vector3f; + + } +} + +#endif
\ No newline at end of file diff --git a/Source/Asura.Engine/Math/Vector3.inl b/Source/Asura.Engine/Math/Vector3.inl new file mode 100644 index 0000000..3a2aa93 --- /dev/null +++ b/Source/Asura.Engine/Math/Vector3.inl @@ -0,0 +1,145 @@ + + +//////////////////////////////////////////////////////////// +template <typename T> +inline Vector3<T>::Vector3() : + x(0), + y(0), + z(0) +{ + +} + + +//////////////////////////////////////////////////////////// +template <typename T> +inline Vector3<T>::Vector3(T X, T Y, T Z) : + x(X), + y(Y), + z(Z) +{ + +} + + +//////////////////////////////////////////////////////////// +template <typename T> +template <typename U> +inline Vector3<T>::Vector3(const Vector3<U>& vector) : + x(static_cast<T>(vector.x)), + y(static_cast<T>(vector.y)), + z(static_cast<T>(vector.z)) +{ +} + + +//////////////////////////////////////////////////////////// +template <typename T> +inline Vector3<T> operator -(const Vector3<T>& left) +{ + return Vector3<T>(-left.x, -left.y, -left.z); +} + + +//////////////////////////////////////////////////////////// +template <typename T> +inline Vector3<T>& operator +=(Vector3<T>& left, const Vector3<T>& right) +{ + left.x += right.x; + left.y += right.y; + left.z += right.z; + + return left; +} + + +//////////////////////////////////////////////////////////// +template <typename T> +inline Vector3<T>& operator -=(Vector3<T>& left, const Vector3<T>& right) +{ + left.x -= right.x; + left.y -= right.y; + left.z -= right.z; + + return left; +} + + +//////////////////////////////////////////////////////////// +template <typename T> +inline Vector3<T> operator +(const Vector3<T>& left, const Vector3<T>& right) +{ + return Vector3<T>(left.x + right.x, left.y + right.y, left.z + right.z); +} + + +//////////////////////////////////////////////////////////// +template <typename T> +inline Vector3<T> operator -(const Vector3<T>& left, const Vector3<T>& right) +{ + return Vector3<T>(left.x - right.x, left.y - right.y, left.z - right.z); +} + + +//////////////////////////////////////////////////////////// +template <typename T> +inline Vector3<T> operator *(const Vector3<T>& left, T right) +{ + return Vector3<T>(left.x * right, left.y * right, left.z * right); +} + + +//////////////////////////////////////////////////////////// +template <typename T> +inline Vector3<T> operator *(T left, const Vector3<T>& right) +{ + return Vector3<T>(right.x * left, right.y * left, right.z * left); +} + + +//////////////////////////////////////////////////////////// +template <typename T> +inline Vector3<T>& operator *=(Vector3<T>& left, T right) +{ + left.x *= right; + left.y *= right; + left.z *= right; + + return left; +} + + +//////////////////////////////////////////////////////////// +template <typename T> +inline Vector3<T> operator /(const Vector3<T>& left, T right) +{ + return Vector3<T>(left.x / right, left.y / right, left.z / right); +} + + +//////////////////////////////////////////////////////////// +template <typename T> +inline Vector3<T>& operator /=(Vector3<T>& left, T right) +{ + left.x /= right; + left.y /= right; + left.z /= right; + + return left; +} + + +//////////////////////////////////////////////////////////// +template <typename T> +inline bool operator ==(const Vector3<T>& left, const Vector3<T>& right) +{ + return (left.x == right.x) && (left.y == right.y) && (left.z == right.z); +} + + +//////////////////////////////////////////////////////////// +template <typename T> +inline bool operator !=(const Vector3<T>& left, const Vector3<T>& right) +{ + return (left.x != right.x) || (left.y != right.y) || (left.z != right.z); +} diff --git a/Source/Asura.Engine/Math/Vector4.cpp b/Source/Asura.Engine/Math/Vector4.cpp deleted file mode 100644 index e69de29..0000000 --- a/Source/Asura.Engine/Math/Vector4.cpp +++ /dev/null diff --git a/Source/Asura.Engine/Math/Vector4.h b/Source/Asura.Engine/Math/Vector4.h index 3739f83..13a9d8a 100644 --- a/Source/Asura.Engine/Math/Vector4.h +++ b/Source/Asura.Engine/Math/Vector4.h @@ -5,12 +5,229 @@ namespace AsuraEngine { namespace Math { - + template <typename T> class Vector4 { + public: + + //////////////////////////////////////////////////////////// + /// \brief Default constructor + /// + /// Creates a Vector4(0, 0, 0). + /// + //////////////////////////////////////////////////////////// + Vector4(); + + //////////////////////////////////////////////////////////// + /// \brief Construct the vector from its coordinates + /// + /// \param X X coordinate + /// \param Y Y coordinate + /// \param Z Z coordinate + /// + //////////////////////////////////////////////////////////// + Vector4(T X, T Y, T Z, T W); + //////////////////////////////////////////////////////////// + /// \brief Construct the vector from another type of vector + /// + /// This constructor doesn't replace the copy constructor, + /// it's called only when U != T. + /// A call to this constructor will fail to compile if U + /// is not convertible to T. + /// + /// \param vector Vector to convert + /// + //////////////////////////////////////////////////////////// + template <typename U> + explicit Vector4(const Vector4<U>& vector); + + //////////////////////////////////////////////////////////// + // Member data + //////////////////////////////////////////////////////////// + T x; ///< X coordinate of the vector + T y; ///< Y coordinate of the vector + T z; ///< Z coordinate of the vector + T w; ///< W coordinate of the vector }; + //////////////////////////////////////////////////////////// + /// \relates Vector4 + /// \brief Overload of unary operator - + /// + /// \param left Vector to negate + /// + /// \return Memberwise opposite of the vector + /// + //////////////////////////////////////////////////////////// + template <typename T> + Vector4<T> operator -(const Vector4<T>& left); + + //////////////////////////////////////////////////////////// + /// \relates Vector4 + /// \brief Overload of binary operator += + /// + /// This operator performs a memberwise addition of both vectors, + /// and assigns the result to \a left. + /// + /// \param left Left operand (a vector) + /// \param right Right operand (a vector) + /// + /// \return Reference to \a left + /// + //////////////////////////////////////////////////////////// + template <typename T> + Vector4<T>& operator +=(Vector4<T>& left, const Vector4<T>& right); + + //////////////////////////////////////////////////////////// + /// \relates Vector4 + /// \brief Overload of binary operator -= + /// + /// This operator performs a memberwise subtraction of both vectors, + /// and assigns the result to \a left. + /// + /// \param left Left operand (a vector) + /// \param right Right operand (a vector) + /// + /// \return Reference to \a left + /// + //////////////////////////////////////////////////////////// + template <typename T> + Vector4<T>& operator -=(Vector4<T>& left, const Vector4<T>& right); + + //////////////////////////////////////////////////////////// + /// \relates Vector4 + /// \brief Overload of binary operator + + /// + /// \param left Left operand (a vector) + /// \param right Right operand (a vector) + /// + /// \return Memberwise addition of both vectors + /// + //////////////////////////////////////////////////////////// + template <typename T> + Vector4<T> operator +(const Vector4<T>& left, const Vector4<T>& right); + + //////////////////////////////////////////////////////////// + /// \relates Vector4 + /// \brief Overload of binary operator - + /// + /// \param left Left operand (a vector) + /// \param right Right operand (a vector) + /// + /// \return Memberwise subtraction of both vectors + /// + //////////////////////////////////////////////////////////// + template <typename T> + Vector4<T> operator -(const Vector4<T>& left, const Vector4<T>& right); + + //////////////////////////////////////////////////////////// + /// \relates Vector4 + /// \brief Overload of binary operator * + /// + /// \param left Left operand (a vector) + /// \param right Right operand (a scalar value) + /// + /// \return Memberwise multiplication by \a right + /// + //////////////////////////////////////////////////////////// + template <typename T> + Vector4<T> operator *(const Vector4<T>& left, T right); + + //////////////////////////////////////////////////////////// + /// \relates Vector4 + /// \brief Overload of binary operator * + /// + /// \param left Left operand (a scalar value) + /// \param right Right operand (a vector) + /// + /// \return Memberwise multiplication by \a left + /// + //////////////////////////////////////////////////////////// + template <typename T> + Vector4<T> operator *(T left, const Vector4<T>& right); + + //////////////////////////////////////////////////////////// + /// \relates Vector4 + /// \brief Overload of binary operator *= + /// + /// This operator performs a memberwise multiplication by \a right, + /// and assigns the result to \a left. + /// + /// \param left Left operand (a vector) + /// \param right Right operand (a scalar value) + /// + /// \return Reference to \a left + /// + //////////////////////////////////////////////////////////// + template <typename T> + Vector4<T>& operator *=(Vector4<T>& left, T right); + + //////////////////////////////////////////////////////////// + /// \relates Vector4 + /// \brief Overload of binary operator / + /// + /// \param left Left operand (a vector) + /// \param right Right operand (a scalar value) + /// + /// \return Memberwise division by \a right + /// + //////////////////////////////////////////////////////////// + template <typename T> + Vector4<T> operator /(const Vector4<T>& left, T right); + + //////////////////////////////////////////////////////////// + /// \relates Vector4 + /// \brief Overload of binary operator /= + /// + /// This operator performs a memberwise division by \a right, + /// and assigns the result to \a left. + /// + /// \param left Left operand (a vector) + /// \param right Right operand (a scalar value) + /// + /// \return Reference to \a left + /// + //////////////////////////////////////////////////////////// + template <typename T> + Vector4<T>& operator /=(Vector4<T>& left, T right); + + //////////////////////////////////////////////////////////// + /// \relates Vector4 + /// \brief Overload of binary operator == + /// + /// This operator compares strict equality between two vectors. + /// + /// \param left Left operand (a vector) + /// \param right Right operand (a vector) + /// + /// \return True if \a left is equal to \a right + /// + //////////////////////////////////////////////////////////// + template <typename T> + bool operator ==(const Vector4<T>& left, const Vector4<T>& right); + + //////////////////////////////////////////////////////////// + /// \relates Vector4 + /// \brief Overload of binary operator != + /// + /// This operator compares strict difference between two vectors. + /// + /// \param left Left operand (a vector) + /// \param right Right operand (a vector) + /// + /// \return True if \a left is not equal to \a right + /// + //////////////////////////////////////////////////////////// + template <typename T> + bool operator !=(const Vector4<T>& left, const Vector4<T>& right); + +#include "Vector4.inl" + + // Define the most common types + typedef Vector4<int> Vector4i; + typedef Vector4<float> Vector4f; + } } diff --git a/Source/Asura.Engine/Math/Vector4.inl b/Source/Asura.Engine/Math/Vector4.inl new file mode 100644 index 0000000..025bfcc --- /dev/null +++ b/Source/Asura.Engine/Math/Vector4.inl @@ -0,0 +1,152 @@ + + +//////////////////////////////////////////////////////////// +template <typename T> +inline Vector4<T>::Vector4() : + x(0), + y(0), + z(0), + w(0) +{ + +} + + +//////////////////////////////////////////////////////////// +template <typename T> +inline Vector4<T>::Vector4(T X, T Y, T Z) : + x(X), + y(Y), + z(Z), + w(0) +{ + +} + + +//////////////////////////////////////////////////////////// +template <typename T> +template <typename U> +inline Vector4<T>::Vector4(const Vector4<U>& vector) : + x(static_cast<T>(vector.x)), + y(static_cast<T>(vector.y)), + z(static_cast<T>(vector.z)) + w(static_cast<T>(vector.w)) +{ +} + + +//////////////////////////////////////////////////////////// +template <typename T> +inline Vector4<T> operator -(const Vector4<T>& left) +{ + return Vector4<T>(-left.x, -left.y, -left.z, -left.w); +} + + +//////////////////////////////////////////////////////////// +template <typename T> +inline Vector4<T>& operator +=(Vector4<T>& left, const Vector4<T>& right) +{ + left.x += right.x; + left.y += right.y; + left.z += right.z; + left.w += right.w; + + return left; +} + + +//////////////////////////////////////////////////////////// +template <typename T> +inline Vector4<T>& operator -=(Vector4<T>& left, const Vector4<T>& right) +{ + left.x -= right.x; + left.y -= right.y; + left.z -= right.z; + left.w -= right.w; + + return left; +} + + +//////////////////////////////////////////////////////////// +template <typename T> +inline Vector4<T> operator +(const Vector4<T>& left, const Vector4<T>& right) +{ + return Vector4<T>(left.x + right.x, left.y + right.y, left.z + right.z, left.w + right.w); +} + + +//////////////////////////////////////////////////////////// +template <typename T> +inline Vector4<T> operator -(const Vector4<T>& left, const Vector4<T>& right) +{ + return Vector4<T>(left.x - right.x, left.y - right.y, left.z - right.z, left.w - right.w); +} + + +//////////////////////////////////////////////////////////// +template <typename T> +inline Vector4<T> operator *(const Vector4<T>& left, T right) +{ + return Vector4<T>(left.x * right, left.y * right, left.z * right, left.w * right); +} + + +//////////////////////////////////////////////////////////// +template <typename T> +inline Vector4<T> operator *(T left, const Vector4<T>& right) +{ + return Vector4<T>(right.x * left, right.y * left, right.z * left, right.w * left); +} + + +//////////////////////////////////////////////////////////// +template <typename T> +inline Vector4<T>& operator *=(Vector4<T>& left, T right) +{ + left.x *= right; + left.y *= right; + left.z *= right; + left.w *= right; + + return left; +} + + +//////////////////////////////////////////////////////////// +template <typename T> +inline Vector4<T> operator /(const Vector4<T>& left, T right) +{ + return Vector4<T>(left.x / right, left.y / right, left.z / right, left.w / right); +} + + +//////////////////////////////////////////////////////////// +template <typename T> +inline Vector4<T>& operator /=(Vector4<T>& left, T right) +{ + left.x /= right; + left.y /= right; + left.z /= right; + left.w /= right; + + return left; +} + + +//////////////////////////////////////////////////////////// +template <typename T> +inline bool operator ==(const Vector4<T>& left, const Vector4<T>& right) +{ + return (left.x == right.x) && (left.y == right.y) && (left.z == right.z) && (left.w == right.w); +} + + +//////////////////////////////////////////////////////////// +template <typename T> +inline bool operator !=(const Vector4<T>& left, const Vector4<T>& right) +{ + return (left.x != right.x) || (left.y != right.y) || (left.z != right.z) || (left.w != right.w); +} diff --git a/Source/Asura.Engine/Object.h b/Source/Asura.Engine/Object.h index 4f00d64..352a61b 100644 --- a/Source/Asura.Engine/Object.h +++ b/Source/Asura.Engine/Object.h @@ -22,9 +22,12 @@ public: static void Release(Object* obj); + void Retain(); + void Release(); + private: - int mRC; // ߳ + unsigned int mRC; // ü }; diff --git a/Source/Asura.Engine/Scripting/Luax.hpp b/Source/Asura.Engine/Scripting/Luax.hpp index 5d01997..e1407ee 100644 --- a/Source/Asura.Engine/Scripting/Luax.hpp +++ b/Source/Asura.Engine/Scripting/Luax.hpp @@ -4,9 +4,13 @@ /// /// Scripting with Lua. /// - #include "Lua51/lua.h" #include "Lua51/lauxlib.h" #include "Luax/luax.h" +/// +/// ¶luapoartable +/// +#include "Portable.h" + #endif
\ No newline at end of file diff --git a/Source/Asura.Engine/Scripting/Portable.h b/Source/Asura.Engine/Scripting/Portable.h new file mode 100644 index 0000000..ae36cc2 --- /dev/null +++ b/Source/Asura.Engine/Scripting/Portable.h @@ -0,0 +1,23 @@ +#ifndef __ASURA_ENGINE_PORTABLE_H__ +#define __ASURA_ENGINE_PORTABLE_H__ + +#include "Object.h" + +namespace AsuraEngine +{ + namespace Scripting + { + + class Portable : virtual public Object + { + public: + + Portable(); + virtual ~Portable(); + + }; + + } +} + +#endif
\ No newline at end of file diff --git a/Source/Asura.Engine/SimClass.h b/Source/Asura.Engine/SimClass.h deleted file mode 100644 index 5901fd5..0000000 --- a/Source/Asura.Engine/SimClass.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef __ASURA_ENGINE_SIMCLASS_H__ -#define __ASURA_ENGINE_SIMCLASS_H__ - -namespace AsuraEngine -{ - - /// - /// - /// - class SimClass - { - public: - - SimClass() {}; - - virtual ~SimClass() {}; - - }; - -} - -#endif
\ No newline at end of file diff --git a/Source/Asura.Engine/Type.h b/Source/Asura.Engine/Type.h index 5159ee2..a956a4b 100644 --- a/Source/Asura.Engine/Type.h +++ b/Source/Asura.Engine/Type.h @@ -8,7 +8,7 @@ namespace AsuraEngine typedef int8_t int8; typedef uint8_t uint8; - typedef uint8 byte; + typedef uint8 byte; typedef int16_t int16; typedef uint16_t uint16; typedef int32_t int32; diff --git a/Source/Asura.Engine/Window/Window.cpp b/Source/Asura.Engine/Window/Window.cpp index e69de29..5e800e0 100644 --- a/Source/Asura.Engine/Window/Window.cpp +++ b/Source/Asura.Engine/Window/Window.cpp @@ -0,0 +1,19 @@ +#include "Window.h" + +namespace AsuraEngine +{ + namespace Graphics + { + + Window::Window() + { + + } + + Window::~Window() + { + + } + + } +} diff --git a/Source/Asura.Engine/Window/Window.h b/Source/Asura.Engine/Window/Window.h index 4e16e79..3456d75 100644 --- a/Source/Asura.Engine/Window/Window.h +++ b/Source/Asura.Engine/Window/Window.h @@ -1,13 +1,20 @@ #ifndef __ASURA_ENGINE_WINDOW_H__ #define __ASURA_ENGINE_WINDOW_H__ +#include "SDL2/Sdl.h" #include "Graphics/RenderTarget.h" +#include "Math/Vector2.hpp" namespace AsuraEngine { namespace Graphics { + enum WindowStyle + { + + }; + /// /// ڣֶ֧രڡڱ༭Ҫ֧֣runnerֻҪһڡ /// @@ -19,8 +26,35 @@ namespace AsuraEngine ~Window(); + SDL_Window* GetSDLHandle(); + + 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(); + private: + /// + /// SDL window handle. + /// + SDL_Window* mWindowHandle; + + Math::Vector2i mPosition; + + Math::Vector2i mSize; }; |