From 3f457498b9c39d40a16a0ec6328880854f8cf4de Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 26 Feb 2019 08:48:54 +0800 Subject: *misc --- Source/Asura.Engine/Graphics/Canvas.h | 43 ++++++++- Source/Asura.Engine/Graphics/Color.cpp | 2 +- Source/Asura.Engine/Graphics/Color.h | 21 ++--- Source/Asura.Engine/Graphics/Image.cpp | 37 ++++++++ Source/Asura.Engine/Graphics/Image.h | 42 +++++---- Source/Asura.Engine/Graphics/Mesh2D.h | 5 +- Source/Asura.Engine/Graphics/Port/Canvas.cpp | 0 Source/Asura.Engine/Graphics/Port/Color.cpp | 0 Source/Asura.Engine/Graphics/Port/Image.cpp | 0 Source/Asura.Engine/Graphics/Port/Mesh2D.cpp | 0 Source/Asura.Engine/Graphics/Port/Shader.cpp | 105 ++++++++++++++++++++++ Source/Asura.Engine/Graphics/Port/SpriteBatch.cpp | 0 Source/Asura.Engine/Graphics/RenderTarget.cpp | 0 Source/Asura.Engine/Graphics/RenderTarget.h | 30 +++++++ Source/Asura.Engine/Graphics/Shader.cpp | 81 +++++++++++++++++ Source/Asura.Engine/Graphics/Shader.h | 92 ++++++++++--------- Source/Asura.Engine/Graphics/SpriteBatch.h | 7 +- Source/Asura.Engine/Graphics/Texture.cpp | 26 ++++++ Source/Asura.Engine/Graphics/Texture.h | 33 ++++++- 19 files changed, 446 insertions(+), 78 deletions(-) create mode 100644 Source/Asura.Engine/Graphics/Port/Canvas.cpp create mode 100644 Source/Asura.Engine/Graphics/Port/Color.cpp create mode 100644 Source/Asura.Engine/Graphics/Port/Image.cpp create mode 100644 Source/Asura.Engine/Graphics/Port/Mesh2D.cpp create mode 100644 Source/Asura.Engine/Graphics/Port/Shader.cpp create mode 100644 Source/Asura.Engine/Graphics/Port/SpriteBatch.cpp create mode 100644 Source/Asura.Engine/Graphics/RenderTarget.cpp create mode 100644 Source/Asura.Engine/Graphics/RenderTarget.h (limited to 'Source/Asura.Engine/Graphics') diff --git a/Source/Asura.Engine/Graphics/Canvas.h b/Source/Asura.Engine/Graphics/Canvas.h index c9adf2d..fc8a527 100644 --- a/Source/Asura.Engine/Graphics/Canvas.h +++ b/Source/Asura.Engine/Graphics/Canvas.h @@ -1,25 +1,64 @@ #ifndef __ASURA_ENGINE_CANVAS_H__ #define __ASURA_ENGINE_CANVAS_H__ +#include + +#include "GL.h" +#include "SimClass.h" #include "Texture.h" +#include "RenderTarget.h" namespace AsuraEngine { namespace Graphics { - class Canvas : public Texture + /// + /// Canvas也可以称为render texture,自身也可以作为texture渲染。 + /// + class Canvas final : public Texture, public RenderTarget, public SimClass { public: Canvas(); + /// + /// 绑定此canvas,设置为活动 + /// + void Bind(); + + /// + /// 设置为非活动,绑定回screen + /// + void Unbind(); + + 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; + + //---------------------------------------------------------------------------------------------------------- + + LUAX_DECL_FACTORY(SimCanvas); + + LUAX_DECL_METHOD(l_Bind); + LUAX_DECL_METHOD(l_Unbind); + + //---------------------------------------------------------------------------------------------------------- + private: - LUAX_DECL_FACTORY(SimCanvas); // AsuraEngine.SimCanvas + /// + /// Frame buffer object id. + /// + GLuint mFBO; }; + /// + /// Canvas别名为RenderTexture + /// + using RenderTexture = Canvas; + } } diff --git a/Source/Asura.Engine/Graphics/Color.cpp b/Source/Asura.Engine/Graphics/Color.cpp index a047f53..106493d 100644 --- a/Source/Asura.Engine/Graphics/Color.cpp +++ b/Source/Asura.Engine/Graphics/Color.cpp @@ -54,7 +54,7 @@ namespace AsuraEngine } - ////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //------------------------------------------------------------------------------------------------------------ Color::Color() { diff --git a/Source/Asura.Engine/Graphics/Color.h b/Source/Asura.Engine/Graphics/Color.h index daf6a09..6383602 100644 --- a/Source/Asura.Engine/Graphics/Color.h +++ b/Source/Asura.Engine/Graphics/Color.h @@ -2,7 +2,7 @@ #define __ASURA_ENGINE_COLOR_H__ #include "Scripting/Luax.hpp" - +#include "Object.h" #include "Type.h" namespace AsuraEngine @@ -15,7 +15,7 @@ namespace AsuraEngine /// /// 32bits颜色 /// - class Color32 + class Color32 : virtual public Object { public: @@ -29,7 +29,7 @@ namespace AsuraEngine byte r, g, b, a; - private: + //---------------------------------------------------------------------------------------------------------- LUAX_DECL_FACTORY(Color32); @@ -37,18 +37,18 @@ namespace AsuraEngine LUAX_DECL_METHOD(l_GetGreen); LUAX_DECL_METHOD(l_GetBlue); LUAX_DECL_METHOD(l_GetAlpha); - - // meta methods LUAX_DECL_METHOD(l_Multiply); LUAX_DECL_METHOD(l_Index); //索引r,g,b,a LUAX_DECL_METHOD(l_NewIndex); //修改r,g,b,a + //---------------------------------------------------------------------------------------------------------- + }; /// /// 规范化颜色 /// - class Color + class Color : virtual public Object { public: @@ -64,9 +64,7 @@ namespace AsuraEngine float r, g, b, a; - private: - - //////////////////////////////////////////////////////////////////////////////////////////////////////////// + //---------------------------------------------------------------------------------------------------------- LUAX_DECL_FACTORY(Color); @@ -74,12 +72,11 @@ namespace AsuraEngine LUAX_DECL_METHOD(l_GetGreen); // color.g LUAX_DECL_METHOD(l_GetBlue); // color.b LUAX_DECL_METHOD(l_GetAlpha); // color.a - - // meta methods LUAX_DECL_METHOD(l_Multiply); // 颜色乘法 - //LUAX_DECL_METHOD(l_Index); // 索引r,g,b,a 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 e69de29..e19d57f 100644 --- a/Source/Asura.Engine/Graphics/Image.cpp +++ b/Source/Asura.Engine/Graphics/Image.cpp @@ -0,0 +1,37 @@ +#include "Image.h" + +namespace AsuraEngine +{ + namespace Graphics + { + + Image::Image() + : Texture() + , mPixels(nullptr) + , mWidth(0) + , mHeight(0) + { + } + + Image::~Image() + { + delete mPixels; + } + + bool Image::Load(const void* data, size_t size) + { + + } + + 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) + { + + } + + } +} diff --git a/Source/Asura.Engine/Graphics/Image.h b/Source/Asura.Engine/Graphics/Image.h index bdd7c1c..391d1c4 100644 --- a/Source/Asura.Engine/Graphics/Image.h +++ b/Source/Asura.Engine/Graphics/Image.h @@ -7,6 +7,7 @@ #include "Texture.h" #include "Color.h" #include "Factory.h" +#include "SimClass.h" namespace AsuraEngine { @@ -19,10 +20,19 @@ namespace AsuraEngine /// Image是图片从内存中载入后,读取进游戏后保存的结果。一个Image在内存、显存中只会保存一份,不会产生副本。需要特征 /// 化的区别image,如锚点位置,缩放和旋转角度,使用sprite。是一个只读类。主要是考虑到editor和engine使用不同的封装。 /// - class Image final : public Texture + class Image final : public Texture, public SimClass { public: + Image(); + ~Image(); + + /// + /// 从数据buffer构建image,如果mPixels不为空,先清空数据。用来重新构建image,使用glTexImage2D重新提交image的像素 + /// 数据。 + /// + bool Load(const void* data, size_t size); + uint GetWidth(); uint GetHeight(); @@ -31,29 +41,29 @@ namespace AsuraEngine /// Color GetPixel(uint x, uint y); - private: + void Render(int x, int y, int sx, int sy, int ox, int oy, int r) override; - friend class ImageFactory; + void Render(const Math::Rect& quad, int x, int y, int sx, int sy, int ox, int oy, int r) override; - Image(Color* pixels, int width, int height); - ~Image(); + //---------------------------------------------------------------------------------------------------------- + + LUAX_DECL_FACTORY(SimImage); + + LUAX_DECL_METHOD(l_Load); + LUAX_DECL_METHOD(l_GetPixel); + LUAX_DECL_METHOD(l_GetWidth); + LUAX_DECL_METHOD(l_GetHeight); + + //---------------------------------------------------------------------------------------------------------- + + private: /// /// 大小(以像素为单位) /// uint mWidth, mHeight; - Color* mPixels; - - /// - /// ID - /// - uint mID; - - //---------------------------------------------------------------------------------------------------- - // 图片的Sim类,具体的封装在AsuraEngine.Image里面,包含一个成员AsuraEngine.SimImage,在AsuraEngine.Image里面对 - // 数据做一个缓存。 - LUAX_DECL_FACTORY(SimImage); + Color* mPixels; }; diff --git a/Source/Asura.Engine/Graphics/Mesh2D.h b/Source/Asura.Engine/Graphics/Mesh2D.h index 0d5113a..921ae80 100644 --- a/Source/Asura.Engine/Graphics/Mesh2D.h +++ b/Source/Asura.Engine/Graphics/Mesh2D.h @@ -1,6 +1,9 @@ #ifndef __ASURA_ENGINE_MESH2D_H__ #define __ASURA_ENGINE_MESH2D_H__ +#include "Object.h" +#include "SimClass.h" + namespace AsuraEngine { namespace Graphics @@ -9,7 +12,7 @@ namespace AsuraEngine /// /// 2D mesh,用于做一些顶点动画。 /// - class Mesh2D + class Mesh2D : virtual public Object, public SimClass { }; diff --git a/Source/Asura.Engine/Graphics/Port/Canvas.cpp b/Source/Asura.Engine/Graphics/Port/Canvas.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Source/Asura.Engine/Graphics/Port/Color.cpp b/Source/Asura.Engine/Graphics/Port/Color.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Source/Asura.Engine/Graphics/Port/Image.cpp b/Source/Asura.Engine/Graphics/Port/Image.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Source/Asura.Engine/Graphics/Port/Mesh2D.cpp b/Source/Asura.Engine/Graphics/Port/Mesh2D.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Source/Asura.Engine/Graphics/Port/Shader.cpp b/Source/Asura.Engine/Graphics/Port/Shader.cpp new file mode 100644 index 0000000..887cfae --- /dev/null +++ b/Source/Asura.Engine/Graphics/Port/Shader.cpp @@ -0,0 +1,105 @@ +#include "../Shader.h" + +using namespace Luax; + +namespace AsuraEngine +{ + namespace Graphics + { + + /// + /// 将此shader设置为活动。 + /// + int Shader::l_Use(lua_State* L) + { + LuaxState state = LuaxState(L); + + } + + /// + /// 将此shader设置为非活动。 + /// + int Shader::l_Unuse(lua_State* L) + { + LuaxState state = LuaxState(L); + + } + + /// + /// 从着色器代码中构建shader程序。如果成功返回true,失败返回false。 + /// + int Shader::l_Load(lua_State* L) + { + LuaxState state = LuaxState(L); + + } + + /// + /// 判断shader是否有这个uniform,如果有返回true,否则返回false + /// + int Shader::l_HasUniform(lua_State* L) + { + LuaxState state = LuaxState(L); + + } + + /// + /// 后的uniforms的location,如果没有这个uniform,返回nil,否则返回对应的loc + /// + int Shader::l_GetUniformLocation(lua_State* L) + { + LuaxState state = LuaxState(L); + + } + + int Shader::l_SetBuiltInUniforms(lua_State* L) + { + LuaxState state = LuaxState(L); + + } + + int Shader::l_SetUniformFloat(lua_State* L) + { + LuaxState state = LuaxState(L); + + } + + int Shader::l_SetUniformTexture(lua_State* L) + { + LuaxState state = LuaxState(L); + + } + + int Shader::l_SetUniformVector2(lua_State* L) + { + LuaxState state = LuaxState(L); + + } + + int Shader::l_SetUniformVector3(lua_State* L) + { + LuaxState state = LuaxState(L); + + } + + int Shader::l_SetUniformVector4(lua_State* L) + { + LuaxState state = LuaxState(L); + + } + + int Shader::l_SetUniformColor(lua_State* L) + { + LuaxState state = LuaxState(L); + + } + + //注册lua类的成员 + int Shader::RegisterLuaClass(lua_State* L) + { + LuaxState state = LuaxState(L); + + } + + } +} \ No newline at end of file diff --git a/Source/Asura.Engine/Graphics/Port/SpriteBatch.cpp b/Source/Asura.Engine/Graphics/Port/SpriteBatch.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Source/Asura.Engine/Graphics/RenderTarget.cpp b/Source/Asura.Engine/Graphics/RenderTarget.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Source/Asura.Engine/Graphics/RenderTarget.h b/Source/Asura.Engine/Graphics/RenderTarget.h new file mode 100644 index 0000000..05d7068 --- /dev/null +++ b/Source/Asura.Engine/Graphics/RenderTarget.h @@ -0,0 +1,30 @@ +#ifndef __ASURA_ENGINE_RENDERTARGET_H__ +#define __ASURA_ENGINE_RENDERTARGET_H__ + +#include "Texture.h" +#include "Object.h" + +namespace AsuraEngine +{ + namespace Graphics + { + + /// + /// 可被作为渲染目标的类,派生类有 + /// Canvas(RenderTexture) + /// Window(RenderWindow) + /// + class RenderTarget : virtual public Object + { + public: + + RenderTarget() {}; + + virtual ~RenderTarget() {}; + + }; + + } +} + +#endif \ No newline at end of file diff --git a/Source/Asura.Engine/Graphics/Shader.cpp b/Source/Asura.Engine/Graphics/Shader.cpp index e69de29..6cf65e0 100644 --- a/Source/Asura.Engine/Graphics/Shader.cpp +++ b/Source/Asura.Engine/Graphics/Shader.cpp @@ -0,0 +1,81 @@ +#include "Shader.h" + +namespace AsuraEngine +{ + namespace Graphics + { + + Shader::Shader() + { + + } + + Shader::~Shader() + { + + } + + bool Shader::Load(const std::string& vertexShader, const std::string& fragmentShader) + { + + } + + uint Shader::GetUniformLocation(const std::string& uniform) + { + + } + + GLuint Shader::GetGLProgramHandle() + { + return mProgramHandle; + } + + void Shader::Use() + { + + } + + void Shader::Unuse() + { + + } + + void Shader::SetUniformFloat(uint loc, float value) + { + + } + + void Shader::SetUniformFloat(uint loc, float value) + { + + } + + void Shader::SetUniformTexture(uint loc, const Texture& texture) + { + + } + + void Shader::SetUniformVector2(uint loc, const Math::Vector2& vec2) + { + + } + + void Shader::SetUniformVector3(uint loc, const Math::Vector3& vec3) + { + + } + + void Shader::SetUniformVector4(uint loc, const Math::Vector4& vec4) + { + + } + + uint Shader::GetGLTextureUnitCount() + { + GLint maxTextureUnits = 0; + glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &maxTextureUnits); + return (uint)maxTextureUnits; + } + + } +} \ No newline at end of file diff --git a/Source/Asura.Engine/Graphics/Shader.h b/Source/Asura.Engine/Graphics/Shader.h index 02d9f46..2cc482b 100644 --- a/Source/Asura.Engine/Graphics/Shader.h +++ b/Source/Asura.Engine/Graphics/Shader.h @@ -4,16 +4,18 @@ #include #include -#include "luax/luax.h" +#include "Scripting/Luax.hpp" +#include "Math/Vector2.h" +#include "Math/Vector3.h" +#include "Math/Vector4.h" +#include "Math/Matrix44.h" #include "StringMap.hpp" #include "Object.h" #include "Color.h" #include "Manager.hpp" #include "Texture.h" -#include "Math/Vector2.h" -#include "Math/Vector3.h" -#include "Math/Vector4.h" #include "GL.h" +#include "SimClass.h" namespace AsuraEngine { @@ -21,10 +23,10 @@ namespace AsuraEngine { /// - /// 一个shader是一个在材质间共享的程序。Shader本身不保存uniforms和顶点数据,只提供设置uniforms和use着色器的方法。编辑器针对每个 - /// shader,会通过shader代码找到声明的uniforms变量,并暴露给framework的material设置。 + /// 一个shader是一个在材质间共享的程序。Shader本身不保存uniforms和顶点数据,只提供设置uniforms和use着色器的方法。编辑 + /// 器针对每个shader,会通过shader代码找到声明的uniforms变量,并暴露给framework的material设置。 /// - class Shader : virtual public Object + class Shader final : virtual public Object, public SimClass { public: @@ -32,9 +34,10 @@ namespace AsuraEngine ~Shader(); /// - /// 从代码编译shader,编译时会先检测是否有上次缓存的uniforms location map + /// 从代码编译shader,编译时会先检测是否有上次缓存的uniforms location map。使用glAttachShader重新编译生成着色器, + /// 不会重新申请着色器程序。 /// - void Load(const std::string& vertexShader, const std::string& fragmentShader); + bool Load(const std::string& vertexShader, const std::string& fragmentShader); /// /// 将当期shader设置为活动 @@ -44,16 +47,7 @@ namespace AsuraEngine /// /// 将当期shader设置为非活动 /// - void UnUse(); - - /// - /// 一系列设置uniforms变量的方法 - /// - void SetUniformFloat(const std::string& uniform, float value); - void SetUniformTexture(const std::string& uniform, const Texture& texture); - void SetUniformVector2(const std::string& uniform, const Math::Vector2& vec2); - void SetUniformVector3(const std::string& uniform, const Math::Vector3& vec3); - void SetUniformVector4(const std::string& uniform, const Math::Vector4& vec4); + void Unuse(); /// /// 在已经知道uniform location的情况下,设置值。 @@ -63,46 +57,58 @@ namespace AsuraEngine void SetUniformVector2(uint loc, const Math::Vector2& vec2); void SetUniformVector3(uint loc, const Math::Vector3& vec3); void SetUniformVector4(uint loc, const Math::Vector4& vec4); - -/* - /// - /// 注:后来考虑这个功能放在framework里面实现,更方便,而且shader在editor里也会用到。 - /// 清空缓存的unifrom location,用于重新编译shader,更新最新的uniform location - /// - void ClearUniformLocation(); -*/ - /// - /// 获得program id - /// - GLint GetNativeHandle(); + void SetUniformColor(uint loc, const Color& color); + void SetUniformMatrix44(uint loc, const Math::Matrix44& mat44); uint GetUniformLocation(const std::string& uniform); - private: + bool HasUniform(const std::string& uniform); + + GLuint GetGLProgramHandle(); /// - /// 设置内置变量: - /// vec2 Asura_Time x值为进入当前场景开始的时间,y值为上一帧的时间间隔 - /// vec2 Asura_RenderTargetSize RT的大小,以像素为单位 - /// Texture Asura_MainTexture 主纹理 + /// 获得texture unit数量,一般为16个 /// - void SetBuiltInUniforms(); - - // OpenGL着色器标识符program id - GLuint mPID; - //// Uniform的locations - //StringMap mUniformLocation; + 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: + + /// + /// 当前活动的shader + /// + static Shader* mCurrentShader; + + /// + /// 设置内置变量: + /// vec2 Asura_Time x值为进入当前场景开始的时间,y值为上一帧的时间间隔 + /// vec2 Asura_RenderTargetSize RT的大小,以像素为单位 + /// Texture Asura_MainTexture 主纹理 + /// + void SetBuiltInUniforms(); + + /// + /// OpenGL shader program handle. + /// + GLuint mProgramHandle; }; diff --git a/Source/Asura.Engine/Graphics/SpriteBatch.h b/Source/Asura.Engine/Graphics/SpriteBatch.h index 17d5e75..a571775 100644 --- a/Source/Asura.Engine/Graphics/SpriteBatch.h +++ b/Source/Asura.Engine/Graphics/SpriteBatch.h @@ -1,6 +1,8 @@ #ifndef __ASURA_ENGINE_SPRITE_BATCH_H__ #define __ASURA_ENGINE_SPRITE_BATCH_H__ +#include "Object.h" + namespace AsuraEngine { namespace Graphics @@ -9,8 +11,11 @@ namespace AsuraEngine /// /// Sprite batch用在批量渲染单个图片的地方,比如粒子系统。 /// - class SpriteBatch + class SpriteBatch : virtual public Object { + public: + + SpriteBatch(); }; diff --git a/Source/Asura.Engine/Graphics/Texture.cpp b/Source/Asura.Engine/Graphics/Texture.cpp index e69de29..6cb6497 100644 --- a/Source/Asura.Engine/Graphics/Texture.cpp +++ b/Source/Asura.Engine/Graphics/Texture.cpp @@ -0,0 +1,26 @@ +#include "Texture.h" + +namespace AsuraEngine +{ + namespace Graphics + { + + Texture::Texture() + : mTextureHandle(0) + { + // 申请GL texture + glGenTextures(1, &mTextureHandle); + } + + Texture::~Texture() + { + glDeleteTextures(1, &mTextureHandle); + } + + GLuint Texture::GetGLTextureHandle() const + { + return mTextureHandle; + } + + } +} \ No newline at end of file diff --git a/Source/Asura.Engine/Graphics/Texture.h b/Source/Asura.Engine/Graphics/Texture.h index 06461ce..e5b713c 100644 --- a/Source/Asura.Engine/Graphics/Texture.h +++ b/Source/Asura.Engine/Graphics/Texture.h @@ -1,8 +1,10 @@ #ifndef __ASURA_ENGINE_TEXTURE_H__ #define __ASURA_ENGINE_TEXTURE_H__ +#include "Math/Rect.h" +#include "Scripting/Luax.hpp" #include "Object.h" -#include "Luax/luax.h" +#include "GL.h" namespace AsuraEngine { @@ -10,13 +12,40 @@ namespace AsuraEngine { /// - /// 2D纹理抽象类,在2d mesh和render target中被使用 + /// 2D纹理抽象类,在2d mesh和render target中被使用。Texture的渲染原点在左上角,游戏里面的上层会以笛卡尔坐标系为标准。 + /// 在Editor里面界面和组件也是以左上角为原点,这样是为了方便。 /// class Texture : virtual public Object { + public: + + Texture(); + + virtual ~Texture(); + + GLuint GetGLTextureHandle() const; + + /// + /// 渲染整个texture到rt上,原点在左上角,向右,向下延伸 + /// + virtual void Render(int x, int y, int sx, int sy, int ox, int oy, int r) = 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; + + protected: + + /// + /// OpenGL texture handle。 + /// + GLuint mTextureHandle; }; + using Renderable = Texture; + } } -- cgit v1.1-26-g67d0