summaryrefslogtreecommitdiff
path: root/Source/Asura.Engine/Graphics
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Asura.Engine/Graphics')
-rw-r--r--Source/Asura.Engine/Graphics/Canvas.h43
-rw-r--r--Source/Asura.Engine/Graphics/Color.cpp2
-rw-r--r--Source/Asura.Engine/Graphics/Color.h21
-rw-r--r--Source/Asura.Engine/Graphics/Image.cpp37
-rw-r--r--Source/Asura.Engine/Graphics/Image.h42
-rw-r--r--Source/Asura.Engine/Graphics/Mesh2D.h5
-rw-r--r--Source/Asura.Engine/Graphics/Port/Canvas.cpp0
-rw-r--r--Source/Asura.Engine/Graphics/Port/Color.cpp0
-rw-r--r--Source/Asura.Engine/Graphics/Port/Image.cpp0
-rw-r--r--Source/Asura.Engine/Graphics/Port/Mesh2D.cpp0
-rw-r--r--Source/Asura.Engine/Graphics/Port/Shader.cpp105
-rw-r--r--Source/Asura.Engine/Graphics/Port/SpriteBatch.cpp0
-rw-r--r--Source/Asura.Engine/Graphics/RenderTarget.cpp0
-rw-r--r--Source/Asura.Engine/Graphics/RenderTarget.h30
-rw-r--r--Source/Asura.Engine/Graphics/Shader.cpp81
-rw-r--r--Source/Asura.Engine/Graphics/Shader.h92
-rw-r--r--Source/Asura.Engine/Graphics/SpriteBatch.h7
-rw-r--r--Source/Asura.Engine/Graphics/Texture.cpp26
-rw-r--r--Source/Asura.Engine/Graphics/Texture.h33
19 files changed, 446 insertions, 78 deletions
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 <Scripting/Luax.hpp>
+
+#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һֻࡣҪǿǵeditorengineʹòͬķװ
///
- class Image final : public Texture
+ class Image final : public Texture, public SimClass
{
public:
+ Image();
+ ~Image();
+
+ ///
+ /// bufferimagemPixelsΪգݡ¹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.SimImageAsuraEngine.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
--- /dev/null
+++ b/Source/Asura.Engine/Graphics/Port/Canvas.cpp
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
--- /dev/null
+++ b/Source/Asura.Engine/Graphics/Port/Color.cpp
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
--- /dev/null
+++ b/Source/Asura.Engine/Graphics/Port/Image.cpp
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
--- /dev/null
+++ b/Source/Asura.Engine/Graphics/Port/Mesh2D.cpp
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);
+
+ }
+
+ ///
+ /// uniformslocationûuniformnil򷵻ضӦ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);
+
+ }
+
+ //עluaijԱ
+ 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
--- /dev/null
+++ b/Source/Asura.Engine/Graphics/Port/SpriteBatch.cpp
diff --git a/Source/Asura.Engine/Graphics/RenderTarget.cpp b/Source/Asura.Engine/Graphics/RenderTarget.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Source/Asura.Engine/Graphics/RenderTarget.cpp
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 <map>
#include <string>
-#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һڲʼ乲ijShaderuniformsͶݣֻṩuniformsuseɫķ༭ÿ
- /// shaderͨshaderҵuniforms¶frameworkmaterialá
+ /// һshaderһڲʼ乲ijShaderuniformsͶݣֻṩuniformsuseɫķ༭
+ /// ÿshaderͨshaderҵuniforms¶frameworkmaterialá
///
- 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ʵ֣㣬shadereditorҲõ
- /// ջ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;
- //// Uniformlocations
- //StringMap<uint> 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 meshrender targetбʹ
+ /// 2D࣬2d meshrender targetбʹáTextureȾԭϽǣϷϲԵѿϵΪ׼
+ /// EditorҲϽΪԭ㣬Ϊ˷㡣
///
class Texture : virtual public Object
{
+ public:
+
+ Texture();
+
+ virtual ~Texture();
+
+ GLuint GetGLTextureHandle() const;
+
+ ///
+ /// ȾtexturertϣԭϽǣң
+ ///
+ 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;
+
}
}