From 7638df1ed1f0f314d78bd42e0aba084ba14ade0a Mon Sep 17 00:00:00 2001 From: chai Date: Sun, 4 Aug 2019 17:19:51 +0800 Subject: *misc --- source/modules/asura-core/Graphics/DrawInfo.h | 1 + source/modules/asura-core/Graphics/DrawUtil.cpp | 0 source/modules/asura-core/Graphics/DrawUtil.h | 0 source/modules/asura-core/Graphics/GPUBuffer.h | 10 ++--- source/modules/asura-core/Graphics/GfxDevice.cpp | 20 --------- source/modules/asura-core/Graphics/GfxDevice.h | 52 +++++++++++----------- .../modules/asura-core/Graphics/GraphicsHelper.cpp | 0 .../modules/asura-core/Graphics/GraphicsHelper.h | 15 +++++++ source/modules/asura-core/Graphics/Polygon2D.cpp | 0 source/modules/asura-core/Graphics/Polygon2D.h | 0 source/modules/asura-core/Graphics/VBO.cpp | 0 source/modules/asura-core/Graphics/VBO.h | 27 +++++++++++ 12 files changed, 74 insertions(+), 51 deletions(-) create mode 100644 source/modules/asura-core/Graphics/DrawUtil.cpp create mode 100644 source/modules/asura-core/Graphics/DrawUtil.h create mode 100644 source/modules/asura-core/Graphics/GraphicsHelper.cpp create mode 100644 source/modules/asura-core/Graphics/GraphicsHelper.h create mode 100644 source/modules/asura-core/Graphics/Polygon2D.cpp create mode 100644 source/modules/asura-core/Graphics/Polygon2D.h create mode 100644 source/modules/asura-core/Graphics/VBO.cpp create mode 100644 source/modules/asura-core/Graphics/VBO.h (limited to 'source/modules/asura-core/Graphics') diff --git a/source/modules/asura-core/Graphics/DrawInfo.h b/source/modules/asura-core/Graphics/DrawInfo.h index f0e375b..9042f2f 100644 --- a/source/modules/asura-core/Graphics/DrawInfo.h +++ b/source/modules/asura-core/Graphics/DrawInfo.h @@ -6,6 +6,7 @@ namespace_begin(AsuraEngine) namespace_begin(Graphics) +/// struct DrawInfo { 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 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 diff --git a/source/modules/asura-core/Graphics/GPUBuffer.h b/source/modules/asura-core/Graphics/GPUBuffer.h index bb40055..0aa3c29 100644 --- a/source/modules/asura-core/Graphics/GPUBuffer.h +++ b/source/modules/asura-core/Graphics/GPUBuffer.h @@ -31,8 +31,7 @@ enum BufferDataType }; /// -/// VRAM缓冲,分顶点缓冲vbo和索引缓冲ebo两种,避免每次都从内存向显存上传数据。在framework的renderers中 -/// 构建。 +/// VRAM缓冲,分顶点缓冲vbo和索引缓冲ebo两种,避免每次都从内存向显存上传数据。在framework的renderers中构建。 /// ASURA_ABSTRACT class GPUBuffer { @@ -62,10 +61,9 @@ private: GLenum m_Target; GLuint m_Buffer; - /// opengl的显存缓冲并没有对数据类型的要求,只在glVertexAttribPointer时会指定,并在drawcall 时根据给定 - /// 的数据起始地址和类型从buffer中取各类顶点数据,所以不同的数据类型可以保存在一个buffer中。但是为了保持 - /// 接口的简洁,这里在初始化buffer时指明保存的数据类型,并在整个周期内保持数据类型的一致,所以不同的数据 - /// 类型分属不同的buffer。 + /// opengl的显存缓冲并没有对数据类型的要求,只在glVertexAttribPointer时会指定,并在drawcall 时根据给定的数据起 + /// 始地址和类型从buffer中取各类顶点数据,所以不同的数据类型可以保存在一个buffer中。但是为了保持接口的简洁,这里在 + /// 初始化buffer时指明保存的数据类型,并在整个周期内保持数据类型的一致,所以不同的数据类型分属不同的buffer。 GLenum m_DataType; GLuint m_Usage; diff --git a/source/modules/asura-core/Graphics/GfxDevice.cpp b/source/modules/asura-core/Graphics/GfxDevice.cpp index ef324e3..ea95f54 100644 --- a/source/modules/asura-core/Graphics/GfxDevice.cpp +++ b/source/modules/asura-core/Graphics/GfxDevice.cpp @@ -82,16 +82,6 @@ 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; @@ -136,16 +126,6 @@ void GfxDevice::DrawArrays(GLenum mode, GLint first, GLsizei count) 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 (); diff --git a/source/modules/asura-core/Graphics/GfxDevice.h b/source/modules/asura-core/Graphics/GfxDevice.h index 1f50b57..02c7392 100644 --- a/source/modules/asura-core/Graphics/GfxDevice.h +++ b/source/modules/asura-core/Graphics/GfxDevice.h @@ -42,47 +42,44 @@ public: static GfxDevice& Get(); - int GetParam(GLParams param); + int GetParam(GLParams param); - bool Init(const AEMath::Recti& viewport); - bool Inited(); + bool Init(const AEMath::Recti& viewport); + bool Inited(); - void SetViewport(const AEMath::Recti viewport); + void SetViewport(const AEMath::Recti viewport); const AEMath::Recti& GetViewport(); - void SetMatrixMode(MatrixMode mode); - MatrixMode GetMatrixMode(); + void PushMatrix(); + void PopMatrix(); - 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); - 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(); - 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 SetActiveCanvas(Canvas* = NULL); - Canvas* GetActiveCanvas() const; + void SetDrawColor(float r, float g, float b, float a); + Color& GetDrawColor(); void SetActiveShader(Shader* = NULL); Shader* GetActiveShader() const; - void DrawArrays(GLenum mode, GLint first, GLsizei count); + void WipeError(); + bool HasError(); + GLenum GetError(); - void WipeError(); - bool HasError(); - GLenum GetError(); + GET_SET(MatrixMode, MatrixMode, state.matrixMode); + GET_SET(Canvas*, ActiveCanvas, state.canvas); private: @@ -130,9 +127,14 @@ luaxport: }; -// 全局 GfxDevice 对象 extern GfxDevice g_Device; + +#define GL_CALL(x) do { x; /*GLAssert(); */} while(0) + + + + namespace_end namespace_end 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 diff --git a/source/modules/asura-core/Graphics/GraphicsHelper.h b/source/modules/asura-core/Graphics/GraphicsHelper.h new file mode 100644 index 0000000..b93756a --- /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 + +namespace_begin(AsuraEngine) +namespace_begin(Graphics) + + + + +namespace_end +namespace_end + +#endif 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 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 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 diff --git a/source/modules/asura-core/Graphics/VBO.h b/source/modules/asura-core/Graphics/VBO.h new file mode 100644 index 0000000..80f405f --- /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 + +namespace_begin(AsuraEngine) +namespace_begin(Graphics) + +struct VertexBufferData +{ + +}; + +struct IndexBufferData +{ + +}; + +class VBO +{ + +}; + +namespace_end +namespace_end + +#endif \ No newline at end of file -- cgit v1.1-26-g67d0