From 8ee3f7453bf7b0db5c7358e697e91714d825c87d Mon Sep 17 00:00:00 2001 From: chai Date: Sun, 9 Jun 2019 21:12:25 +0800 Subject: *misc --- source/modules/asura-core/graphics/gfx_device.h | 31 +++++++++---------------- 1 file changed, 11 insertions(+), 20 deletions(-) (limited to 'source/modules/asura-core/graphics/gfx_device.h') diff --git a/source/modules/asura-core/graphics/gfx_device.h b/source/modules/asura-core/graphics/gfx_device.h index c93717f..3c5b383 100644 --- a/source/modules/asura-core/graphics/gfx_device.h +++ b/source/modules/asura-core/graphics/gfx_device.h @@ -33,12 +33,6 @@ namespace AsuraEngine GL_PARAM_MAX_TEXTURE_UNIT = 1, }; - /// - /// OpenGL上下文,用来做一些opengl状态的追踪。在编辑器多窗口环境下,一个窗口对应一个hwnd, - /// 一个hdc,以及数个opengl context,如果使用wglMakeCurrent(hdc, glc)指定当前线程耳朵 - /// 渲染窗口hdc和opengl上下文glc,gl中记录的就是任意一个线程的任意一个窗口的任意一个OpenGL - /// 上下文的状态,不支持多上下文渲染。 - /// class GfxDevice : public AEScripting::Portable { public: @@ -46,6 +40,8 @@ namespace AsuraEngine GfxDevice(); ~GfxDevice(); + static GfxDevice& Get(); + int GetParam(GLParams param); bool Init(const AEMath::Recti& viewport); @@ -54,8 +50,8 @@ namespace AsuraEngine void SetViewport(const AEMath::Recti viewport); const AEMath::Recti& GetViewport(); - void UseShader(Shader* shader); - void UnuseShader(); + void UseShader(Shader* shader); + void UnuseShader(); Shader* GetShader(); void DrawArrays(GLenum mode, GLint first, GLsizei count); @@ -69,16 +65,16 @@ namespace AsuraEngine 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); - AEMath::Matrix44& GetMatrix(MatrixMode mode); - AEMath::Matrix44 GetMVPMatrix(); uint GetMatrixDepth(); uint GetMatrixIndex(); + AEMath::Matrix44& GetMatrix(MatrixMode mode); + AEMath::Matrix44 GetMVPMatrix(); - void SetDrawColor(float r, float g, float b, float a); + void SetDrawColor(float r, float g, float b, float a); Color& GetDrawColor(); - void WipeError(); - bool HasError(); + void WipeError(); + bool HasError(); GLenum GetError(); struct @@ -103,7 +99,7 @@ namespace AsuraEngine friend class Profiler; - //----------------------------------------------------------------------------// + luaxport: LUAX_DECL_SINGLETON(GfxDevice); @@ -121,17 +117,12 @@ namespace AsuraEngine LUAX_DECL_METHOD(_Ortho); LUAX_DECL_METHOD(_GetMatrixDepth); LUAX_DECL_METHOD(_GetMatrixIndex); - LUAX_DECL_METHOD(_UseShader); LUAX_DECL_METHOD(_UnuseShader); - //----------------------------------------------------------------------------// - }; - /// - /// OpenGL单例。 - /// + // 全局gfx device单例 extern GfxDevice gfx; } -- cgit v1.1-26-g67d0