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/binding/_canvas.cpp2
-rw-r--r--source/modules/asura-core/graphics/binding/_color.cpp2
-rw-r--r--source/modules/asura-core/graphics/binding/_color32.cpp2
-rw-r--r--source/modules/asura-core/graphics/binding/_gfx_device.cpp2
-rw-r--r--source/modules/asura-core/graphics/binding/_gpu_buffer.cpp2
-rw-r--r--source/modules/asura-core/graphics/binding/_index_buffer.cpp2
-rw-r--r--source/modules/asura-core/graphics/binding/_sprite_batch.cpp2
-rw-r--r--source/modules/asura-core/graphics/binding/_vertex_buffer.cpp2
-rw-r--r--source/modules/asura-core/graphics/blend_mode.h17
-rw-r--r--source/modules/asura-core/graphics/canvas.h24
-rw-r--r--source/modules/asura-core/graphics/color.cpp4
-rw-r--r--source/modules/asura-core/graphics/color.h10
-rw-r--r--source/modules/asura-core/graphics/color32.cpp4
-rw-r--r--source/modules/asura-core/graphics/color32.h10
-rw-r--r--source/modules/asura-core/graphics/color_palette.h0
-rw-r--r--source/modules/asura-core/graphics/gfx_device.cpp208
-rw-r--r--source/modules/asura-core/graphics/gfx_device.h139
-rw-r--r--source/modules/asura-core/graphics/gpu_buffer.cpp151
-rw-r--r--source/modules/asura-core/graphics/gpu_buffer.h95
-rw-r--r--source/modules/asura-core/graphics/image.cpp10
-rw-r--r--source/modules/asura-core/graphics/image.h28
-rw-r--r--source/modules/asura-core/graphics/index_buffer.cpp17
-rw-r--r--source/modules/asura-core/graphics/index_buffer.h34
-rw-r--r--source/modules/asura-core/graphics/matrix_stack.cpp75
-rw-r--r--source/modules/asura-core/graphics/matrix_stack.h58
-rw-r--r--source/modules/asura-core/graphics/mesh2d.h16
-rw-r--r--source/modules/asura-core/graphics/render_state.h47
-rw-r--r--source/modules/asura-core/graphics/render_target.cpp0
-rw-r--r--source/modules/asura-core/graphics/render_target.h52
-rw-r--r--source/modules/asura-core/graphics/shader.cpp6
-rw-r--r--source/modules/asura-core/graphics/shader.h34
-rw-r--r--source/modules/asura-core/graphics/sprite_batch.cpp0
-rw-r--r--source/modules/asura-core/graphics/sprite_batch.h34
-rw-r--r--source/modules/asura-core/graphics/texture.cpp2
-rw-r--r--source/modules/asura-core/graphics/texture.h14
-rw-r--r--source/modules/asura-core/graphics/vertex_buffer.cpp16
-rw-r--r--source/modules/asura-core/graphics/vertex_buffer.h34
37 files changed, 89 insertions, 1066 deletions
diff --git a/source/modules/asura-core/graphics/binding/_canvas.cpp b/source/modules/asura-core/graphics/binding/_canvas.cpp
index 6dda773..44841f5 100644
--- a/source/modules/asura-core/graphics/binding/_canvas.cpp
+++ b/source/modules/asura-core/graphics/binding/_canvas.cpp
@@ -1,4 +1,4 @@
-#include "../canvas.h"
+#include "../Canvas.h"
using namespace std;
diff --git a/source/modules/asura-core/graphics/binding/_color.cpp b/source/modules/asura-core/graphics/binding/_color.cpp
index c990d8b..008d9c2 100644
--- a/source/modules/asura-core/graphics/binding/_color.cpp
+++ b/source/modules/asura-core/graphics/binding/_color.cpp
@@ -1,4 +1,4 @@
-#include "../color.h"
+#include "../Color.h"
using namespace std;
using namespace Luax;
diff --git a/source/modules/asura-core/graphics/binding/_color32.cpp b/source/modules/asura-core/graphics/binding/_color32.cpp
index 96c63af..7613361 100644
--- a/source/modules/asura-core/graphics/binding/_color32.cpp
+++ b/source/modules/asura-core/graphics/binding/_color32.cpp
@@ -1,4 +1,4 @@
-#include "../color32.h"
+#include "../Color32.h"
using namespace std;
diff --git a/source/modules/asura-core/graphics/binding/_gfx_device.cpp b/source/modules/asura-core/graphics/binding/_gfx_device.cpp
index 60a0b0b..f6c2004 100644
--- a/source/modules/asura-core/graphics/binding/_gfx_device.cpp
+++ b/source/modules/asura-core/graphics/binding/_gfx_device.cpp
@@ -1,4 +1,4 @@
-#include "../gfx_device.h"
+#include "../GfxDevice.h"
using namespace std;
using namespace Luax;
diff --git a/source/modules/asura-core/graphics/binding/_gpu_buffer.cpp b/source/modules/asura-core/graphics/binding/_gpu_buffer.cpp
index 479901e..8c39a59 100644
--- a/source/modules/asura-core/graphics/binding/_gpu_buffer.cpp
+++ b/source/modules/asura-core/graphics/binding/_gpu_buffer.cpp
@@ -1,7 +1,7 @@
#include <stdlib.h>
#include "../image.h"
-#include "../gpu_buffer.h"
+#include "../GPUBuffer.h"
using namespace std;
using namespace Luax;
diff --git a/source/modules/asura-core/graphics/binding/_index_buffer.cpp b/source/modules/asura-core/graphics/binding/_index_buffer.cpp
index eb81699..151dc98 100644
--- a/source/modules/asura-core/graphics/binding/_index_buffer.cpp
+++ b/source/modules/asura-core/graphics/binding/_index_buffer.cpp
@@ -1,4 +1,4 @@
-#include "../index_buffer.h"
+#include "../IndexBuffer.h"
using namespace std;
using namespace Luax;
diff --git a/source/modules/asura-core/graphics/binding/_sprite_batch.cpp b/source/modules/asura-core/graphics/binding/_sprite_batch.cpp
index 7795d26..6b7d25c 100644
--- a/source/modules/asura-core/graphics/binding/_sprite_batch.cpp
+++ b/source/modules/asura-core/graphics/binding/_sprite_batch.cpp
@@ -1,4 +1,4 @@
-#include "../sprite_batch.h"
+#include "../SpriteBatch.h"
using namespace std;
diff --git a/source/modules/asura-core/graphics/binding/_vertex_buffer.cpp b/source/modules/asura-core/graphics/binding/_vertex_buffer.cpp
index b181df3..8ed487b 100644
--- a/source/modules/asura-core/graphics/binding/_vertex_buffer.cpp
+++ b/source/modules/asura-core/graphics/binding/_vertex_buffer.cpp
@@ -1,4 +1,4 @@
-#include "../vertex_buffer.h"
+#include "../VertexBuffer.h"
using namespace std;
using namespace Luax;
diff --git a/source/modules/asura-core/graphics/blend_mode.h b/source/modules/asura-core/graphics/blend_mode.h
deleted file mode 100644
index 73e1a41..0000000
--- a/source/modules/asura-core/graphics/blend_mode.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef __ASURA_ENGINE_BLEND_MODE_H__
-#define __ASURA_ENGINE_BLEND_MODE_H__
-
-#include <asura-utils/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.h b/source/modules/asura-core/graphics/canvas.h
index bbd098a..0ec55bc 100644
--- a/source/modules/asura-core/graphics/canvas.h
+++ b/source/modules/asura-core/graphics/canvas.h
@@ -1,15 +1,15 @@
-#ifndef __ASURA_ENGINE_CANVAS_H__
-#define __ASURA_ENGINE_CANVAS_H__
-
-#include <asura-utils/scripting/portable.hpp>
-#include <asura-utils/math/rect.hpp>
-#include <asura-utils/math/vector2.hpp>
-#include <asura-utils/exceptions/exception.h>
-
-#include "gfx_device.h"
-#include "texture.h"
-#include "render_target.h"
-#include "render_state.h"
+#ifndef _ASURA_ENGINE_CANVAS_H_
+#define _ASURA_ENGINE_CANVAS_H_
+
+#include <asura-utils/Scripting/Portable.hpp>
+#include <asura-utils/Math/Rect.hpp>
+#include <asura-utils/Math/Vector2.hpp>
+#include <asura-utils/Exceptions/Exception.h>
+
+#include "GfxDevice.h"
+#include "Texture.h"
+#include "RenderTarget.h"
+#include "RenderState.h"
namespace_begin(AsuraEngine)
namespace_begin(Graphics)
diff --git a/source/modules/asura-core/graphics/color.cpp b/source/modules/asura-core/graphics/color.cpp
index 47e039f..5a66291 100644
--- a/source/modules/asura-core/graphics/color.cpp
+++ b/source/modules/asura-core/graphics/color.cpp
@@ -1,5 +1,5 @@
-#include "color.h"
-#include "color32.h"
+#include "Color.h"
+#include "Color32.h"
namespace_begin(AsuraEngine)
namespace_begin(Graphics)
diff --git a/source/modules/asura-core/graphics/color.h b/source/modules/asura-core/graphics/color.h
index 99a9b00..a16f17d 100644
--- a/source/modules/asura-core/graphics/color.h
+++ b/source/modules/asura-core/graphics/color.h
@@ -1,10 +1,10 @@
-#ifndef __ASURA_ENGINE_COLOR_H__
-#define __ASURA_ENGINE_COLOR_H__
+#ifndef _ASURA_ENGINE_COLOR_H_
+#define _ASURA_ENGINE_COLOR_H_
-#include <asura-utils/scripting/portable.hpp>
-#include <asura-utils/classes.h>
+#include <asura-utils/Scripting/Portable.hpp>
+#include <asura-utils/Classes.h>
-#include "../core_config.h"
+#include "../CoreConfig.h"
namespace_begin(AsuraEngine)
namespace_begin(Graphics)
diff --git a/source/modules/asura-core/graphics/color32.cpp b/source/modules/asura-core/graphics/color32.cpp
index 11239c8..f1f0b74 100644
--- a/source/modules/asura-core/graphics/color32.cpp
+++ b/source/modules/asura-core/graphics/color32.cpp
@@ -1,5 +1,5 @@
-#include "color.h"
-#include "color32.h"
+#include "Color.h"
+#include "Color32.h"
namespace_begin(AsuraEngine)
namespace_begin(Graphics)
diff --git a/source/modules/asura-core/graphics/color32.h b/source/modules/asura-core/graphics/color32.h
index 52405e9..aa445fe 100644
--- a/source/modules/asura-core/graphics/color32.h
+++ b/source/modules/asura-core/graphics/color32.h
@@ -1,10 +1,10 @@
-#ifndef __ASURA_ENGINE_COLOR32_H__
-#define __ASURA_ENGINE_COLOR32_H__
+#ifndef _ASURA_ENGINE_COLOR32_H__
+#define _ASURA_ENGINE_COLOR32_H__
-#include <asura-utils/classes.h>
-#include <asura-utils/scripting/portable.hpp>
+#include <asura-utils/Classes.h>
+#include <asura-utils/Scripting/Portable.hpp>
-#include "../core_config.h"
+#include "../CoreConfig.h"
namespace_begin(AsuraEngine)
namespace_begin(Graphics)
diff --git a/source/modules/asura-core/graphics/color_palette.h b/source/modules/asura-core/graphics/color_palette.h
deleted file mode 100644
index e69de29..0000000
--- a/source/modules/asura-core/graphics/color_palette.h
+++ /dev/null
diff --git a/source/modules/asura-core/graphics/gfx_device.cpp b/source/modules/asura-core/graphics/gfx_device.cpp
deleted file mode 100644
index 2751a9d..0000000
--- a/source/modules/asura-core/graphics/gfx_device.cpp
+++ /dev/null
@@ -1,208 +0,0 @@
-#include <asura-utils/type.h>
-
-#include "../core_config.h"
-
-#include "gfx_device.h"
-#include "shader.h"
-#include "matrix_stack.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;
-}
-
-Canvas* GfxDevice::GetActiveCanvas() const
-{
- return state.canvas;
-}
-
-void GfxDevice::SetActiveCanvas(Canvas* canvas)
-{
- state.canvas = canvas;
-}
-
-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::SetMatrixMode (MatrixMode mode)
-{
- state.matrixMode = mode;
-}
-
-MatrixMode GfxDevice::GetMatrixMode ()
-{
- return state.matrixMode;
-}
-
-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/gfx_device.h b/source/modules/asura-core/graphics/gfx_device.h
deleted file mode 100644
index fa22dd4..0000000
--- a/source/modules/asura-core/graphics/gfx_device.h
+++ /dev/null
@@ -1,139 +0,0 @@
-#ifndef __ASURA_ENGINE_GFX_DEVICE_H__
-#define __ASURA_ENGINE_GFX_DEVICE_H__
-
-#include <stack>
-
-#include <glad/glad.h>
-
-#include <asura-utils/scripting/portable.hpp>
-#include <asura-utils/math/rect.hpp>
-#include <asura-utils/math/matrix44.h>
-#include <asura-utils/math/vector4.h>
-
-#include "color.h"
-#include "matrix_stack.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 SetMatrixMode(MatrixMode mode);
- MatrixMode GetMatrixMode();
-
- 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();
-
- AEMath::Matrix44& GetMatrix(MatrixMode mode);
- AEMath::Matrix44 GetMVPMatrix();
-
- void SetDrawColor(float r, float g, float b, float a);
- Color& GetDrawColor();
-
- void SetActiveCanvas(Canvas* = NULL);
- Canvas* GetActiveCanvas() const;
-
- void SetActiveShader(Shader* = NULL);
- Shader* GetActiveShader() const;
-
- void DrawArrays(GLenum mode, GLint first, GLsizei count);
-
- void WipeError();
- bool HasError();
- GLenum GetError();
-
-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);
-
-};
-
-// ȫ GfxDevice
-extern GfxDevice g_Device;
-
-namespace_end
-namespace_end
-
-#endif \ No newline at end of file
diff --git a/source/modules/asura-core/graphics/gpu_buffer.cpp b/source/modules/asura-core/graphics/gpu_buffer.cpp
deleted file mode 100644
index 4271b70..0000000
--- a/source/modules/asura-core/graphics/gpu_buffer.cpp
+++ /dev/null
@@ -1,151 +0,0 @@
-#include "gpu_buffer.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/gpu_buffer.h b/source/modules/asura-core/graphics/gpu_buffer.h
deleted file mode 100644
index 3153904..0000000
--- a/source/modules/asura-core/graphics/gpu_buffer.h
+++ /dev/null
@@ -1,95 +0,0 @@
-#ifndef __ASURA_GPU_BUFFER_H__
-#define __ASURA_GPU_BUFFER_H__
-
-#include <asura-utils/scripting/portable.hpp>
-#include <asura-utils/exceptions/exception.h>
-#include <asura-utils/type.h>
-
-#include "gfx_device.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/image.cpp b/source/modules/asura-core/graphics/image.cpp
index 32fa870..d2b2ec9 100644
--- a/source/modules/asura-core/graphics/image.cpp
+++ b/source/modules/asura-core/graphics/image.cpp
@@ -1,10 +1,10 @@
-#include <asura-utils/exceptions/exception.h>
+#include <asura-utils/Exceptions/Exception.h>
-#include "../core_config.h"
+#include "../CoreConfig.h"
-#include "shader.h"
-#include "image.h"
-#include "gfx_device.h"
+#include "Shader.h"
+#include "Image.h"
+#include "GfxDevice.h"
using namespace AEIO;
using namespace AEImage;
diff --git a/source/modules/asura-core/graphics/image.h b/source/modules/asura-core/graphics/image.h
index 72f1281..5cbfe23 100644
--- a/source/modules/asura-core/graphics/image.h
+++ b/source/modules/asura-core/graphics/image.h
@@ -1,23 +1,23 @@
-#ifndef __ASURA_ENGINE_IMAGE_H__
-#define __ASURA_ENGINE_IMAGE_H__
+#ifndef _ASURA_ENGINE_IMAGE_H_
+#define _ASURA_ENGINE_IMAGE_H_
// asura modules
-#include <asura-utils/math/rect.hpp>
-#include <asura-utils/math/vector2.hpp>
-#include <asura-utils/scripting/portable.hpp>
-#include <asura-utils/io/renewable.h>
-#include <asura-utils/stringmap.hpp>
-#include <asura-utils/manager.hpp>
+#include <asura-utils/Math/Rect.hpp>
+#include <asura-utils/Math/Vector2.hpp>
+#include <asura-utils/Scripting/Portable.hpp>
+#include <asura-utils/IO/Renewable.h>
+#include <asura-utils/Stringmap.hpp>
+#include <asura-utils/Manager.hpp>
// module
-#include "../image/image_data.h"
+#include "../Image/ImageData.h"
// folder
-#include "color.h"
-#include "color32.h"
-#include "render_state.h"
-#include "gpu_buffer.h"
-#include "texture.h"
+#include "Color.h"
+#include "Color32.h"
+#include "RenderState.h"
+#include "GPUBuffer.h"
+#include "Texture.h"
namespace_begin(AsuraEngine)
namespace_begin(Graphics)
diff --git a/source/modules/asura-core/graphics/index_buffer.cpp b/source/modules/asura-core/graphics/index_buffer.cpp
deleted file mode 100644
index 9d7416f..0000000
--- a/source/modules/asura-core/graphics/index_buffer.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-#include "index_buffer.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/index_buffer.h b/source/modules/asura-core/graphics/index_buffer.h
deleted file mode 100644
index 538b43b..0000000
--- a/source/modules/asura-core/graphics/index_buffer.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef __ASURA_INDEX_BUFFER_H__
-#define __ASURA_INDEX_BUFFER_H__
-
-#include <asura-utils/scripting/portable.hpp>
-
-#include "gpu_buffer.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/matrix_stack.cpp b/source/modules/asura-core/graphics/matrix_stack.cpp
deleted file mode 100644
index eaa686f..0000000
--- a/source/modules/asura-core/graphics/matrix_stack.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-#include "matrix_stack.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/matrix_stack.h b/source/modules/asura-core/graphics/matrix_stack.h
deleted file mode 100644
index ad32bb4..0000000
--- a/source/modules/asura-core/graphics/matrix_stack.h
+++ /dev/null
@@ -1,58 +0,0 @@
-#ifndef __ASURA_MATRIX_STACK_H__
-#define __ASURA_MATRIX_STACK_H__
-
-#include <asura-utils/type.h>
-#include <asura-utils/math/matrix44.h>
-#include <asura-utils/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.h b/source/modules/asura-core/graphics/mesh2d.h
index d2d7d3b..1546765 100644
--- a/source/modules/asura-core/graphics/mesh2d.h
+++ b/source/modules/asura-core/graphics/mesh2d.h
@@ -1,20 +1,20 @@
-#ifndef __ASURA_ENGINE_MESH2D_H__
-#define __ASURA_ENGINE_MESH2D_H__
+#ifndef _ASURA_ENGINE_MESH2D_H__
+#define _ASURA_ENGINE_MESH2D_H__
// cpp
#include <vector>
// asura modules
-#include <asura-utils/scripting/portable.hpp>
-#include <asura-utils/math/vector2.hpp>
+#include <asura-utils/Scripting/Portable.hpp>
+#include <asura-utils/Math/Vector2.hpp>
// module
-#include "../mesh/mesh2d_data.h"
+#include "../Mesh/Mesh2dData.h"
// folder
-#include "color.h"
-#include "vertex_buffer.h"
-#include "index_buffer.h"
+#include "Color.h"
+#include "VertexBuffer.h"
+#include "IndexBuffer.h"
namespace_begin(AsuraEngine)
namespace_begin(Graphics)
diff --git a/source/modules/asura-core/graphics/render_state.h b/source/modules/asura-core/graphics/render_state.h
deleted file mode 100644
index 9f138c0..0000000
--- a/source/modules/asura-core/graphics/render_state.h
+++ /dev/null
@@ -1,47 +0,0 @@
-#ifndef __ASURA_ENGINE_RENDER_STATE_H__
-#define __ASURA_ENGINE_RENDER_STATE_H__
-
-#include <asura-utils/math/vector2.hpp>
-#include <asura-utils/math/transform.h>
-
-#include "blend_mode.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/render_target.cpp b/source/modules/asura-core/graphics/render_target.cpp
deleted file mode 100644
index e69de29..0000000
--- a/source/modules/asura-core/graphics/render_target.cpp
+++ /dev/null
diff --git a/source/modules/asura-core/graphics/render_target.h b/source/modules/asura-core/graphics/render_target.h
deleted file mode 100644
index a52e7b0..0000000
--- a/source/modules/asura-core/graphics/render_target.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef __ASURA_ENGINE_RENDERTARGET_H__
-#define __ASURA_ENGINE_RENDERTARGET_H__
-
-#include <asura-utils/math/vector2.hpp>
-#include <asura-utils/math/rect.hpp>
-#include <asura-utils/scripting/portable.hpp>
-
-#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
index 74bf7a8..30e0161 100644
--- a/source/modules/asura-core/graphics/shader.cpp
+++ b/source/modules/asura-core/graphics/shader.cpp
@@ -1,7 +1,7 @@
-#include <asura-utils/exceptions/exception.h>
+#include <asura-utils/Exceptions/Exception.h>
-#include "gfx_device.h"
-#include "shader.h"
+#include "GfxDevice.h"
+#include "Shader.h"
using namespace std;
diff --git a/source/modules/asura-core/graphics/shader.h b/source/modules/asura-core/graphics/shader.h
index c535570..c96b99f 100644
--- a/source/modules/asura-core/graphics/shader.h
+++ b/source/modules/asura-core/graphics/shader.h
@@ -1,24 +1,24 @@
-#ifndef __ASURA_ENGINE_SHADER_H__
-#define __ASURA_ENGINE_SHADER_H__
+#ifndef _ASURA_ENGINE_SHADER_H_
+#define _ASURA_ENGINE_SHADER_H_
#include <map>
#include <string>
-#include <asura-utils/exceptions/exception.h>
-#include <asura-utils/scripting/portable.hpp>
-#include <asura-utils/io/renewable.h>
-#include <asura-utils/math/vector2.hpp>
-#include <asura-utils/math/vector3.hpp>
-#include <asura-utils/math/vector4.h>
-#include <asura-utils/math/matrix44.h>
-#include <asura-utils/stringmap.hpp>
-#include <asura-utils/manager.hpp>
-
-#include "gfx_device.h"
-#include "color.h"
-#include "texture.h"
-#include "vertex_buffer.h"
-#include "index_buffer.h"
+#include <asura-utils/Exceptions/Exception.h>
+#include <asura-utils/Scripting/Portable.hpp>
+#include <asura-utils/IO/Renewable.h>
+#include <asura-utils/Math/Vector2.hpp>
+#include <asura-utils/Math/vector3.hpp>
+#include <asura-utils/Math/vector4.h>
+#include <asura-utils/Math/matrix44.h>
+#include <asura-utils/Stringmap.hpp>
+#include <asura-utils/Manager.hpp>
+
+#include "GfxDevice.h"
+#include "Color.h"
+#include "Texture.h"
+#include "VertexBuffer.h"
+#include "IndexBuffer.h"
namespace_begin(AsuraEngine)
namespace_begin(Graphics)
diff --git a/source/modules/asura-core/graphics/sprite_batch.cpp b/source/modules/asura-core/graphics/sprite_batch.cpp
deleted file mode 100644
index e69de29..0000000
--- a/source/modules/asura-core/graphics/sprite_batch.cpp
+++ /dev/null
diff --git a/source/modules/asura-core/graphics/sprite_batch.h b/source/modules/asura-core/graphics/sprite_batch.h
deleted file mode 100644
index 7f22da0..0000000
--- a/source/modules/asura-core/graphics/sprite_batch.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef __ASURA_ENGINE_SPRITE_BATCH_H__
-#define __ASURA_ENGINE_SPRITE_BATCH_H__
-
-#include <asura-utils/scripting/portable.hpp>
-
-#include "gpu_buffer.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
index 42e3851..bae0f7c 100644
--- a/source/modules/asura-core/graphics/texture.cpp
+++ b/source/modules/asura-core/graphics/texture.cpp
@@ -1,4 +1,4 @@
-#include <asura-utils/exceptions/exception.h>
+#include <asura-utils/Exceptions/Exception.h>
#include "Texture.h"
diff --git a/source/modules/asura-core/graphics/texture.h b/source/modules/asura-core/graphics/texture.h
index 458e35a..7d37c31 100644
--- a/source/modules/asura-core/graphics/texture.h
+++ b/source/modules/asura-core/graphics/texture.h
@@ -1,13 +1,13 @@
-#ifndef __ASURA_TEXTURE_H__
-#define __ASURA_TEXTURE_H__
+#ifndef _ASURA_TEXTURE_H_
+#define _ASURA_TEXTURE_H_
-#include <asura-utils/math/vector2.hpp>
-#include <asura-utils/math/rect.hpp>
+#include <asura-utils/Math/Vector2.hpp>
+#include <asura-utils/Math/Rect.hpp>
-#include "../core_config.h"
+#include "../CoreConfig.h"
-#include "render_state.h"
-#include "gfx_device.h"
+#include "RenderState.h"
+#include "GfxDevice.h"
namespace_begin(AsuraEngine)
namespace_begin(Graphics)
diff --git a/source/modules/asura-core/graphics/vertex_buffer.cpp b/source/modules/asura-core/graphics/vertex_buffer.cpp
deleted file mode 100644
index 7fcd3d4..0000000
--- a/source/modules/asura-core/graphics/vertex_buffer.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#include "vertex_buffer.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/vertex_buffer.h b/source/modules/asura-core/graphics/vertex_buffer.h
deleted file mode 100644
index f0bfb9e..0000000
--- a/source/modules/asura-core/graphics/vertex_buffer.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef __ASURA_VERTEX_BUFFER_H__
-#define __ASURA_VERTEX_BUFFER_H__
-
-#include <asura-utils/scripting/portable.hpp>
-
-#include "gpu_buffer.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