From 88b882ed0b432c6aff2063213e2f793a36dd25f7 Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 6 Jun 2019 00:11:18 +0800 Subject: *misc --- source/modules/asura-core/graphics/gl.h | 165 -------------------------------- 1 file changed, 165 deletions(-) delete mode 100644 source/modules/asura-core/graphics/gl.h (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 deleted file mode 100644 index 6c6ff30..0000000 --- a/source/modules/asura-core/graphics/gl.h +++ /dev/null @@ -1,165 +0,0 @@ -#ifndef __ASURA_ENGINE_OPENGL_H__ -#define __ASURA_ENGINE_OPENGL_H__ - -#include - -#include - -#include -#include -#include -#include - -#include "color.h" -#include "matrix_stack.h" - -namespace AsuraEngine -{ - namespace Graphics - { - - class Profiler; - class Shader; - - enum MatrixMode - { - MATRIX_MODE_PROJECTION = 0, - MATRIX_MODE_MODEL = 1, - MATRIX_MODE_VIEW = 2, - }; - - enum GLParams - { - GL_PARAM_MAX_TEXTURE_UNIT = 1, - }; - - /// - /// OpenGL上下文,用来做一些opengl状态的追踪。在编辑器多窗口环境下,一个窗口对应一个hwnd, - /// 一个hdc,以及数个opengl context,如果使用wglMakeCurrent(hdc, glc)指定当前线程耳朵 - /// 渲染窗口hdc和opengl上下文glc,gl中记录的就是任意一个线程的任意一个窗口的任意一个OpenGL - /// 上下文的状态,不支持多上下文渲染。 - /// - class OpenGL : public AEScripting::Portable - { - public: - - OpenGL(); - ~OpenGL(); - - /// - /// 获得常量值 - /// - int GetParam(GLParams param); - - /// - /// 初始化OpenGL上下文参数,发生在创建OpenGL上下文之后。此函数会注册OpenGL函数的地址。 - /// - bool Init(const AEMath::Recti& viewport); - bool Inited(); - - void SetViewport(const AEMath::Recti viewport); - const AEMath::Recti& GetViewport(); - - void UseShader(Shader* shader); - void UnuseShader(); - Shader* GetShader(); - - /// - /// 用来方便统计drawcall - /// - void DrawArrays(GLenum mode, GLint first, GLsizei count); - - /// - /// Matrix stack相关操作 - /// - 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); - AEMath::Matrix44& GetMatrix(MatrixMode mode); - AEMath::Matrix44 GetMVPMatrix(); - uint GetMatrixDepth(); - uint GetMatrixIndex(); - - void SetDrawColor(float r, float g, float b, float a); - Color& GetDrawColor(); - - /// - /// 清理错误提示 - /// - void WipeError(); - bool HasError(); - GLenum GetError(); - - /// - /// OpenGL3.0以后由用户管理矩阵变换、视口、shader等参数,这里保存一些OpenGL状态。注意 - /// 似乎全进程的,也就是说,Asura不支持多线程渲染。OpenGL上下文的创建使得一个上下 - /// 文绑定在一个HDC\窗口上,由于窗口是在特定线程创建的,所以OpenGL上下文也绑定了一个 - /// 特定的线程。同一个线程的不同HDC\窗口可以共享同一个OpenGL上下文。共享上下文是为了 - /// 共享上下文中创建的textuer\shader等handle。 - /// - struct - { - Shader* shader; ///< 当前使用的shader - AEMath::Recti viewport; ///< 当前的视区,在切换HDC或者本窗口大小改变或者部分刷新时变动 - MatrixStack matrix[3]; ///< model, view, projection矩阵 - MatrixMode matrixMode; ///< 当前操作的矩阵 - AEMath::Matrix44 mvpMatrix; ///< mvp matrix - Color drawColor; ///< 绘制的颜色 - } state; - -#if ASURA_GL_PROFILE - struct - { - uint drawCall; ///< 统计drawcall - uint canvasSwitch; ///< 切换texture的次数 - uint shaderSwitch; ///< 切换shader的次数 - } stats; -#endif - - private: - - friend class Profiler; - - //----------------------------------------------------------------------------// - - LUAX_DECL_SINGLETON(OpenGL); - - 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); - - //----------------------------------------------------------------------------// - - bool mUpdateMVPMatrix; - - }; - - /// - /// OpenGL单例。 - /// - extern OpenGL gl; - - } -} - -#endif \ No newline at end of file -- cgit v1.1-26-g67d0