From 250e30d73f09e9da2b5a81d0fbae63744ae12a73 Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 2 Apr 2019 08:47:15 +0800 Subject: *misc --- source/libs/asura-lib-core/graphics/image.h | 83 +++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 source/libs/asura-lib-core/graphics/image.h (limited to 'source/libs/asura-lib-core/graphics/image.h') diff --git a/source/libs/asura-lib-core/graphics/image.h b/source/libs/asura-lib-core/graphics/image.h new file mode 100644 index 0000000..4d9787b --- /dev/null +++ b/source/libs/asura-lib-core/graphics/image.h @@ -0,0 +1,83 @@ +#ifndef __ASURA_ENGINE_IMAGE_H__ +#define __ASURA_ENGINE_IMAGE_H__ + +#include +#include +#include +#include +#include +#include + +#include "texture.h" +#include "color.h" +#include "color32.h" +#include "image_data.h" +#include "render_state.h" + +namespace AsuraEngine +{ + namespace Graphics + { + + class ImageFactory; + + /// + /// Image是图片从内存中载入后,读取进游戏后保存的结果。一个Image在内存、显存中只会保存一 + /// 份,不会产生副本。需要特征化的区别image,如锚点位置,缩放和旋转角度,使用sprite。 + /// 是一个只读类。主要是考虑到editor和engine使用不同的封装。 + /// + class Image ASURA_FINAL + : public Drawable + , public Scripting::Portable + , public AEIO::Reloadable + { + public: + + LUAX_DECL_FACTORY(SimImage); + + Image(); + + ~Image(); + + /// + /// 从数据buffer构建image像素信息,如果mPixels不为空,先清空数据。用来重新构建image, + /// 使用glTexImage2D重新提交image的像素数据。 + /// + bool Load(ImageData* data); + + uint GetWidth(); + uint GetHeight(); + Math::Vector2u GetSize(); + + /// + /// 获得某一个位置的像素 + /// + Color32 GetPixel(uint x, uint y); + + 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; + Luax::LuaxMemberRef mImageDataRef; + + Math::Vector2u mSize; + + LUAX_DECL_METHOD(_New); + LUAX_DECL_METHOD(_Load); + LUAX_DECL_METHOD(_GetWidth); + LUAX_DECL_METHOD(_GetHeight); + LUAX_DECL_METHOD(_GetSize); + LUAX_DECL_METHOD(_GetPixel); + LUAX_DECL_METHOD(_Render); + + }; + + } +} + +namespace AEGraphics = AsuraEngine::Graphics; + +#endif \ No newline at end of file -- cgit v1.1-26-g67d0