From c8a6a8e2dd6f015a31b4f8191ad945a78fe77f3d Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 3 Apr 2019 09:00:13 +0800 Subject: *misc --- source/modules/asura-core/graphics/gl.h | 55 ++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 5 deletions(-) (limited to 'source/modules/asura-core/graphics/gl.h') diff --git a/source/modules/asura-core/graphics/gl.h b/source/modules/asura-core/graphics/gl.h index 9ca1f44..3104288 100644 --- a/source/modules/asura-core/graphics/gl.h +++ b/source/modules/asura-core/graphics/gl.h @@ -5,6 +5,7 @@ #include +#include #include #include @@ -18,15 +19,25 @@ namespace AsuraEngine class Profiler; class Shader; + enum MatrixMode + { + MATRIX_PROJECTION = 0, + MATRIX_MODELVIEW, + _MATRIX_COUNT + }; + /// /// OpenGL上下文,用来做一些opengl状态的追踪。在编辑器多窗口环境下,一个窗口对应一个hwnd, /// 一个hdc,以及数个opengl context,如果使用wglMakeCurrent(hdc, glc)指定当前线程耳朵 /// 渲染窗口hdc和opengl上下文glc,gl中记录的就是任意一个线程的任意一个窗口的任意一个OpenGL /// 上下文的状态, /// - class OpenGL + class OpenGL : public AEScripting::Portable { public: + + LUAX_DECL_SINGLETON(GL); + OpenGL(); ~OpenGL(); @@ -36,6 +47,19 @@ namespace AsuraEngine void UseShader(Shader* shader); void UnuseShader(); + void SetMatrixMode(MatrixMode mode); + MatrixMode GetMatrixMode(); + void PushMatrix(); + void PopMatrix(); + void LoadIdentity(); + void Rotate(float angle, float x, float y, float z); + void Translate(float x, float y, float z); + void Scale(float x, float y, float z); + void Ortho(float l, float r, float b, float t, float n, float f); + AEMath::Matrix44& GetMatrix(MatrixMode mode); + uint GetMatrixDepth(); + uint GetMatrixIndex(); + /// /// OpenGL3.0以后由用户管理矩阵变换、视口、shader等参数,这里保存一些OpenGL状态。注意 /// 似乎全进程的,也就是说,Asura不支持多线程渲染。OpenGL上下文的创建使得一个上下 @@ -45,16 +69,37 @@ namespace AsuraEngine /// struct { - Shader* shader; ///< 当前使用的shader - AEMath::Recti viewport; ///< 当前的视区,在切换HDC或者本窗口大小改变或者部分刷新时变动 - MatrixStack projectionMatrix; ///< 投影矩阵 - MatrixStack modelViewMatrix; ///< 变换矩阵 + Shader* shader; ///< 当前使用的shader + AEMath::Recti viewport; ///< 当前的视区,在切换HDC或者本窗口大小改变或者部分刷新时变动 + MatrixStack matrix[_MATRIX_COUNT]; ///< 投影矩阵 + MatrixMode matrixMode; ///< 当前操作的矩阵 } state; private: friend class Profiler; + //----------------------------------------------------------------------------// + + LUAX_DECL_ENUM(MatrixMode, 0); + + 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); + + //----------------------------------------------------------------------------// + }; /// -- cgit v1.1-26-g67d0