summaryrefslogtreecommitdiff
path: root/Source/modules/asura-core/Graphics
diff options
context:
space:
mode:
Diffstat (limited to 'Source/modules/asura-core/Graphics')
-rw-r--r--Source/modules/asura-core/Graphics/BlendMode.h17
-rw-r--r--Source/modules/asura-core/Graphics/Canvas.cpp49
-rw-r--r--Source/modules/asura-core/Graphics/Canvas.h73
-rw-r--r--Source/modules/asura-core/Graphics/Color.cpp58
-rw-r--r--Source/modules/asura-core/Graphics/Color.h75
-rw-r--r--Source/modules/asura-core/Graphics/Color32.cpp53
-rw-r--r--Source/modules/asura-core/Graphics/Color32.h58
-rw-r--r--Source/modules/asura-core/Graphics/ColorPalette.h0
-rw-r--r--Source/modules/asura-core/Graphics/DrawInfo.cpp10
-rw-r--r--Source/modules/asura-core/Graphics/DrawInfo.h19
-rw-r--r--Source/modules/asura-core/Graphics/DrawUtil.cpp0
-rw-r--r--Source/modules/asura-core/Graphics/DrawUtil.h0
-rw-r--r--Source/modules/asura-core/Graphics/GPUBuffer.cpp151
-rw-r--r--Source/modules/asura-core/Graphics/GPUBuffer.h93
-rw-r--r--Source/modules/asura-core/Graphics/GfxDevice.cpp188
-rw-r--r--Source/modules/asura-core/Graphics/GfxDevice.h141
-rw-r--r--Source/modules/asura-core/Graphics/GraphicsHelper.cpp0
-rw-r--r--Source/modules/asura-core/Graphics/GraphicsHelper.h15
-rw-r--r--Source/modules/asura-core/Graphics/Image.cpp103
-rw-r--r--Source/modules/asura-core/Graphics/Image.h63
-rw-r--r--Source/modules/asura-core/Graphics/IndexBuffer.cpp17
-rw-r--r--Source/modules/asura-core/Graphics/IndexBuffer.h34
-rw-r--r--Source/modules/asura-core/Graphics/MatrixStack.cpp75
-rw-r--r--Source/modules/asura-core/Graphics/MatrixStack.h58
-rw-r--r--Source/modules/asura-core/Graphics/Mesh2D.cpp0
-rw-r--r--Source/modules/asura-core/Graphics/Mesh2D.h52
-rw-r--r--Source/modules/asura-core/Graphics/Polygon2D.cpp0
-rw-r--r--Source/modules/asura-core/Graphics/Polygon2D.h0
-rw-r--r--Source/modules/asura-core/Graphics/Quad.cpp0
-rw-r--r--Source/modules/asura-core/Graphics/Quad.h1
-rw-r--r--Source/modules/asura-core/Graphics/RenderState.h47
-rw-r--r--Source/modules/asura-core/Graphics/RenderTarget.cpp0
-rw-r--r--Source/modules/asura-core/Graphics/RenderTarget.h52
-rw-r--r--Source/modules/asura-core/Graphics/Shader.cpp282
-rw-r--r--Source/modules/asura-core/Graphics/Shader.h117
-rw-r--r--Source/modules/asura-core/Graphics/Shape.cpp0
-rw-r--r--Source/modules/asura-core/Graphics/Shape.h0
-rw-r--r--Source/modules/asura-core/Graphics/SpriteBatch.cpp0
-rw-r--r--Source/modules/asura-core/Graphics/SpriteBatch.h34
-rw-r--r--Source/modules/asura-core/Graphics/Texture.cpp47
-rw-r--r--Source/modules/asura-core/Graphics/Texture.h101
-rw-r--r--Source/modules/asura-core/Graphics/VBO.cpp0
-rw-r--r--Source/modules/asura-core/Graphics/VBO.h27
-rw-r--r--Source/modules/asura-core/Graphics/VertexBuffer.cpp16
-rw-r--r--Source/modules/asura-core/Graphics/VertexBuffer.h34
-rw-r--r--Source/modules/asura-core/Graphics/binding/_canvas.cpp48
-rw-r--r--Source/modules/asura-core/Graphics/binding/_color.cpp130
-rw-r--r--Source/modules/asura-core/Graphics/binding/_color32.cpp66
-rw-r--r--Source/modules/asura-core/Graphics/binding/_gfx_device.cpp151
-rw-r--r--Source/modules/asura-core/Graphics/binding/_gpu_buffer.cpp118
-rw-r--r--Source/modules/asura-core/Graphics/binding/_image.cpp71
-rw-r--r--Source/modules/asura-core/Graphics/binding/_index_buffer.cpp31
-rw-r--r--Source/modules/asura-core/Graphics/binding/_mesh2d.cpp20
-rw-r--r--Source/modules/asura-core/Graphics/binding/_shader.cpp131
-rw-r--r--Source/modules/asura-core/Graphics/binding/_sprite_batch.cpp20
-rw-r--r--Source/modules/asura-core/Graphics/binding/_texture.cpp85
-rw-r--r--Source/modules/asura-core/Graphics/binding/_vertex_buffer.cpp38
57 files changed, 3069 insertions, 0 deletions
diff --git a/Source/modules/asura-core/Graphics/BlendMode.h b/Source/modules/asura-core/Graphics/BlendMode.h
new file mode 100644
index 0000000..fb17b45
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/BlendMode.h
@@ -0,0 +1,17 @@
+#ifndef _ASURA_ENGINE_BLEND_MODE_H_
+#define _ASURA_ENGINE_BLEND_MODE_H_
+
+#include <asura-base/Classes.h>
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+enum BlendMode
+{
+
+};
+
+namespace_end
+namespace_end
+
+#endif \ No newline at end of file
diff --git a/Source/modules/asura-core/Graphics/Canvas.cpp b/Source/modules/asura-core/Graphics/Canvas.cpp
new file mode 100644
index 0000000..60c8f87
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/Canvas.cpp
@@ -0,0 +1,49 @@
+#include "Canvas.h"
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+Canvas::Canvas()
+ : m_Width(0)
+ , m_Height(0)
+ , m_FBO(0)
+{
+ // Fix: ôСʼʱframebufferԴ
+ //glGenFramebuffers(1, &m_FBO);
+ //GLint current_fbo;
+ //glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &current_fbo);
+ //glBindFramebuffer(GL_FRAMEBUFFER, m_FBO);
+ //glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_TexID, 0);
+ //glBindFramebuffer(GL_FRAMEBUFFER, current_fbo);
+}
+
+void Canvas::SetSize(uint w, uint h)
+{
+ if (m_FBO == 0)
+ {
+ glGenFramebuffers(1, &m_FBO);
+ if (m_FBO == 0)
+ throw Exception("OpenGL glGenFramebuffers cannot generate frame buffer object.");
+ //
+ if (m_TexID == 0)
+ {
+ glGenTextures(1, &m_TexID);
+ if (m_TexID == 0)
+ throw Exception("OpenGL glGenTextures cannot generate texture.");
+ }
+ GLint current_fbo;
+ glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &current_fbo);
+ glBindFramebuffer(GL_FRAMEBUFFER, m_FBO);
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_TexID, 0);
+ glBindFramebuffer(GL_FRAMEBUFFER, current_fbo);
+ }
+ GLint current_tex;
+ glGetIntegerv(GL_TEXTURE_BINDING_2D, &current_tex);
+ glBindTexture(GL_TEXTURE_2D, m_TexID);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ glBindTexture(GL_TEXTURE_2D, current_tex);
+}
+
+namespace_end
+
+namespace_end \ No newline at end of file
diff --git a/Source/modules/asura-core/Graphics/Canvas.h b/Source/modules/asura-core/Graphics/Canvas.h
new file mode 100644
index 0000000..de02b9d
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/Canvas.h
@@ -0,0 +1,73 @@
+#ifndef _ASURA_ENGINE_CANVAS_H_
+#define _ASURA_ENGINE_CANVAS_H_
+
+#include <asura-base/Scripting/Scripting.h>
+#include <asura-base/Math/Rect.hpp>
+#include <asura-base/Math/Vector2.hpp>
+#include <asura-base/Exception.h>
+
+#include "GfxDevice.h"
+#include "Texture.h"
+#include "RenderTarget.h"
+#include "RenderState.h"
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+
+///
+/// CanvasҲԳΪrender textureҲΪtextureȾ
+///
+class Canvas ASURA_FINAL
+ : public Scripting::Portable<Canvas, RenderTarget>
+{
+public:
+
+ Canvas();
+
+ ~Canvas();
+
+ ///
+ /// render textureĴС
+ ///
+ void SetSize(uint w, uint h) ASURA_THROW(Exception);
+
+ void Clear(const Color& col = Color::Black) override;
+/*
+ void Clear(const Math::Recti& quad, const Color& col = Color::Black) override;
+*/
+ void Render(const RenderTarget* rt, const Math::Vector2i& pos, const Math::Vector2i& scale, const Math::Vector2i& center, float rot);
+
+ void Render(const RenderTarget* rt, const Math::Rectf& quad, const Math::Vector2i& pos, const Math::Vector2i& scale, const Math::Vector2i& center, float rot);
+
+ void Draw(const Drawable* texture, const RenderState& state);
+
+ void Draw(const Drawable* texture, const Math::Recti& quad, const RenderState& state);
+
+private:
+
+ GLuint m_FBO;
+
+ GLuint m_TexID;
+
+ uint m_Width, m_Height;
+
+luaxport:
+
+ LUAX_DECL_FACTORY(Canvas, RenderTarget);
+
+ LUAX_DECL_METHOD(_SetSize);
+ LUAX_DECL_METHOD(_Bind);
+ LUAX_DECL_METHOD(_Unbind);
+
+};
+
+///
+/// CanvasΪRenderTexture
+///
+typedef Canvas RenderTexture;
+
+} // Graphics
+} // AsuraEngine
+
+#endif \ No newline at end of file
diff --git a/Source/modules/asura-core/Graphics/Color.cpp b/Source/modules/asura-core/Graphics/Color.cpp
new file mode 100644
index 0000000..5a66291
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/Color.cpp
@@ -0,0 +1,58 @@
+#include "Color.h"
+#include "Color32.h"
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+Color::Color()
+{
+ r = g = b = a = 0;
+}
+
+Color::Color(const Color& c)
+{
+ r = c.r;
+ g = c.g;
+ b = c.b;
+ a = c.a;
+}
+
+Color::Color(float r, float g, float b, float a)
+{
+ this->r = r;
+ this->g = g;
+ this->b = b;
+ this->a = a;
+}
+
+Color::Color(const Color32& c)
+{
+ r = c.r / 255.f;
+ g = c.g / 255.f;
+ b = c.b / 255.f;
+ a = c.a / 255.f;
+}
+
+Color::~Color()
+{
+}
+
+void Color::Set(float r, float g, float b, float a)
+{
+ this->r = r;
+ this->g = g;
+ this->b = b;
+ this->a = a;
+}
+
+//Color Color::operator *(const Color& c)
+//{
+// r *= c.r;
+// g *= c.g;
+// b *= c.b;
+// a *= c.a;
+
+//}
+
+namespace_end
+namespace_end
diff --git a/Source/modules/asura-core/Graphics/Color.h b/Source/modules/asura-core/Graphics/Color.h
new file mode 100644
index 0000000..c81b601
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/Color.h
@@ -0,0 +1,75 @@
+#ifndef _ASURA_ENGINE_COLOR_H_
+#define _ASURA_ENGINE_COLOR_H_
+
+#include <asura-base/Scripting/Scripting.h>
+#include <asura-base/Classes.h>
+
+#include "../CoreConfig.h"
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+class Color32;
+
+///
+/// 淶ɫColor32иIJԡ
+///
+class Color ASURA_FINAL
+ : public Scripting::Portable<Color>
+{
+public:
+
+ static Color Black;
+ static Color White;
+ static Color Red;
+ static Color Green;
+ static Color Blue;
+
+ Color();
+
+ Color(const Color& c);
+
+ Color(float r, float g, float b, float a);
+
+ Color(const Color32& c);
+
+ ~Color();
+
+ Color operator *(const Color& c);
+
+ void Set(float r, float g, float b, float a);
+
+ GET_SET(float, Red, r);
+ GET_SET(float, Green, g);
+ GET_SET(float, Blue, b);
+ GET_SET(float, Alpha, a);
+
+ float r, g, b, a;
+
+luaxport:
+
+ LUAX_DECL_FACTORY(Color);
+
+ LUAX_DECL_METHOD(_ToColor32);
+ LUAX_DECL_METHOD(_SetColor);
+ LUAX_DECL_METHOD(_GetColor);
+ LUAX_DECL_METHOD(_GetR);
+ LUAX_DECL_METHOD(_GetG);
+ LUAX_DECL_METHOD(_GetB);
+ LUAX_DECL_METHOD(_GetA);
+
+ // Ԫ
+ LUAX_DECL_METHOD(___eq); // __eq
+ LUAX_DECL_METHOD(___add); // __add
+ LUAX_DECL_METHOD(___sub); // __sub
+ LUAX_DECL_METHOD(___mul); // __mul
+ LUAX_DECL_METHOD(___div); // __div
+
+};
+
+namespace_end
+namespace_end
+
+namespace AEGraphics = AsuraEngine::Graphics;
+
+#endif \ No newline at end of file
diff --git a/Source/modules/asura-core/Graphics/Color32.cpp b/Source/modules/asura-core/Graphics/Color32.cpp
new file mode 100644
index 0000000..f1f0b74
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/Color32.cpp
@@ -0,0 +1,53 @@
+#include "Color.h"
+#include "Color32.h"
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+#if ASURA_LITTLE_ENDIAN
+// СˣֽڵAlphaڸߵַ
+const uint32 Color32::RMASK = 0x000000ff;
+const uint32 Color32::GMASK = 0x0000ff00;
+const uint32 Color32::BMASK = 0x00ff0000;
+const uint32 Color32::AMASK = 0xff000000;
+#endif
+
+Color32::Color32()
+{
+ r = g = b = a = 0;
+}
+
+Color32::Color32(const Color32& c)
+{
+ r = c.r;
+ g = c.g;
+ b = c.b;
+ a = c.a;
+}
+
+Color32::Color32(const Color& c)
+{
+ r = 255.f * c.r;
+ g = 255.f * c.g;
+ b = 255.f * c.b;
+ a = 255.f * c.a;
+}
+
+Color32::Color32(byte r, byte g, byte b, byte a)
+{
+ this->r = r;
+ this->g = g;
+ this->b = b;
+ this->a = a;
+}
+
+void Color32::Set(const Color32& c32)
+{
+ r = c32.r;
+ g = c32.g;
+ b = c32.b;
+ a = c32.a;
+}
+
+namespace_end
+namespace_end \ No newline at end of file
diff --git a/Source/modules/asura-core/Graphics/Color32.h b/Source/modules/asura-core/Graphics/Color32.h
new file mode 100644
index 0000000..4dbfe2d
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/Color32.h
@@ -0,0 +1,58 @@
+#ifndef _ASURA_ENGINE_COLOR32_H__
+#define _ASURA_ENGINE_COLOR32_H__
+
+#include <asura-base/Classes.h>
+#include <asura-base/Scripting/Scripting.h>
+
+#include "../CoreConfig.h"
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+class Color;
+
+///
+/// 32bitsɫ
+///
+class Color32 ASURA_FINAL
+ : public Scripting::Portable<Color32>
+{
+public:
+
+ static const uint32 RMASK;
+ static const uint32 GMASK;
+ static const uint32 BMASK;
+ static const uint32 AMASK;
+
+ Color32();
+
+ ~Color32();
+
+ Color32(const Color32& c);
+
+ Color32(const Color& c);
+
+ Color32(byte r, byte g, byte b, byte a);
+
+ void Set(const Color32& c32);
+
+ byte r, g, b, a;
+
+luaxport:
+
+ LUAX_DECL_FACTORY(Color32);
+
+ LUAX_DECL_METHOD(_ToColor);
+ LUAX_DECL_METHOD(_SetColor);
+ LUAX_DECL_METHOD(_GetColor);
+ LUAX_DECL_METHOD(_GetRed);
+ LUAX_DECL_METHOD(_GetGreen);
+ LUAX_DECL_METHOD(_GetBlue);
+ LUAX_DECL_METHOD(_GetAlpha);
+
+};
+
+namespace_end
+namespace_end
+
+#endif \ No newline at end of file
diff --git a/Source/modules/asura-core/Graphics/ColorPalette.h b/Source/modules/asura-core/Graphics/ColorPalette.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/ColorPalette.h
diff --git a/Source/modules/asura-core/Graphics/DrawInfo.cpp b/Source/modules/asura-core/Graphics/DrawInfo.cpp
new file mode 100644
index 0000000..c7a6912
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/DrawInfo.cpp
@@ -0,0 +1,10 @@
+#include "DrawInfo.h"
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+
+
+
+namespace_end
+namespace_end
diff --git a/Source/modules/asura-core/Graphics/DrawInfo.h b/Source/modules/asura-core/Graphics/DrawInfo.h
new file mode 100644
index 0000000..0082102
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/DrawInfo.h
@@ -0,0 +1,19 @@
+#ifndef _ASURA_ENGINE_DRAWINFO_H_
+#define _ASURA_ENGINE_DRAWINFO_H_
+
+#include <asura-base/Classes.h>
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+///
+struct DrawInfo
+{
+
+};
+
+
+namespace_end
+namespace_end
+
+#endif \ No newline at end of file
diff --git a/Source/modules/asura-core/Graphics/DrawUtil.cpp b/Source/modules/asura-core/Graphics/DrawUtil.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/DrawUtil.cpp
diff --git a/Source/modules/asura-core/Graphics/DrawUtil.h b/Source/modules/asura-core/Graphics/DrawUtil.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/DrawUtil.h
diff --git a/Source/modules/asura-core/Graphics/GPUBuffer.cpp b/Source/modules/asura-core/Graphics/GPUBuffer.cpp
new file mode 100644
index 0000000..f28b914
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/GPUBuffer.cpp
@@ -0,0 +1,151 @@
+#include "GPUBuffer.h"
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+GPUBuffer::GPUBuffer(BufferType type, BufferUsage usage, BufferDataType dataType, size_t size)
+ : m_Target(GL_ZERO)
+ , m_Buffer(GL_ZERO)
+ , m_Size(0)
+#if ASURA_DEBUG
+ , m_Data(nullptr)
+#endif
+{
+ m_Target = ConvertBufferType(type);
+ m_Usage = ConvertBufferUsage(usage);
+ m_DataType = ConvertBufferDataType(dataType);
+ m_Size = size;
+}
+
+GPUBuffer::~GPUBuffer()
+{
+#if ASURA_DEBUG
+ if (m_Data)
+ free(m_Data);
+#endif
+ glDeleteBuffers(1, &m_Buffer);
+}
+
+GLenum GPUBuffer::ConvertBufferType(BufferType type)
+{
+ switch (type)
+ {
+ case BUFFER_TYPE_VERTEX:
+ return GL_ARRAY_BUFFER;
+ case BUFFER_TYPE_INDEX:
+ return GL_ELEMENT_ARRAY_BUFFER;
+ }
+}
+
+GLenum GPUBuffer::ConvertBufferUsage(BufferUsage usage)
+{
+ switch (usage)
+ {
+ case BUFFER_USAGE_STREAM:
+ return GL_STREAM_DRAW;
+ case BUFFER_USAGE_DYNAMIC:
+ return GL_DYNAMIC_DRAW;
+ case BUFFER_USAGE_STATIC:
+ return GL_STATIC_DRAW;
+ }
+}
+
+GLenum GPUBuffer::ConvertBufferDataType(BufferDataType type)
+{
+ switch (type)
+ {
+ case BUFFER_DATA_TYPE_INT:
+ return GL_INT;
+ case BUFFER_DATA_TYPE_FLOAT:
+ return GL_FLOAT;
+ case BUFFER_DATA_TYPE_UNSIGNED_BYTE:
+ return GL_UNSIGNED_BYTE;
+ }
+}
+
+bool GPUBuffer::Fill(const void * data, size_t size, uint offset)
+{
+ if (data == nullptr)
+ return false;
+ if (m_Buffer == 0)
+ {
+ g_Device.WipeError();
+ glGenBuffers(1, &m_Buffer);
+ if (m_Buffer == 0)
+ throw Exception("OpenGL glGenBuffers failed.");
+ glBindBuffer(m_Target, m_Buffer);
+ glBufferData(m_Target, m_Size, NULL, m_Usage);
+ if (g_Device.HasError())
+ {
+ glBindBuffer(m_Target, 0);
+ throw Exception("OpenGL glBufferData failed. Errorcode=%d.", g_Device.GetError());
+ }
+#if ASURA_DEBUG
+ m_Data = (byte*)malloc(size);
+ memset(m_Data, 0, size);
+#endif
+ }
+ else
+ glBindBuffer(m_Target, m_Buffer);
+ glBufferSubData(m_Target, offset, size, data);
+ if (g_Device.HasError())
+ {
+ glBindBuffer(m_Target, 0);
+ throw Exception("OpenGL glBufferSubData failed. Errorcode=%d.", g_Device.GetError());
+ }
+ glBindBuffer(m_Target, 0);
+#if ASURA_DEBUG
+ memcpy(m_Data + offset, data, size);
+#endif
+ return true;
+}
+
+void GPUBuffer::Bind()
+{
+ glBindBuffer(m_Target, m_Buffer);
+}
+
+void GPUBuffer::UnBind()
+{
+ glBindBuffer(m_Target, 0);
+}
+
+uint GPUBuffer::GetBufferSize()
+{
+ return m_Size;
+}
+
+GLenum GPUBuffer::GetDataType()
+{
+ return m_DataType;
+}
+
+size_t GPUBuffer::GetDataTypeSize()
+{
+ //https://blog.csdn.net/nklinux/article/details/16919017
+ switch (m_DataType)
+ {
+ case GL_UNSIGNED_BYTE:
+ return sizeof(GLbyte);
+ case GL_FLOAT :
+ return sizeof(GLfloat);
+ case GL_INT:
+ return sizeof(GLint);
+ }
+}
+
+size_t GPUBuffer::GetDataTypeSize(GLenum datatype)
+{
+ switch (datatype)
+ {
+ case GL_UNSIGNED_BYTE:
+ return sizeof(GLbyte);
+ case GL_FLOAT:
+ return sizeof(GLfloat);
+ case GL_INT:
+ return sizeof(GLint);
+ }
+}
+
+namespace_end
+namespace_end \ No newline at end of file
diff --git a/Source/modules/asura-core/Graphics/GPUBuffer.h b/Source/modules/asura-core/Graphics/GPUBuffer.h
new file mode 100644
index 0000000..565db17
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/GPUBuffer.h
@@ -0,0 +1,93 @@
+#ifndef _ASURA_GPU_BUFFER_H_
+#define _ASURA_GPU_BUFFER_H_
+
+#include <asura-base/Scripting/Scripting.h>
+#include <asura-base/Exception.h>
+#include <asura-base/type.h>
+
+#include "GfxDevice.h"
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+enum BufferType
+{
+ BUFFER_TYPE_VERTEX, ///< 㻺壬position\tangent\normal\color\texcoord(n)
+ BUFFER_TYPE_INDEX, ///<
+};
+
+enum BufferUsage
+{
+ BUFFER_USAGE_STREAM, ///< ޸һΣʹô
+ BUFFER_USAGE_DYNAMIC, ///< ޸һΣʹ
+ BUFFER_USAGE_STATIC, ///< ޸ĺʹ
+};
+
+enum BufferDataType
+{
+ BUFFER_DATA_TYPE_INT,
+ BUFFER_DATA_TYPE_FLOAT,
+ BUFFER_DATA_TYPE_UNSIGNED_BYTE,
+};
+
+///
+/// VRAM壬ֶ㻺vboebo֣ÿζڴԴϴݡframeworkrenderersй
+///
+ASURA_ABSTRACT class GPUBuffer
+{
+public:
+
+ GPUBuffer(BufferType type, BufferUsage usage, BufferDataType datatype, size_t size);
+ virtual ~GPUBuffer();
+
+ static size_t GetDataTypeSize(GLenum datatype);
+
+ bool Fill(const void* data, size_t size, uint offset = 0) ASURA_THROW(Exception);
+
+ void Bind();
+ void UnBind();
+
+ uint GetBufferSize();
+ uint GetBufferCount();
+ GLenum GetDataType();
+ size_t GetDataTypeSize();
+
+private:
+
+ GLenum ConvertBufferType(BufferType type);
+ GLenum ConvertBufferUsage(BufferUsage type);
+ GLenum ConvertBufferDataType(BufferDataType type);
+
+ GLenum m_Target;
+ GLuint m_Buffer;
+
+ /// openglԴ滺岢ûж͵ҪֻglVertexAttribPointerʱָdrawcall ʱݸ
+ /// ʼַʹbufferȡඥݣԲͬͿԱһbufferСΪ˱ֽӿڵļ࣬
+ /// ʼbufferʱָͣڱ͵һ£Բͬͷͬbuffer
+
+ GLenum m_DataType;
+ GLuint m_Usage;
+ uint m_Size;
+
+#if ASURA_DEBUG
+ byte* m_Data;
+#endif
+
+luaxport:
+
+ LUAX_DECL_ABSTRACT_FACTORY(GPUBuffer);
+
+ LUAX_DECL_ENUM(BufferType, 1);
+ LUAX_DECL_ENUM(BufferUsage, 1);
+ LUAX_DECL_ENUM(BufferDataType, 2);
+
+ LUAX_DECL_METHOD(_Fill);
+ LUAX_DECL_METHOD(_GetSize);
+ LUAX_DECL_METHOD(_GetCount);
+
+};
+
+namespace_end
+namespace_end
+
+#endif \ No newline at end of file
diff --git a/Source/modules/asura-core/Graphics/GfxDevice.cpp b/Source/modules/asura-core/Graphics/GfxDevice.cpp
new file mode 100644
index 0000000..529a76c
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/GfxDevice.cpp
@@ -0,0 +1,188 @@
+#include <asura-base/type.h>
+
+#include "../CoreConfig.h"
+
+#include "GfxDevice.h"
+#include "Shader.h"
+#include "MatrixStack.h"
+#include "Color.h"
+
+using namespace AEMath;
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+#if ASURA_DEBUG
+static bool instantiated = false;
+#endif
+
+GfxDevice g_Device;
+
+GfxDevice::GfxDevice()
+{
+#if ASURA_DEBUG
+ ASSERT(!instantiated);
+ instantiated = true;
+#endif
+}
+
+GfxDevice::~GfxDevice()
+{
+}
+
+GfxDevice& GfxDevice::Get()
+{
+ return g_Device;
+}
+
+static bool inited = false;
+
+bool GfxDevice::Init(const AEMath::Recti& view)
+{
+ bool loaded = false;
+#if ASURA_OPENGL_LOADER & ASURA_OPENGL_GLAD
+ if (!loaded)
+ loaded = gladLoadGL();
+#endif
+ if (!loaded)
+ return false;
+ SetViewport(view);
+
+ inited = true;
+ return true;
+}
+
+bool GfxDevice::Inited()
+{
+ return inited;
+}
+
+void GfxDevice::WipeError()
+{
+ while (glGetError() != GL_NO_ERROR);
+}
+
+bool GfxDevice::HasError()
+{
+ return glGetError() != GL_NO_ERROR;
+}
+
+GLenum GfxDevice::GetError()
+{
+ return glGetError();
+}
+
+void GfxDevice::SetDrawColor(float r, float g, float b, float a)
+{
+ state.drawColor.Set(r, g, b, a);
+}
+
+Color& GfxDevice::GetDrawColor()
+{
+ return state.drawColor;
+}
+
+void GfxDevice::SetViewport(const Recti v)
+{
+ state.viewport = v;
+ glViewport(v.x, v.y, v.w, v.h);
+}
+
+const Recti& GfxDevice::GetViewport()
+{
+ return state.viewport;
+}
+
+void GfxDevice::SetActiveShader(Shader* shader)
+{
+ if (state.shader == shader)
+ return;
+ if (state.shader)
+ state.shader->OnDisable();
+ state.shader = shader;
+ if (shader)
+ {
+ GLint program = shader->GetGLProgram();
+ glUseProgram(program);
+#if ASURA_GL_PROFILE
+ ++stats.shaderSwitch;
+#endif
+ shader->OnEnable();
+ }
+}
+
+Shader* GfxDevice::GetActiveShader() const
+{
+ return state.shader;
+}
+
+void GfxDevice::DrawArrays(GLenum mode, GLint first, GLsizei count)
+{
+ glDrawArrays(mode, first, count);
+#if ASURA_GL_PROFILE
+ ++stats.drawCall;
+#endif
+ if (state.shader)
+ state.shader->OnUsed();
+}
+
+void GfxDevice::PushMatrix ()
+{
+ state.matrix[state.matrixMode].Push ();
+}
+
+void GfxDevice::PopMatrix ()
+{
+ state.matrix[state.matrixMode].Pop();
+}
+
+void GfxDevice::LoadIdentity()
+{
+ state.matrix[state.matrixMode].LoadIdentity();
+}
+
+void GfxDevice::Rotate (float angle)
+{
+ state.matrix[state.matrixMode].Rotate(angle);
+}
+
+void GfxDevice::Translate (float x, float y)
+{
+ state.matrix[state.matrixMode].Translate(x, y);
+}
+
+void GfxDevice::Scale (float x, float y)
+{
+ state.matrix[state.matrixMode].Scale(x, y);
+}
+
+void GfxDevice::Ortho(float l, float r, float b, float t, float n, float f)
+{
+ state.matrix[state.matrixMode].Ortho(l, r, b, t, n, f);
+}
+
+AEMath::Matrix44& GfxDevice::GetMatrix(MatrixMode mode)
+{
+ return state.matrix[mode].GetTop();
+}
+
+AEMath::Matrix44 GfxDevice::GetMVPMatrix()
+{
+ return state.matrix[MATRIX_MODE_PROJECTION].GetTop()
+ * state.matrix[MATRIX_MODE_VIEW].GetTop()
+ * state.matrix[MATRIX_MODE_MODEL].GetTop();
+}
+
+uint GfxDevice::GetMatrixDepth()
+{
+ return state.matrix[state.matrixMode].GetCapacity();
+}
+
+uint GfxDevice::GetMatrixIndex()
+{
+ return state.matrix[state.matrixMode].GetTopIndex();
+}
+
+
+namespace_end
+namespace_end \ No newline at end of file
diff --git a/Source/modules/asura-core/Graphics/GfxDevice.h b/Source/modules/asura-core/Graphics/GfxDevice.h
new file mode 100644
index 0000000..2b105df
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/GfxDevice.h
@@ -0,0 +1,141 @@
+#ifndef _ASURA_ENGINE_GFX_DEVICE_H_
+#define _ASURA_ENGINE_GFX_DEVICE_H_
+
+#include <stack>
+
+#include <glad/glad.h>
+
+#include <asura-base/Scripting/Scripting.h>
+#include <asura-base/Math/Rect.hpp>
+#include <asura-base/Math/matrix44.h>
+#include <asura-base/Math/vector4.h>
+
+#include "Color.h"
+#include "MatrixStack.h"
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+class Profiler;
+class Shader;
+class GPUBuffer;
+class Canvas;
+
+enum MatrixMode
+{
+ MATRIX_MODE_PROJECTION = 0,
+ MATRIX_MODE_MODEL = 1,
+ MATRIX_MODE_VIEW = 2,
+};
+
+enum GLParams
+{
+ GL_PARAM_MAX_TEXTURE_UNIT = 1,
+};
+
+class GfxDevice : public AEScripting::Portable<GfxDevice>
+{
+public:
+
+ GfxDevice();
+ ~GfxDevice();
+
+ static GfxDevice& Get();
+
+ int GetParam(GLParams param);
+
+ bool Init(const AEMath::Recti& viewport);
+ bool Inited();
+
+ void SetViewport(const AEMath::Recti viewport);
+
+ const AEMath::Recti& GetViewport();
+
+ void PushMatrix();
+ void PopMatrix();
+
+ void LoadIdentity();
+ void Rotate(float angle);
+ void Translate(float x, float y);
+ void Scale(float x, float y);
+ void Ortho(float l, float r, float b, float t, float n, float f);
+
+ uint GetMatrixDepth();
+ uint GetMatrixIndex();
+
+ void DrawArrays(GLenum mode, GLint first, GLsizei count);
+
+ AEMath::Matrix44& GetMatrix(MatrixMode mode);
+ AEMath::Matrix44 GetMVPMatrix();
+
+ void SetDrawColor(float r, float g, float b, float a);
+ Color& GetDrawColor();
+
+ void SetActiveShader(Shader* = NULL);
+ Shader* GetActiveShader() const;
+
+ void WipeError();
+ bool HasError();
+ GLenum GetError();
+
+ GET_SET(MatrixMode, MatrixMode, state.matrixMode);
+ GET_SET(Canvas*, ActiveCanvas, state.canvas);
+
+private:
+
+ friend class Profiler;
+
+ struct
+ {
+ AEMath::Recti viewport; ///< ǰлHDC߱ڴСı߲ˢʱ䶯
+ MatrixStack matrix[3]; ///< model, view, projection
+ MatrixMode matrixMode; ///< ǰľ
+ Color drawColor; ///< Ƶɫ
+ Canvas* canvas; ///< ǰcanvas
+ Shader* shader; ///< ǰʹõshader
+ } state;
+
+#if ASURA_GL_PROFILE
+ struct
+ {
+ uint drawCall; ///< ͳdrawcall
+ uint canvasSwitch; ///< лtextureĴ
+ uint shaderSwitch; ///< лshaderĴ
+ } stats;
+#endif
+
+luaxport:
+
+ LUAX_DECL_SINGLETON(GfxDevice);
+
+ LUAX_DECL_ENUM(MatrixMode, 1);
+ LUAX_DECL_ENUM(GLParams, 1);
+
+ LUAX_DECL_METHOD(_SetMatrixMode);
+ LUAX_DECL_METHOD(_GetMatrixMode);
+ LUAX_DECL_METHOD(_PushMatrix);
+ LUAX_DECL_METHOD(_PopMatrix);
+ LUAX_DECL_METHOD(_LoadIdentity);
+ LUAX_DECL_METHOD(_Rotate);
+ LUAX_DECL_METHOD(_Translate);
+ LUAX_DECL_METHOD(_Scale);
+ LUAX_DECL_METHOD(_Ortho);
+ LUAX_DECL_METHOD(_GetMatrixDepth);
+ LUAX_DECL_METHOD(_GetMatrixIndex);
+ LUAX_DECL_METHOD(_UseShader);
+ LUAX_DECL_METHOD(_UnuseShader);
+
+};
+
+extern GfxDevice g_Device;
+
+
+#define GL_CALL(x) do { x; /*GLAssert(); */} while(0)
+
+
+
+
+namespace_end
+namespace_end
+
+#endif \ No newline at end of file
diff --git a/Source/modules/asura-core/Graphics/GraphicsHelper.cpp b/Source/modules/asura-core/Graphics/GraphicsHelper.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/GraphicsHelper.cpp
diff --git a/Source/modules/asura-core/Graphics/GraphicsHelper.h b/Source/modules/asura-core/Graphics/GraphicsHelper.h
new file mode 100644
index 0000000..3125292
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/GraphicsHelper.h
@@ -0,0 +1,15 @@
+#ifndef _ASURA_GRAPHICS_HELPER_H_
+#define _ASURA_GRAPHICS_HELPER_H_
+
+#include <asura-base/Classes.h>
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+
+
+
+namespace_end
+namespace_end
+
+#endif
diff --git a/Source/modules/asura-core/Graphics/Image.cpp b/Source/modules/asura-core/Graphics/Image.cpp
new file mode 100644
index 0000000..36d2478
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/Image.cpp
@@ -0,0 +1,103 @@
+#include <asura-base/Exception.h>
+
+#include "../CoreConfig.h"
+
+#include "Shader.h"
+#include "Image.h"
+#include "GfxDevice.h"
+
+using namespace AEFileSystem;
+using namespace AEImage;
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+Image::Image()
+ : m_Width(0)
+ , m_Height(0)
+{
+}
+
+Image::~Image()
+{
+}
+
+bool Image::Load(ImageData* imgData)
+{
+ if (!imgData) return false;
+
+ if (m_TexID == 0)
+ {
+ glGenTextures(1, &m_TexID);
+ if (m_TexID == 0)
+ throw Exception("OpenGL glGenTextures failed.");
+ }
+
+ glBindTexture(GL_TEXTURE_2D, m_TexID);
+ imgData->Lock();
+ int width = imgData->width;
+ int height = imgData->height;
+ TextureFormat tf = ConvertColorFormat(imgData->format);
+ glTexImage2D(
+ GL_TEXTURE_2D
+ , 0
+ , tf.internalformat
+ , width, height
+ , 0
+ , tf.externalformat
+ , tf.type
+ , imgData->pixels
+ );
+
+ m_Width = imgData->width;
+ m_Height = imgData->height;
+ imgData->Unlock();
+ GLenum err = glGetError();
+ if (err != GL_NO_ERROR)
+ throw Exception("OpenGL glTexImage2D cause error, error code=%d", err);
+ glBindTexture(GL_TEXTURE_2D, 0);
+
+ return true;
+}
+
+bool Image::Load(ImageData* imgData, const AEMath::Vector2i& pos)
+{
+ if (!imgData) return false;
+
+ glBindTexture(GL_TEXTURE_2D, m_TexID);
+ imgData->Lock();
+ int width = imgData->width;
+ int height = imgData->height;
+ TextureFormat tf = ConvertColorFormat(imgData->format);
+ glTexSubImage2D(
+ GL_TEXTURE_2D
+ , 0
+ , pos.x
+ , pos.y
+ , imgData->width
+ , imgData->height
+ , tf.externalformat
+ , tf.type
+ , imgData->pixels
+ );
+ imgData->Unlock();
+ GLenum err = glGetError();
+ if (err != GL_NO_ERROR)
+ throw Exception("OpenGL glTexSubImage2D cause error, error code=%d", err);
+ glBindTexture(GL_TEXTURE_2D, 0);
+
+ return true;
+}
+
+uint32 Image::GetWidth()
+{
+ return m_Width;
+}
+
+uint32 Image::GetHeight()
+{
+ return m_Height;
+}
+
+namespace_end
+namespace_end \ No newline at end of file
diff --git a/Source/modules/asura-core/Graphics/Image.h b/Source/modules/asura-core/Graphics/Image.h
new file mode 100644
index 0000000..a76d06f
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/Image.h
@@ -0,0 +1,63 @@
+#ifndef _ASURA_ENGINE_IMAGE_H_
+#define _ASURA_ENGINE_IMAGE_H_
+
+// asura modules
+#include <asura-base/Math/Rect.hpp>
+#include <asura-base/Math/Vector2.hpp>
+#include <asura-base/Scripting/Scripting.h>
+#include <asura-base/FileSystem/Renewable.h>
+#include <asura-base/Utilities/Stringmap.hpp>
+#include <asura-base/Manager.hpp>
+
+// module
+#include "../Image/ImageData.h"
+
+// folder
+#include "Color.h"
+#include "Color32.h"
+#include "RenderState.h"
+#include "GPUBuffer.h"
+#include "Texture.h"
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+class Image ASURA_FINAL : public AEScripting::Portable<Image, Texture>
+{
+public:
+
+ Image();
+ ~Image();
+
+ bool Load(AEImage::ImageData* decodeData);
+ bool Load(AEImage::ImageData* decodeData, const AEMath::Vector2i& pos);
+
+ uint GetWidth();
+ uint GetHeight();
+
+ GPUBuffer* GenGPUBuffer();
+
+private:
+
+ uint32 m_Width, m_Height;
+
+luaxport:
+
+ LUAX_DECL_FACTORY(Image, Texture);
+
+ 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_end
+namespace_end
+
+namespace AEGraphics = AsuraEngine::Graphics;
+
+#endif \ No newline at end of file
diff --git a/Source/modules/asura-core/Graphics/IndexBuffer.cpp b/Source/modules/asura-core/Graphics/IndexBuffer.cpp
new file mode 100644
index 0000000..bb3eea7
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/IndexBuffer.cpp
@@ -0,0 +1,17 @@
+#include "IndexBuffer.h"
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+
+IndexBuffer::IndexBuffer(BufferUsage usage, BufferDataType datatype, size_t size)
+ : GPUBuffer(BUFFER_TYPE_INDEX, usage, datatype, size)
+{
+}
+
+IndexBuffer::~IndexBuffer()
+{
+}
+
+namespace_end
+namespace_end
diff --git a/Source/modules/asura-core/Graphics/IndexBuffer.h b/Source/modules/asura-core/Graphics/IndexBuffer.h
new file mode 100644
index 0000000..b7886b7
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/IndexBuffer.h
@@ -0,0 +1,34 @@
+#ifndef _ASURA_INDEX_BUFFER_H_
+#define _ASURA_INDEX_BUFFER_H_
+
+#include <asura-base/Scripting/Scripting.h>
+
+#include "GPUBuffer.h"
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+///
+///
+///
+class IndexBuffer ASURA_FINAL
+ : public AEScripting::Portable<IndexBuffer>
+ , public GPUBuffer
+{
+public:
+
+ IndexBuffer(BufferUsage usage, BufferDataType datatype, size_t size);
+ ~IndexBuffer();
+
+luaxport:
+
+ LUAX_DECL_FACTORY(IndexBuffer);
+
+ LUAX_DECL_METHOD(_New);
+
+};
+
+namespace_end
+namespace_end
+
+#endif \ No newline at end of file
diff --git a/Source/modules/asura-core/Graphics/MatrixStack.cpp b/Source/modules/asura-core/Graphics/MatrixStack.cpp
new file mode 100644
index 0000000..987d29c
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/MatrixStack.cpp
@@ -0,0 +1,75 @@
+#include "MatrixStack.h"
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+MatrixStack::MatrixStack()
+ : top(0)
+{
+ // ջʼջô˱֤ջԶǿգȡֵ
+ m_Stack[top].SetIdentity();
+}
+
+MatrixStack::~MatrixStack()
+{
+}
+
+void MatrixStack::LoadIdentity()
+{
+ m_Stack[top].SetIdentity();
+}
+
+bool MatrixStack::Push()
+{
+ if (top == ASURA_MAX_MATRIX_STACK_DEPTH - 1)
+ return false;
+ ++top;
+ m_Stack[top] = m_Stack[top - 1];
+ return true;
+}
+
+bool MatrixStack::Pop()
+{
+ if (top == 0)
+ return false;
+ --top;
+ return true;
+}
+
+AEMath::Matrix44& MatrixStack::GetTop()
+{
+ return m_Stack[top];
+}
+
+uint MatrixStack::GetTopIndex()
+{
+ return top;
+}
+
+uint MatrixStack::GetCapacity()
+{
+ return ASURA_MAX_MATRIX_STACK_DEPTH;
+}
+
+void MatrixStack::Ortho(float left, float right, float bottom, float top, float near, float far)
+{
+ m_Stack[this->top].Ortho(left, right, bottom, top, near, far);
+}
+
+void MatrixStack::Rotate(float angle)
+{
+ m_Stack[top].Rotate(angle);
+}
+
+void MatrixStack::Translate(float x, float y)
+{
+ m_Stack[top].Translate(x, y);
+}
+
+void MatrixStack::Scale(float x, float y)
+{
+ m_Stack[top].Scale(x, y);
+}
+
+namespace_end
+namespace_end \ No newline at end of file
diff --git a/Source/modules/asura-core/Graphics/MatrixStack.h b/Source/modules/asura-core/Graphics/MatrixStack.h
new file mode 100644
index 0000000..8dd56bf
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/MatrixStack.h
@@ -0,0 +1,58 @@
+#ifndef _ASURA_MATRIX_STACK_H_
+#define _ASURA_MATRIX_STACK_H_
+
+#include <asura-base/Type.h>
+#include <asura-base/Math/Matrix44.h>
+#include <asura-base/Classes.h>
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+///
+/// ջľȡ
+///
+#define ASURA_MAX_MATRIX_STACK_DEPTH 32 // 2KB
+
+///
+/// ջ״ָ̬֮ǰ״̬ջеһstack[i]ֵstack[0]*..*stack[i-1]
+/// ֵһϵtransform
+///
+/// TODO: template<uint _capacity> MatrixStack
+///
+class MatrixStack
+{
+public:
+
+ MatrixStack();
+ ~MatrixStack();
+
+ void LoadIdentity();
+ bool Push();
+ bool Pop();
+
+ AEMath::Matrix44& GetTop();
+ void GetTop(ASURA_OUT AEMath::Matrix44& mat44);
+
+ void LoadMatrix(const AEMath::Matrix44& mat44);
+ void MultMatrix(const AEMath::Matrix44& mat44);
+
+ void Rotate(float angle);
+ void Translate(float x, float y);
+ void Scale(float x, float y);
+
+ void Ortho(float l, float r, float b, float t, float n, float f);
+
+ uint GetTopIndex();
+ uint GetCapacity();
+
+private:
+
+ AEMath::Matrix44 m_Stack[ASURA_MAX_MATRIX_STACK_DEPTH];
+ uint8 top;
+
+};
+
+namespace_end
+namespace_end
+
+#endif \ No newline at end of file
diff --git a/Source/modules/asura-core/Graphics/Mesh2D.cpp b/Source/modules/asura-core/Graphics/Mesh2D.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/Mesh2D.cpp
diff --git a/Source/modules/asura-core/Graphics/Mesh2D.h b/Source/modules/asura-core/Graphics/Mesh2D.h
new file mode 100644
index 0000000..7a0f62e
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/Mesh2D.h
@@ -0,0 +1,52 @@
+#ifndef _ASURA_ENGINE_MESH2D_H__
+#define _ASURA_ENGINE_MESH2D_H__
+
+// cpp
+#include <vector>
+
+// asura modules
+#include <asura-base/Scripting/Scripting.h>
+#include <asura-base/Math/Vector2.hpp>
+
+// module
+#include "../Mesh/Mesh2dData.h"
+
+// folder
+#include "Color.h"
+#include "VertexBuffer.h"
+#include "IndexBuffer.h"
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+///
+/// 2D meshһЩ㶯
+/// https://en.wikipedia.org/wiki/Polygon_mesh
+///
+class Mesh2D ASURA_FINAL
+ : public Scripting::Portable<Mesh2D>
+{
+public:
+
+ Mesh2D();
+ ~Mesh2D();
+
+ bool Load(AEMesh::Mesh2DData* data);
+
+private:
+
+ VertexBuffer* m_VBO; ///< vertex buffer
+ IndexBuffer* m_IBO; ///< index buffer
+
+luaxport:
+
+ LUAX_DECL_FACTORY(Mesh2D);
+
+ LUAX_DECL_METHOD(_SetVertex);
+
+};
+
+namespace_end
+namespace_end
+
+#endif \ No newline at end of file
diff --git a/Source/modules/asura-core/Graphics/Polygon2D.cpp b/Source/modules/asura-core/Graphics/Polygon2D.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/Polygon2D.cpp
diff --git a/Source/modules/asura-core/Graphics/Polygon2D.h b/Source/modules/asura-core/Graphics/Polygon2D.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/Polygon2D.h
diff --git a/Source/modules/asura-core/Graphics/Quad.cpp b/Source/modules/asura-core/Graphics/Quad.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/Quad.cpp
diff --git a/Source/modules/asura-core/Graphics/Quad.h b/Source/modules/asura-core/Graphics/Quad.h
new file mode 100644
index 0000000..b7dd3d9
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/Quad.h
@@ -0,0 +1 @@
+// Quadrectڣrectǵıƫᣬquadһ
diff --git a/Source/modules/asura-core/Graphics/RenderState.h b/Source/modules/asura-core/Graphics/RenderState.h
new file mode 100644
index 0000000..23804d8
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/RenderState.h
@@ -0,0 +1,47 @@
+#ifndef _ASURA_ENGINE_RENDER_STATE_H_
+#define _ASURA_ENGINE_RENDER_STATE_H_
+
+#include <asura-base/Math/Vector2.hpp>
+#include <asura-base/Math/Transform.h>
+
+#include "BlendMode.h"
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+class Shader;
+
+///
+/// Ⱦǰķʽ
+///
+struct RenderState ASURA_FINAL
+{
+ ///
+ /// Ĭϵrender state
+ ///
+ static RenderState Default;
+
+ RenderState();
+ ~RenderState();
+
+ ///
+ /// λášλúת
+ ///
+ Math::Transform transform;
+
+ ///
+ /// ɫ
+ ///
+ Shader* shader;
+
+ ///
+ /// Ϸʽ
+ ///
+ BlendMode blendMode;
+
+};
+
+namespace_end
+namespace_end
+
+#endif \ No newline at end of file
diff --git a/Source/modules/asura-core/Graphics/RenderTarget.cpp b/Source/modules/asura-core/Graphics/RenderTarget.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/RenderTarget.cpp
diff --git a/Source/modules/asura-core/Graphics/RenderTarget.h b/Source/modules/asura-core/Graphics/RenderTarget.h
new file mode 100644
index 0000000..ab09e35
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/RenderTarget.h
@@ -0,0 +1,52 @@
+#ifndef _ASURA_ENGINE_RENDERTARGET_H_
+#define _ASURA_ENGINE_RENDERTARGET_H_
+
+#include <asura-base/Math/Vector2.hpp>
+#include <asura-base/Math/Rect.hpp>
+#include <asura-base/Scripting/Scripting.h>
+
+#include "Texture.h"
+#include "Color.h"
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+///
+/// ɱΪȾĿ࣬
+/// Canvas(RenderTexture)
+/// Window(RenderWindow)
+///
+class RenderTarget : public AEScripting::Object
+{
+public:
+
+ RenderTarget() {};
+
+ 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;
+
+};
+
+namespace_end
+namespace_end
+
+#endif \ No newline at end of file
diff --git a/Source/modules/asura-core/Graphics/Shader.cpp b/Source/modules/asura-core/Graphics/Shader.cpp
new file mode 100644
index 0000000..329b3f1
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/Shader.cpp
@@ -0,0 +1,282 @@
+#include <asura-base/Exception.h>
+
+#include "GfxDevice.h"
+#include "Shader.h"
+
+using namespace std;
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+// texture unit
+static uint8 texUnit = 0;
+
+Shader::Shader()
+{
+}
+
+Shader::~Shader()
+{
+ if(m_VertShader) glDeleteShader(m_VertShader);
+ if(m_FragShader) glDeleteShader(m_FragShader);
+ if(m_Program) glDeleteProgram(m_Program);
+}
+
+void Shader::SetActive(Shader* shader)
+{
+ g_Device.SetActiveShader(shader);
+}
+
+Shader* Shader::GetActive()
+{
+ return g_Device.GetActiveShader();
+}
+
+bool Shader::Load(const string& vert, const string& frag)
+{
+ string warnning = "";
+
+ if (!m_Program)
+ {
+ m_Program = glCreateProgram();
+ if (!m_Program)
+ throw Exception("Cannot create OpenGL shader program.");
+ }
+
+ if (!CompileVertexShader(vert, warnning))
+ {
+ throw Exception("Compile vertex shader failed:%s", warnning);
+ }
+
+ if (!CompileFragementShader(frag, warnning))
+ {
+ throw Exception("Compile fragment shader failed:%s", warnning);
+ }
+
+ glAttachShader(m_Program, m_VertShader);
+ glAttachShader(m_Program, m_FragShader);
+
+ glLinkProgram(m_Program);
+ GLint success;
+ glGetProgramiv(m_Program, GL_LINK_STATUS, &success);
+ if (success == GL_FALSE)
+ {
+ warnning = GetProgramWarnings();
+ throw Exception("Link shader program failed:\n%s", warnning.c_str());
+ }
+
+ return true;
+}
+
+bool Shader::CompileVertexShader(const string& vert, string& outError)
+{
+ if (!m_VertShader)
+ {
+ m_VertShader = glCreateShader(GL_VERTEX_SHADER);
+ if (!m_VertShader)
+ {
+ outError = "Cannot create OpenGL Vertex shader.";
+ return false;
+ }
+ }
+
+ const GLchar* source = vert.c_str();
+ GLint success;
+
+ glShaderSource(m_VertShader, 1, &source, NULL);
+ glCompileShader(m_VertShader);
+ glGetShaderiv(m_VertShader, GL_COMPILE_STATUS, &success);
+ if (success == GL_FALSE)
+ {
+ outError = GetShaderWarnings(m_VertShader);
+ return false;
+ }
+
+ return true;
+}
+
+bool Shader::CompileFragementShader(const string& frag, string& outError)
+{
+ if (!m_FragShader)
+ {
+ m_FragShader = glCreateShader(GL_FRAGMENT_SHADER);
+ if (!m_FragShader)
+ {
+ outError = "Cannot create OpenGL fragment shader.";
+ return false;
+ }
+ }
+
+ const GLchar* source = frag.c_str();
+ GLint success;
+
+ source = frag.c_str();
+ glShaderSource(m_FragShader, 1, &source, NULL);
+ glCompileShader(m_FragShader);
+ glGetShaderiv(m_FragShader, GL_COMPILE_STATUS, &success);
+ if (success == GL_FALSE)
+ {
+ outError = GetShaderWarnings(m_FragShader);
+ return false;
+ }
+
+ return true;
+}
+
+void Shader::OnEnable()
+{
+ texUnit = 0;
+}
+
+void Shader::OnDisable()
+{
+ texUnit = 0;
+}
+
+void Shader::OnUsed()
+{
+ texUnit = 0;
+}
+
+uint Shader::GetUniformLocation(const std::string& uniform)
+{
+ GLint loc = glGetUniformLocation(m_Program, uniform.c_str());
+ return loc;
+}
+
+bool Shader::HasUniform(const std::string& uniform)
+{
+ GLint loc = glGetUniformLocation(m_Program, uniform.c_str());
+ return loc != -1;
+}
+
+GLuint Shader::GetGLProgram()
+{
+ return m_Program;
+}
+
+void Shader::SetUniformFloat(uint loc, float value)
+{
+ if(g_Device.GetActiveShader() == this)
+ glUniform1f(loc, value);
+}
+
+bool Shader::SetUniformTexture(uint loc, const Texture& texture)
+{
+ if (g_Device.GetActiveShader() != this)
+ return false;
+
+ g_Device.WipeError();
+ glActiveTexture(GL_TEXTURE0 + texUnit);
+ if (g_Device.HasError())
+ return false;
+ GLint tex = texture.GetGLTexture();
+ glBindTexture(GL_TEXTURE_2D, tex);
+ if (g_Device.HasError())
+ return false;
+ glUniform1i(loc, texUnit);
+ if (g_Device.HasError())
+ return false;
+ ++texUnit;
+}
+
+void Shader::SetUniformVector2(uint loc, const Math::Vector2f& vec2)
+{
+ if (g_Device.GetActiveShader() == this)
+ glUniform2f(loc, vec2.x, vec2.y);
+}
+
+void Shader::SetUniformVector3(uint loc, const Math::Vector3f& vec3)
+{
+ if (g_Device.GetActiveShader() == this)
+ glUniform3f(loc, vec3.x, vec3.y, vec3.z);
+}
+
+void Shader::SetUniformVector4(uint loc, const Math::Vector4f& vec4)
+{
+ if (g_Device.GetActiveShader() == this)
+ glUniform4f(loc, vec4.x, vec4.y, vec4.z, vec4.w);
+}
+
+void Shader::SetUniformMatrix44(uint loc, const Math::Matrix44& mat)
+{
+ if (g_Device.GetActiveShader() == this)
+ glUniformMatrix4fv(loc, 1, GL_FALSE, mat.GetElements());
+}
+
+void Shader::SetUniformColor(uint loc, const Color& color)
+{
+ if (g_Device.GetActiveShader() == this)
+ glUniform4f(loc, color.r, color.g, color.b, color.a);
+}
+
+uint Shader::GetGLTextureUnitCount()
+{
+ GLint maxTextureUnits;
+ glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &maxTextureUnits);
+ return (uint)maxTextureUnits;
+}
+
+std::string Shader::GetProgramWarnings()
+{
+ GLint strsize, nullpos;
+ glGetProgramiv(m_Program, GL_INFO_LOG_LENGTH, &strsize);
+
+ if (strsize == 0)
+ return "";
+
+ char *tempstr = new char[strsize];
+
+ memset(tempstr, '\0', strsize);
+ glGetProgramInfoLog(m_Program, strsize, &nullpos, tempstr);
+ tempstr[nullpos] = '\0';
+
+ std::string warnings(tempstr);
+ delete[] tempstr;
+
+ return warnings;
+}
+
+std::string Shader::GetShaderWarnings(GLuint shader)
+{
+ GLint strsize, nullpos;
+ glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &strsize);
+
+ if (strsize == 0)
+ return "";
+
+ char *tempstr = new char[strsize];
+
+ memset(tempstr, '\0', strsize);
+ glGetShaderInfoLog(shader, strsize, &nullpos, tempstr);
+ tempstr[nullpos] = '\0';
+
+ std::string warnings(tempstr);
+ delete[] tempstr;
+
+ return warnings;
+}
+
+void Shader::SetAttribute(int loc, VertexBuffer* vbo, uint offseti, uint stridei, bool normalized)
+{
+ GLsizei offset = offseti * vbo->GetDataTypeSize();
+ GLsizei stride = stridei * vbo->GetDataTypeSize();
+ glEnableVertexAttribArray(loc);
+ vbo->Bind();
+ glVertexAttribPointer(loc, 2, vbo->GetDataType(), normalized, stride, (GLvoid*)offset);
+ vbo->UnBind();
+}
+
+int Shader::GetAttributeLocation(const std::string& attribute)
+{
+ int loc = glGetAttribLocation(m_Program, attribute.c_str());
+ return loc;
+}
+
+void Shader::DisableAttribute(int loc)
+{
+ glDisableVertexAttribArray(loc);
+}
+
+namespace_end
+namespace_end \ No newline at end of file
diff --git a/Source/modules/asura-core/Graphics/Shader.h b/Source/modules/asura-core/Graphics/Shader.h
new file mode 100644
index 0000000..615b028
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/Shader.h
@@ -0,0 +1,117 @@
+#ifndef _ASURA_ENGINE_SHADER_H_
+#define _ASURA_ENGINE_SHADER_H_
+
+#include <map>
+#include <string>
+
+#include <asura-base/Exception.h>
+#include <asura-base/Scripting/Scripting.h>
+#include <asura-base/FileSystem/Renewable.h>
+#include <asura-base/Math/Vector2.hpp>
+#include <asura-base/Math/vector3.hpp>
+#include <asura-base/Math/vector4.h>
+#include <asura-base/Math/matrix44.h>
+#include <asura-base/Utilities/Stringmap.hpp>
+#include <asura-base/Manager.hpp>
+
+#include "GfxDevice.h"
+#include "Color.h"
+#include "Texture.h"
+#include "VertexBuffer.h"
+#include "IndexBuffer.h"
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+///
+/// һshaderһڲʼ乲ijShaderuniformsͶݣֻṩ uniformsuseɫ
+/// ķ༭ÿshaderͨshaderҵuniforms¶frameworkmaterial
+/// á
+///
+class Shader ASURA_FINAL
+ : public Scripting::Portable<Shader>
+ , public AEFileSystem::Renewable
+{
+public:
+
+ Shader();
+
+ ~Shader();
+
+ static void SetActive(Shader* shader);
+ static Shader* GetActive();
+
+ bool Load(const std::string& vert, const std::string& frag) ASURA_THROW(Exception);
+
+ // ʹSetActiveлshaderʱ
+ void OnEnable();
+ void OnDisable();
+ // Draw call֮
+ void OnUsed();
+
+ void SetAttribute(int loc, VertexBuffer* vbo, uint offseti = 0, uint stridei = 0, bool normalized = false);
+ int GetAttributeLocation(const std::string& attribute);
+ void DisableAttribute(int loc);
+
+ bool HasUniform(const std::string& uniform);
+ uint GetUniformLocation(const std::string& uniform);
+ void SetUniformFloat(uint loc, float value);
+ 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);
+ bool SetUniformTexture(uint loc, const Texture& texture);
+
+ float GetUniformFloat(uint loc);
+ AEMath::Vector2f GetUniformVector2(uint loc);
+ AEMath::Vector3f GetUniformVector3(uint loc);
+ AEMath::Vector4f GetUniformVector4s(uint loc);
+ AEMath::Matrix44 GetUniformMatrix44(uint loc);
+
+ GLuint GetGLProgram();
+
+ static uint GetGLTextureUnitCount();
+
+private:
+
+ bool CompileVertexShader(const std::string& vert, std::string& outError);
+ bool CompileFragementShader(const std::string& frag, std::string& outError);
+
+ std::string GetProgramWarnings();
+ std::string GetShaderWarnings(GLuint shader);
+
+ GLuint m_Program;
+ GLuint m_VertShader;
+ GLuint m_FragShader;
+
+luaxport:
+
+ LUAX_DECL_FACTORY(Shader);
+
+ LUAX_DECL_METHOD(_New);
+ LUAX_DECL_METHOD(_Load);
+ LUAX_DECL_METHOD(_Update);
+ LUAX_DECL_METHOD(_HasUniform);
+ LUAX_DECL_METHOD(_GetUniformLocation);
+ LUAX_DECL_METHOD(_SetUniformFloat);
+ LUAX_DECL_METHOD(_SetUniformTexture);
+ LUAX_DECL_METHOD(_SetUniformVector2);
+ LUAX_DECL_METHOD(_SetUniformVector3);
+ LUAX_DECL_METHOD(_SetUniformVector4);
+ LUAX_DECL_METHOD(_SetUniformColor);
+
+ LUAX_DECL_METHOD(_GetAttributeLocation);
+ LUAX_DECL_METHOD(_SetAttribute);
+ LUAX_DECL_METHOD(_DisableAttribute);
+
+ LUAX_DECL_METHOD(_SetBuiltInUniforms);
+
+};
+
+typedef Shader GpuProgram;
+
+namespace_end
+namespace_end
+
+#endif \ No newline at end of file
diff --git a/Source/modules/asura-core/Graphics/Shape.cpp b/Source/modules/asura-core/Graphics/Shape.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/Shape.cpp
diff --git a/Source/modules/asura-core/Graphics/Shape.h b/Source/modules/asura-core/Graphics/Shape.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/Shape.h
diff --git a/Source/modules/asura-core/Graphics/SpriteBatch.cpp b/Source/modules/asura-core/Graphics/SpriteBatch.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/SpriteBatch.cpp
diff --git a/Source/modules/asura-core/Graphics/SpriteBatch.h b/Source/modules/asura-core/Graphics/SpriteBatch.h
new file mode 100644
index 0000000..30cb56c
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/SpriteBatch.h
@@ -0,0 +1,34 @@
+#ifndef _ASURA_ENGINE_SPRITE_BATCH_H_
+#define _ASURA_ENGINE_SPRITE_BATCH_H_
+
+#include <asura-base/Scripting/Scripting.h>
+
+#include "GPUBuffer.h"
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+///
+/// Sprite batchȾͼƬĵطϵͳ
+///
+class SpriteBatch ASURA_FINAL
+ : public Scripting::Portable<SpriteBatch>
+{
+public:
+
+ SpriteBatch();
+
+ ~SpriteBatch();
+
+private:
+
+luaxport:
+
+ LUAX_DECL_FACTORY(SpriteBatch);
+
+};
+
+namespace_end
+namespace_end
+
+#endif \ No newline at end of file
diff --git a/Source/modules/asura-core/Graphics/Texture.cpp b/Source/modules/asura-core/Graphics/Texture.cpp
new file mode 100644
index 0000000..03f005d
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/Texture.cpp
@@ -0,0 +1,47 @@
+#include <asura-base/Exception.h>
+
+#include "Texture.h"
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+Texture::Texture()
+ : m_TexID(0)
+{
+}
+
+Texture::~Texture()
+{
+ // ͷԴ
+ if(m_TexID != 0)
+ glDeleteTextures(1, &m_TexID);
+}
+
+GLuint Texture::GetGLTexture() const
+{
+ return m_TexID;
+}
+
+TextureFormat Texture::ConvertColorFormat(const ColorFormat& colorformat)
+{
+ TextureFormat t;
+ switch (colorformat)
+ {
+ case COLOR_FORMAT_RGBA8:
+ t.internalformat = GL_RGBA8; // 4*sizeof(byte) ~= 4 bytes
+ t.externalformat = GL_RGBA;
+ t.type = GL_UNSIGNED_BYTE;
+ break;
+ case COLOR_FORMAT_RGBA32F:
+ t.internalformat = GL_RGBA32F; // 4*sizeof(float) = 16 bytes
+ t.externalformat = GL_RGBA;
+ t.type = GL_FLOAT;
+ break;
+ default:
+ ASSERT(false);
+ }
+ return t;
+}
+
+namespace_end
+namespace_end \ No newline at end of file
diff --git a/Source/modules/asura-core/Graphics/Texture.h b/Source/modules/asura-core/Graphics/Texture.h
new file mode 100644
index 0000000..76b9a8f
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/Texture.h
@@ -0,0 +1,101 @@
+#ifndef _ASURA_TEXTURE_H_
+#define _ASURA_TEXTURE_H_
+
+#include <asura-base/Math/Vector2.hpp>
+#include <asura-base/Math/Rect.hpp>
+
+#include "../CoreConfig.h"
+
+#include "RenderState.h"
+#include "GfxDevice.h"
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+class RenderTarget;
+
+/// UVʽ
+enum WrapMode
+{
+ WRAP_MODE_REPEAT,
+ WRAP_MODE_MIRROR,
+ WRAP_MODE_CLAMPTOEDGE,
+ WRAP_MODE_CLAMPTOBORDER,
+};
+
+/// ˲ģʽ
+enum FilterMode
+{
+ FILTER_MODE_NEAREST,
+ FILTER_MODE_LINEAR,
+};
+
+/// ͼݵɫʽ
+enum ColorFormat
+{
+ COLOR_FORMAT_UNKNOWN,
+ COLOR_FORMAT_RGBA8, ///< RGBA8bits int
+ COLOR_FORMAT_RGBA32F, ///< RGBA32bits float
+};
+
+/// ʽGPUڲCPUⲿʽ
+struct TextureFormat
+{
+ GLenum internalformat; ///< GPUڲʽ
+ GLenum externalformat; ///< CPUⲿʽ
+ GLenum type; ///< ⲿʽÿchannelֵ
+};
+
+///
+/// 2D࣬2d meshrender targetбʹáTextureȾԭϽǣϷϲԵѿ
+/// ϵΪ׼EditorҲϽΪԭ㣬Ϊ˷㡣
+///
+ASURA_ABSTRACT class Texture : public AEScripting::Object
+{
+public:
+
+ LUAX_DECL_ABSTRACT_FACTORY(Texture);
+
+ Texture();
+ virtual ~Texture();
+
+ GLuint GetGLTexture() const;
+
+ void SetFilterMode(FilterMode min, FilterMode mag);
+ void SetWrapMode(WrapMode wrapMode);
+
+ void GetFilterMode();
+ void GetWrapMode();
+
+ /// UVfilterΪ
+ bool IsGenMipmap();
+
+protected:
+
+ /// תcolor formatΪtexture format
+ TextureFormat ConvertColorFormat(const ColorFormat& colorformat);
+
+ GLuint m_TexID;
+ FilterMode m_MinFilter;
+ FilterMode m_MagFilter;
+ WrapMode m_WrapMode;
+ bool m_IsGenMipmap;
+
+ LUAX_DECL_ENUM(ColorFormat, 1);
+ LUAX_DECL_ENUM(FilterMode, 1);
+ LUAX_DECL_ENUM(WrapMode, 1);
+
+ LUAX_DECL_METHOD(_SetFilterMode);
+ LUAX_DECL_METHOD(_SetWrapMode);
+ LUAX_DECL_METHOD(_GetFilterMode);
+ LUAX_DECL_METHOD(_GetWrapMode);
+ LUAX_DECL_METHOD(_IsGenMipmap);
+
+};
+
+typedef Texture Drawable;
+
+namespace_end
+namespace_end
+
+#endif \ No newline at end of file
diff --git a/Source/modules/asura-core/Graphics/VBO.cpp b/Source/modules/asura-core/Graphics/VBO.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/VBO.cpp
diff --git a/Source/modules/asura-core/Graphics/VBO.h b/Source/modules/asura-core/Graphics/VBO.h
new file mode 100644
index 0000000..f80991e
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/VBO.h
@@ -0,0 +1,27 @@
+#ifndef _ASURA_ENGINE_VBO_H_
+#define _ASURA_ENGINE_VBO_H_
+
+#include <asura-base/Classes.h>
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+struct VertexBufferData
+{
+
+};
+
+struct IndexBufferData
+{
+
+};
+
+class VBO
+{
+
+};
+
+namespace_end
+namespace_end
+
+#endif \ No newline at end of file
diff --git a/Source/modules/asura-core/Graphics/VertexBuffer.cpp b/Source/modules/asura-core/Graphics/VertexBuffer.cpp
new file mode 100644
index 0000000..c44e9be
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/VertexBuffer.cpp
@@ -0,0 +1,16 @@
+#include "VertexBuffer.h"
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+VertexBuffer::VertexBuffer(BufferUsage usage, BufferDataType datatype, size_t size)
+ : GPUBuffer(BUFFER_TYPE_VERTEX, usage, datatype, size)
+{
+}
+
+VertexBuffer::~VertexBuffer()
+{
+}
+
+namespace_end
+namespace_end
diff --git a/Source/modules/asura-core/Graphics/VertexBuffer.h b/Source/modules/asura-core/Graphics/VertexBuffer.h
new file mode 100644
index 0000000..0622388
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/VertexBuffer.h
@@ -0,0 +1,34 @@
+#ifndef _ASURA_VERTEX_BUFFER_H_
+#define _ASURA_VERTEX_BUFFER_H_
+
+#include <asura-base/Scripting/Scripting.h>
+
+#include "GPUBuffer.h"
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+///
+/// frameworkṩ˴Դ滺Ĺܣֱû壬ֱܶͨöݡ
+///
+class VertexBuffer ASURA_FINAL
+ : public AEScripting::Portable<VertexBuffer>
+ , public GPUBuffer
+{
+public:
+
+ VertexBuffer(BufferUsage usage, BufferDataType datatype, size_t size);
+ ~VertexBuffer();
+
+luaxport:
+
+ LUAX_DECL_FACTORY(VertexBuffer);
+
+ LUAX_DECL_METHOD(_New);
+
+};
+
+namespace_end
+namespace_end
+
+#endif \ No newline at end of file
diff --git a/Source/modules/asura-core/Graphics/binding/_canvas.cpp b/Source/modules/asura-core/Graphics/binding/_canvas.cpp
new file mode 100644
index 0000000..44841f5
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/binding/_canvas.cpp
@@ -0,0 +1,48 @@
+#include "../Canvas.h"
+
+using namespace std;
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+
+ LUAX_REGISTRY(Canvas)
+ {
+ LUAX_REGISTER_METHODS(state,
+ { "SetSize", _SetSize },
+ { "Bind", _Bind },
+ { "Unbind", _Unbind }
+ );
+ }
+
+ LUAX_POSTPROCESS(Canvas)
+ {
+
+ }
+
+ // canvas:SetSize()
+ LUAX_IMPL_METHOD(Canvas, _SetSize)
+ {
+ LUAX_PREPARE(L, Canvas);
+ return 0;
+
+ }
+
+ // canvas:Bind()
+ LUAX_IMPL_METHOD(Canvas, _Bind)
+ {
+ LUAX_PREPARE(L, Canvas);
+
+ return 0;
+ }
+
+ // canvas:Unbind()
+ LUAX_IMPL_METHOD(Canvas, _Unbind)
+ {
+ LUAX_PREPARE(L, Canvas);
+ return 0;
+
+ }
+
+ }
+}
diff --git a/Source/modules/asura-core/Graphics/binding/_color.cpp b/Source/modules/asura-core/Graphics/binding/_color.cpp
new file mode 100644
index 0000000..008d9c2
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/binding/_color.cpp
@@ -0,0 +1,130 @@
+#include "../Color.h"
+
+using namespace std;
+using namespace Luax;
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+
+LUAX_REGISTRY(Color)
+{
+ LUAX_REGISTER_METHODS(state,
+ { "ToColor32", _ToColor32 },
+ { "SetColor", _SetColor },
+ { "GetColor", _GetColor },
+ { "GetR", _GetR },
+ { "GetG", _GetG },
+ { "GetB", _GetB },
+ { "GetA", _GetA },
+ { "__eq", ___eq },
+ { "__add", ___add },
+ { "__sub", ___sub },
+ { "__mul", ___mul },
+ { "__div", ___div }
+ );
+}
+
+LUAX_POSTPROCESS(Color)
+{
+
+}
+
+// color:ToColor32()
+LUAX_IMPL_METHOD(Color, _ToColor32)
+{
+ LUAX_PREPARE(L, Color);
+
+ return 0;
+}
+
+// color:SetColor()
+LUAX_IMPL_METHOD(Color, _SetColor)
+{
+ LUAX_PREPARE(L, Color);
+
+ return 0;
+}
+
+// color:GetColor()
+LUAX_IMPL_METHOD(Color, _GetColor)
+{
+ LUAX_PREPARE(L, Color);
+
+ return 0;
+}
+
+// color:GetR()
+LUAX_IMPL_METHOD(Color, _GetR)
+{
+ LUAX_PREPARE(L, Color);
+
+ return 0;
+}
+
+// color:GetG()
+LUAX_IMPL_METHOD(Color, _GetG)
+{
+ LUAX_PREPARE(L, Color);
+
+ return 0;
+}
+
+// color:GetB()
+LUAX_IMPL_METHOD(Color, _GetB)
+{
+ LUAX_PREPARE(L, Color);
+
+ return 0;
+}
+
+// color:GetA()
+LUAX_IMPL_METHOD(Color, _GetA)
+{
+ LUAX_PREPARE(L, Color);
+
+ return 0;
+}
+
+// color:__eq()
+LUAX_IMPL_METHOD(Color, ___eq)
+{
+ LUAX_PREPARE(L, Color);
+
+ return 0;
+}
+
+// color:__add()
+LUAX_IMPL_METHOD(Color, ___add)
+{
+ LUAX_PREPARE(L, Color);
+
+ return 0;
+}
+
+// color:__sub()
+LUAX_IMPL_METHOD(Color, ___sub)
+{
+ LUAX_PREPARE(L, Color);
+
+ return 0;
+}
+
+// color:__mul()
+LUAX_IMPL_METHOD(Color, ___mul)
+{
+ LUAX_PREPARE(L, Color);
+
+ return 0;
+}
+
+// color:__div()
+LUAX_IMPL_METHOD(Color, ___div)
+{
+ LUAX_PREPARE(L, Color);
+
+ return 0;
+}
+
+}
+} \ No newline at end of file
diff --git a/Source/modules/asura-core/Graphics/binding/_color32.cpp b/Source/modules/asura-core/Graphics/binding/_color32.cpp
new file mode 100644
index 0000000..7613361
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/binding/_color32.cpp
@@ -0,0 +1,66 @@
+#include "../Color32.h"
+
+using namespace std;
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+
+ LUAX_REGISTRY(Color32)
+ {
+ LUAX_REGISTER_METHODS(state,
+ { "ToColor", _ToColor },
+ { "GetRed", _GetRed },
+ { "GetGreen", _GetGreen },
+ { "GetBlue", _GetBlue },
+ { "GetAlpha", _GetAlpha }
+ );
+ }
+
+ LUAX_POSTPROCESS(Color32)
+ {
+
+ }
+
+ // color32:ToColor()
+ LUAX_IMPL_METHOD(Color32, _ToColor)
+ {
+ LUAX_PREPARE(L, Color32);
+ return 0;
+
+ }
+
+ // color32:GetRed()
+ LUAX_IMPL_METHOD(Color32, _GetRed)
+ {
+ LUAX_PREPARE(L, Color32);
+ return 0;
+ }
+
+ // color32:GetGreen()
+ LUAX_IMPL_METHOD(Color32, _GetGreen)
+ {
+ LUAX_PREPARE(L, Color32);
+
+ return 0;
+ }
+
+ // color32:GetBlue()
+ LUAX_IMPL_METHOD(Color32, _GetBlue)
+ {
+ LUAX_PREPARE(L, Color32);
+
+ return 0;
+ }
+
+ // color32:GetAlpha()
+ LUAX_IMPL_METHOD(Color32, _GetAlpha)
+ {
+ LUAX_PREPARE(L, Color32);
+
+ return 0;
+ }
+
+ }
+}
+ \ No newline at end of file
diff --git a/Source/modules/asura-core/Graphics/binding/_gfx_device.cpp b/Source/modules/asura-core/Graphics/binding/_gfx_device.cpp
new file mode 100644
index 0000000..f6c2004
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/binding/_gfx_device.cpp
@@ -0,0 +1,151 @@
+#include "../GfxDevice.h"
+
+using namespace std;
+using namespace Luax;
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+
+ LUAX_REGISTRY(GfxDevice)
+ {
+ LUAX_REGISTER_METHODS(state,
+ { "SetMatrixMode", _SetMatrixMode },
+ { "GetMatrixMode", _GetMatrixMode },
+ { "PushMatrix", _PushMatrix },
+ { "PopMatrix", _PopMatrix },
+ { "LoadIdentity", _LoadIdentity },
+ { "Rotate", _Rotate },
+ { "Translate", _Translate },
+ { "Scale", _Scale },
+ { "Ortho", _Ortho },
+ { "GetMatrixDepth", _GetMatrixDepth },
+ { "GetMatrixIndex", _GetMatrixIndex },
+ { "UseShader", _UseShader },
+ { "UnuseShader", _UnuseShader }
+ );
+ }
+
+ LUAX_POSTPROCESS(GfxDevice)
+ {
+ LUAX_REGISTER_ENUM(state, "EMatrixMode",
+ { "PROJECTION", MATRIX_MODE_PROJECTION },
+ { "0", 0 },
+ { "MODEL", MATRIX_MODE_MODEL },
+ { "1", 1 },
+ { "VIEW", MATRIX_MODE_VIEW },
+ { "2", 2 }
+ );
+ LUAX_REGISTER_ENUM(state, "EGLParams",
+ { "MAX_TEXTURE_UNIT", GL_PARAM_MAX_TEXTURE_UNIT },
+ { "1", 1 }
+ );
+
+ }
+
+ // gfxdevice:SetMatrixMode()
+ LUAX_IMPL_METHOD(GfxDevice, _SetMatrixMode)
+ {
+ LUAX_PREPARE(L, GfxDevice);
+
+ return 0;
+ }
+
+ // gfxdevice:GetMatrixMode()
+ LUAX_IMPL_METHOD(GfxDevice, _GetMatrixMode)
+ {
+ LUAX_PREPARE(L, GfxDevice);
+
+ return 0;
+ }
+
+ // gfxdevice:PushMatrix()
+ LUAX_IMPL_METHOD(GfxDevice, _PushMatrix)
+ {
+ LUAX_PREPARE(L, GfxDevice);
+
+ return 0;
+ }
+
+ // gfxdevice:PopMatrix()
+ LUAX_IMPL_METHOD(GfxDevice, _PopMatrix)
+ {
+ LUAX_PREPARE(L, GfxDevice);
+
+ return 0;
+ }
+
+ // gfxdevice:LoadIdentity()
+ LUAX_IMPL_METHOD(GfxDevice, _LoadIdentity)
+ {
+ LUAX_PREPARE(L, GfxDevice);
+
+ return 0;
+ }
+
+ // gfxdevice:Rotate()
+ LUAX_IMPL_METHOD(GfxDevice, _Rotate)
+ {
+ LUAX_PREPARE(L, GfxDevice);
+
+ return 0;
+ }
+
+ // gfxdevice:Translate()
+ LUAX_IMPL_METHOD(GfxDevice, _Translate)
+ {
+ LUAX_PREPARE(L, GfxDevice);
+
+ return 0;
+ }
+
+ // gfxdevice:Scale()
+ LUAX_IMPL_METHOD(GfxDevice, _Scale)
+ {
+ LUAX_PREPARE(L, GfxDevice);
+
+ return 0;
+ }
+
+ // gfxdevice:Ortho()
+ LUAX_IMPL_METHOD(GfxDevice, _Ortho)
+ {
+ LUAX_PREPARE(L, GfxDevice);
+
+ return 0;
+ }
+
+ // gfxdevice:GetMatrixDepth()
+ LUAX_IMPL_METHOD(GfxDevice, _GetMatrixDepth)
+ {
+ LUAX_PREPARE(L, GfxDevice);
+
+ return 0;
+ }
+
+ // gfxdevice:GetMatrixIndex()
+ LUAX_IMPL_METHOD(GfxDevice, _GetMatrixIndex)
+ {
+ LUAX_PREPARE(L, GfxDevice);
+
+ return 0;
+ }
+
+ // gfxdevice:UseShader()
+ LUAX_IMPL_METHOD(GfxDevice, _UseShader)
+ {
+ LUAX_PREPARE(L, GfxDevice);
+
+ return 0;
+ }
+
+ // gfxdevice:UnuseShader()
+ LUAX_IMPL_METHOD(GfxDevice, _UnuseShader)
+ {
+ LUAX_PREPARE(L, GfxDevice);
+
+ return 0;
+ }
+
+ }
+}
diff --git a/Source/modules/asura-core/Graphics/binding/_gpu_buffer.cpp b/Source/modules/asura-core/Graphics/binding/_gpu_buffer.cpp
new file mode 100644
index 0000000..8c39a59
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/binding/_gpu_buffer.cpp
@@ -0,0 +1,118 @@
+#include <stdlib.h>
+
+#include "../image.h"
+#include "../GPUBuffer.h"
+
+using namespace std;
+using namespace Luax;
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+
+ LUAX_REGISTRY(GPUBuffer)
+ {
+ LUAX_REGISTER_METHODS(state,
+ { "Fill", _Fill },
+ { "GetSize", _GetSize },
+ { "GetCount", _GetCount }
+ );
+ }
+
+ LUAX_POSTPROCESS(GPUBuffer)
+ {
+ LUAX_REGISTER_ENUM(state, "EBufferType",
+ { "VERTEX", BUFFER_TYPE_VERTEX },
+ { "INDEX", BUFFER_TYPE_INDEX }
+ );
+ LUAX_REGISTER_ENUM(state, "EBufferUsage",
+ { "STREAM", BUFFER_USAGE_STREAM },
+ { "DYNAMIC", BUFFER_USAGE_DYNAMIC },
+ { "STATIC", BUFFER_USAGE_STATIC }
+ );
+ LUAX_REGISTER_ENUM(state, "EBufferDataType",
+ { "INT", BUFFER_DATA_TYPE_INT },
+ { "FLOAT", BUFFER_DATA_TYPE_FLOAT },
+ { "UNSIGNED_BYTE", BUFFER_DATA_TYPE_UNSIGNED_BYTE }
+ );
+
+ }
+
+ // buffer = GPUBuffer.New(bufferType, bufferUsage, bufferDataType, size)
+ // buffer = GPUBuffer.New(image)
+ // buffer = GPUBuffer.New(mesh2d)
+ // buffer = GPUBuffer.New(canvas)
+ // buffer = GPUBuffer.New(shape)
+ //LUAX_IMPL_METHOD(GPUBuffer, _New)
+ //{
+ // LUAX_STATE(L);
+
+ // return 0;
+ //}
+
+ // gpubuffer:Fill({data_unit_list}, offseti)
+ // data_unit_list ݵtable
+ // offseti : ʼǵĵطڵ(0ʼ
+ LUAX_IMPL_METHOD(GPUBuffer, _Fill)
+ {
+ LUAX_PREPARE(L, GPUBuffer);
+
+ // ʹbufferӦ޸bufferڵһεʱʼsizeСbufferȻ䡣
+ int offset = state.GetValue(3, 0);
+ int count = lua_objlen(L, 2);
+ int size = count * self->GetDataTypeSize();
+ byte* data = (byte*)malloc(size);
+ int unit = self->GetDataTypeSize();
+ int i = 1;
+ lua_rawgeti(L, 2, i);
+ while (!lua_isnil(L, -1))
+ {
+ switch (self->m_DataType)
+ {
+ case GL_INT:
+ {
+ int n = state.CheckValue<int>(-1);
+ memcpy(data + (i - 1)*unit, &n, unit);
+ break;
+ }
+ case GL_FLOAT:
+ {
+ float n = state.CheckValue<float>(-1);
+ memcpy(data + (i - 1)*unit, &n, unit);
+ break;
+ }
+ case GL_UNSIGNED_BYTE:
+ {
+ unsigned char n = state.CheckValue<unsigned char>(-1);
+ memcpy(data + (i - 1)*unit, &n, unit);
+ break;
+ }
+ }
+ state.Pop(1); // value
+ lua_rawgeti(L, 2, ++i);
+ }
+ state.Pop(); // nil
+
+ self->Fill(data, size, offset * unit);
+
+ free(data);
+ return 0;
+ }
+
+ // gpubuffer:GetSize()
+ LUAX_IMPL_METHOD(GPUBuffer, _GetSize)
+ {
+ LUAX_PREPARE(L, GPUBuffer);
+ state.Push(self->m_Size);
+ return 0;
+ }
+
+ LUAX_IMPL_METHOD(GPUBuffer, _GetCount)
+ {
+ LUAX_PREPARE(L, GPUBuffer);
+ state.Push(self->m_Size / self->GetDataTypeSize());
+ return 0;
+ }
+
+ }
+}
diff --git a/Source/modules/asura-core/Graphics/binding/_image.cpp b/Source/modules/asura-core/Graphics/binding/_image.cpp
new file mode 100644
index 0000000..0e4cb16
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/binding/_image.cpp
@@ -0,0 +1,71 @@
+#include "../image.h"
+
+using namespace std;
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+
+ LUAX_REGISTRY(Image)
+ {
+ LUAX_INHERIT(state, Texture);
+
+ LUAX_REGISTER_METHODS(state,
+ { "New", _New },
+ { "GetWidth", _GetWidth },
+ { "GetHeight", _GetHeight },
+ { "GetSize", _GetSize },
+ { "Render", _Render }
+ );
+ }
+
+ LUAX_POSTPROCESS(Image)
+ {
+ }
+
+ // image = Image.New()
+ LUAX_IMPL_METHOD(Image, _New)
+ {
+ LUAX_STATE(L);
+ Image* img = new Image();
+ img->PushLuaxUserdata(state);
+ return 1;
+ }
+
+ // width = image:GetWidth()
+ LUAX_IMPL_METHOD(Image, _GetWidth)
+ {
+ LUAX_PREPARE(L, Image);
+ state.Push(self->GetWidth());
+ return 1;
+ }
+
+ // height = image:GetHeight()
+ LUAX_IMPL_METHOD(Image, _GetHeight)
+ {
+ LUAX_PREPARE(L, Image);
+ state.Push(self->GetHeight());
+ return 1;
+ }
+
+ // width, height = image:GetSize()
+ LUAX_IMPL_METHOD(Image, _GetSize)
+ {
+ LUAX_PREPARE(L, Image);
+ int width = self->GetWidth();
+ int height = self->GetHeight();
+ state.Push(width);
+ state.Push(height);
+ return 2;
+ }
+
+ // image:Render()
+ LUAX_IMPL_METHOD(Image, _Render)
+ {
+ LUAX_PREPARE(L, Image);
+
+ return 0;
+ }
+
+ }
+}
diff --git a/Source/modules/asura-core/Graphics/binding/_index_buffer.cpp b/Source/modules/asura-core/Graphics/binding/_index_buffer.cpp
new file mode 100644
index 0000000..151dc98
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/binding/_index_buffer.cpp
@@ -0,0 +1,31 @@
+#include "../IndexBuffer.h"
+
+using namespace std;
+using namespace Luax;
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+
+ LUAX_REGISTRY(IndexBuffer)
+ {
+ LUAX_REGISTER_METHODS(state,
+ { "New", _New }
+ );
+ }
+
+ LUAX_POSTPROCESS(IndexBuffer)
+ {
+
+ }
+
+ // IndexBuffer.New()
+ LUAX_IMPL_METHOD(IndexBuffer, _New)
+ {
+ LUAX_STATE(L);
+
+ return 0;
+ }
+
+ }
+}
diff --git a/Source/modules/asura-core/Graphics/binding/_mesh2d.cpp b/Source/modules/asura-core/Graphics/binding/_mesh2d.cpp
new file mode 100644
index 0000000..4e3f426
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/binding/_mesh2d.cpp
@@ -0,0 +1,20 @@
+#include "../mesh2d.h"
+
+using namespace std;
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+
+ LUAX_REGISTRY(Mesh2D)
+ {
+
+ }
+
+ LUAX_POSTPROCESS(Mesh2D)
+ {
+
+ }
+
+ }
+}
diff --git a/Source/modules/asura-core/Graphics/binding/_shader.cpp b/Source/modules/asura-core/Graphics/binding/_shader.cpp
new file mode 100644
index 0000000..85fd388
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/binding/_shader.cpp
@@ -0,0 +1,131 @@
+#include "../shader.h"
+
+using namespace std;
+using namespace Luax;
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+
+ LUAX_REGISTRY(Shader)
+ {
+ LUAX_REGISTER_METHODS(state,
+ { "New", _New },
+ { "Load", _Load },
+ { "Update", _Update },
+ { "HasUniform", _HasUniform },
+ { "GetUniformLocation", _GetUniformLocation },
+ { "SetBuiltInUniforms", _SetBuiltInUniforms },
+ { "SetUniformFloat", _SetUniformFloat },
+ { "SetUniformTexture", _SetUniformTexture },
+ { "SetUniformVector2", _SetUniformVector2 },
+ { "SetUniformVector3", _SetUniformVector3 },
+ { "SetUniformVector4", _SetUniformVector4 },
+ { "SetUniformColor", _SetUniformColor },
+ { "SetBuiltInUniforms", _SetBuiltInUniforms }
+ );
+ }
+
+ LUAX_POSTPROCESS(Shader)
+ {
+
+ }
+
+ // Shader.New()
+ LUAX_IMPL_METHOD(Shader, _New)
+ {
+ LUAX_STATE(L);
+
+ return 0;
+ }
+
+ // shader:Load()
+ LUAX_IMPL_METHOD(Shader, _Load)
+ {
+ LUAX_PREPARE(L, Shader);
+
+ return 0;
+ }
+
+ // shader:Update()
+ LUAX_IMPL_METHOD(Shader, _Update)
+ {
+ LUAX_PREPARE(L, Shader);
+
+ return 0;
+ }
+
+ // shader:HasUniform()
+ LUAX_IMPL_METHOD(Shader, _HasUniform)
+ {
+ LUAX_PREPARE(L, Shader);
+
+ return 0;
+ }
+
+ // shader:GetUniformLocation()
+ LUAX_IMPL_METHOD(Shader, _GetUniformLocation)
+ {
+ LUAX_PREPARE(L, Shader);
+
+ return 0;
+ }
+
+ // shader:SetBuiltInUniforms()
+ LUAX_IMPL_METHOD(Shader, _SetBuiltInUniforms)
+ {
+ LUAX_PREPARE(L, Shader);
+
+ return 0;
+ }
+
+ // shader:SetUniformFloat()
+ LUAX_IMPL_METHOD(Shader, _SetUniformFloat)
+ {
+ LUAX_PREPARE(L, Shader);
+
+ return 0;
+ }
+
+ // shader:SetUniformTexture()
+ LUAX_IMPL_METHOD(Shader, _SetUniformTexture)
+ {
+ LUAX_PREPARE(L, Shader);
+
+ return 0;
+ }
+
+ // shader:SetUniformVector2()
+ LUAX_IMPL_METHOD(Shader, _SetUniformVector2)
+ {
+ LUAX_PREPARE(L, Shader);
+
+ return 0;
+ }
+
+ // shader:SetUniformVector3()
+ LUAX_IMPL_METHOD(Shader, _SetUniformVector3)
+ {
+ LUAX_PREPARE(L, Shader);
+
+ return 0;
+ }
+
+ // shader:SetUniformVector4()
+ LUAX_IMPL_METHOD(Shader, _SetUniformVector4)
+ {
+ LUAX_PREPARE(L, Shader);
+
+ return 0;
+ }
+
+ // shader:SetUniformColor()
+ LUAX_IMPL_METHOD(Shader, _SetUniformColor)
+ {
+ LUAX_PREPARE(L, Shader);
+
+ return 0;
+ }
+
+ }
+}
diff --git a/Source/modules/asura-core/Graphics/binding/_sprite_batch.cpp b/Source/modules/asura-core/Graphics/binding/_sprite_batch.cpp
new file mode 100644
index 0000000..6b7d25c
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/binding/_sprite_batch.cpp
@@ -0,0 +1,20 @@
+#include "../SpriteBatch.h"
+
+using namespace std;
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+
+ LUAX_REGISTRY(SpriteBatch)
+ {
+
+ }
+
+ LUAX_POSTPROCESS(SpriteBatch)
+ {
+
+ }
+
+ }
+}
diff --git a/Source/modules/asura-core/Graphics/binding/_texture.cpp b/Source/modules/asura-core/Graphics/binding/_texture.cpp
new file mode 100644
index 0000000..f5e5f17
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/binding/_texture.cpp
@@ -0,0 +1,85 @@
+#include "../texture.h"
+
+using namespace std;
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+
+ LUAX_REGISTRY(Texture)
+ {
+ LUAX_REGISTER_METHODS(state,
+ { "SetFilterMode", _SetFilterMode },
+ { "SetWrapMode", _SetWrapMode },
+ { "GetFilterMode", _GetFilterMode },
+ { "GetWrapMode", _GetWrapMode },
+ { "IsGenMipmap", _IsGenMipmap }
+ );
+ }
+
+ LUAX_POSTPROCESS(Texture)
+ {
+ LUAX_REGISTER_ENUM(state, "EColorFormat",
+ { "UNKNOWN", COLOR_FORMAT_UNKNOWN },
+ { "RGBA8", COLOR_FORMAT_RGBA8 },
+ { "RGBA32F", COLOR_FORMAT_RGBA32F }
+ );
+ LUAX_REGISTER_ENUM(state, "EFilterMode",
+ { "NEAREST", FILTER_MODE_NEAREST },
+ { "LINEAR", FILTER_MODE_LINEAR }
+ );
+ LUAX_REGISTER_ENUM(state, "EWrapMode",
+ { "REPEAT", WRAP_MODE_REPEAT },
+ { "MIRROR", WRAP_MODE_MIRROR },
+ { "CLAMPTOEDGE", WRAP_MODE_CLAMPTOEDGE },
+ { "CLAMPTOBORDER", WRAP_MODE_CLAMPTOBORDER }
+ );
+
+ }
+
+ // texture:SetFilterMode(minFilter, magFilter)
+ LUAX_IMPL_METHOD(Texture, _SetFilterMode)
+ {
+ LUAX_PREPARE(L, Texture);
+ FilterMode min = (FilterMode)state.CheckValue<int>(2);
+ FilterMode mag = (FilterMode)state.CheckValue<int>(3);
+ self->SetFilterMode(min, mag);
+ return 0;
+ }
+
+ // texture:SetWrapMode(wrap_mode)
+ LUAX_IMPL_METHOD(Texture, _SetWrapMode)
+ {
+ LUAX_PREPARE(L, Texture);
+ WrapMode wrap_mode = (WrapMode)state.CheckValue<int>(2);
+ self->SetWrapMode(wrap_mode);
+ return 0;
+ }
+
+ // min, mag = texture:GetFilterMode()
+ LUAX_IMPL_METHOD(Texture, _GetFilterMode)
+ {
+ LUAX_PREPARE(L, Texture);
+ state.Push((int)self->m_MinFilter);
+ state.Push((int)self->m_MagFilter);
+ return 2;
+ }
+
+ // wrapmode= texture:GetWrapMode()
+ LUAX_IMPL_METHOD(Texture, _GetWrapMode)
+ {
+ LUAX_PREPARE(L, Texture);
+ state.Push((int)self->m_WrapMode);
+ return 1;
+ }
+
+ // texture:IsGenMipmap()
+ LUAX_IMPL_METHOD(Texture, _IsGenMipmap)
+ {
+ LUAX_PREPARE(L, Texture);
+ state.Push(self->IsGenMipmap());
+ return 1;
+ }
+
+ }
+} \ No newline at end of file
diff --git a/Source/modules/asura-core/Graphics/binding/_vertex_buffer.cpp b/Source/modules/asura-core/Graphics/binding/_vertex_buffer.cpp
new file mode 100644
index 0000000..8ed487b
--- /dev/null
+++ b/Source/modules/asura-core/Graphics/binding/_vertex_buffer.cpp
@@ -0,0 +1,38 @@
+#include "../VertexBuffer.h"
+
+using namespace std;
+using namespace Luax;
+
+namespace_begin(AsuraEngine)
+namespace_begin(Graphics)
+
+
+ LUAX_REGISTRY(VertexBuffer)
+ {
+ LUAX_REGISTER_METHODS(state,
+ { "New", _New }
+ );
+ }
+
+ LUAX_POSTPROCESS(VertexBuffer)
+ {
+
+ }
+
+ // vbo = VertexBuffer.New(usage, data_type, count)
+ LUAX_IMPL_METHOD(VertexBuffer, _New)
+ {
+ LUAX_STATE(L);
+
+ BufferUsage usage = (BufferUsage)state.CheckValue<uint>(1);
+ BufferDataType datatype = (BufferDataType)state.CheckValue<uint>(2);
+ uint count = state.CheckValue<uint>(3);
+
+ VertexBuffer* vbo = new VertexBuffer(usage, datatype, count * GPUBuffer::GetDataTypeSize(datatype));
+ vbo->PushLuaxUserdata(state);
+
+ return 1;
+ }
+
+ }
+}