diff options
Diffstat (limited to 'source/modules/asura-core/graphics/gfx_device.h')
-rw-r--r-- | source/modules/asura-core/graphics/gfx_device.h | 180 |
1 files changed, 89 insertions, 91 deletions
diff --git a/source/modules/asura-core/graphics/gfx_device.h b/source/modules/asura-core/graphics/gfx_device.h index 385f703..8d401dc 100644 --- a/source/modules/asura-core/graphics/gfx_device.h +++ b/source/modules/asura-core/graphics/gfx_device.h @@ -13,129 +13,127 @@ #include "color.h" #include "matrix_stack.h" -namespace AsuraEngine -{ - namespace Graphics - { +namespace_begin(AsuraEngine) +namespace_begin(Graphics) - class Profiler; - class Shader; - class GPUBuffer; - class Canvas; +class Profiler; +class Shader; +class GPUBuffer; +class Canvas; - enum MatrixMode - { - MATRIX_MODE_PROJECTION = 0, - MATRIX_MODE_MODEL = 1, - MATRIX_MODE_VIEW = 2, - }; +enum MatrixMode +{ + MATRIX_MODE_PROJECTION = 0, + MATRIX_MODE_MODEL = 1, + MATRIX_MODE_VIEW = 2, +}; - enum GLParams - { - GL_PARAM_MAX_TEXTURE_UNIT = 1, - }; +enum GLParams +{ + GL_PARAM_MAX_TEXTURE_UNIT = 1, +}; - class GfxDevice : public AEScripting::Portable<GfxDevice> - { - public: +class GfxDevice : public AEScripting::Portable<GfxDevice> +{ +public: - GfxDevice(); - ~GfxDevice(); + GfxDevice(); + ~GfxDevice(); - static GfxDevice& Get(); + 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(); + const AEMath::Recti& GetViewport(); - void SetMatrixMode(MatrixMode mode); - MatrixMode GetMatrixMode(); + 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(); - AEMath::Matrix44& GetMatrix(MatrixMode mode); - AEMath::Matrix44 GetMVPMatrix(); + AEMath::Matrix44& GetMatrix(MatrixMode mode); + AEMath::Matrix44 GetMVPMatrix(); - void SetDrawColor(float r, float g, float b, float a); - Color& GetDrawColor(); + void SetDrawColor(float r, float g, float b, float a); + Color& GetDrawColor(); - void SetActiveCanvas(Canvas* = NULL); - Canvas* GetActiveCanvas() const; + void SetActiveCanvas(Canvas* = NULL); + Canvas* GetActiveCanvas() const; - void SetActiveShader(Shader* = NULL); - Shader* GetActiveShader() const; + void SetActiveShader(Shader* = NULL); + Shader* GetActiveShader() const; - void DrawArrays(GLenum mode, GLint first, GLsizei count); + void DrawArrays(GLenum mode, GLint first, GLsizei count); - void WipeError(); - bool HasError(); - GLenum GetError(); + void WipeError(); + bool HasError(); + GLenum GetError(); - private: +private: - friend class Profiler; + 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; + 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; + struct + { + uint drawCall; ///< ͳdrawcall + uint canvasSwitch; ///< лtextureĴ + uint shaderSwitch; ///< лshaderĴ + } stats; #endif - luaxport: +luaxport: - LUAX_DECL_SINGLETON(GfxDevice); + LUAX_DECL_SINGLETON(GfxDevice); - LUAX_DECL_ENUM(MatrixMode, 1); - LUAX_DECL_ENUM(GLParams, 1); + 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); + 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 gfx; +// ȫ GfxDevice +extern GfxDevice gfx; - } -} +namespace_end +namespace_end #endif
\ No newline at end of file |