From af7bdaa10ee71a319dc55c3c7556fa43a95c9dc9 Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 2 Apr 2019 21:45:33 +0800 Subject: *misc --- source/modules/asura-core/graphics/gl.h | 40 +++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 14 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 4d21a5a..9ca1f44 100644 --- a/source/modules/asura-core/graphics/gl.h +++ b/source/modules/asura-core/graphics/gl.h @@ -1,21 +1,28 @@ #ifndef __ASURA_ENGINE_OPENGL_H__ #define __ASURA_ENGINE_OPENGL_H__ -#include +#include #include +#include +#include + +#include "matrix_stack.h" + namespace AsuraEngine { namespace Graphics { class Profiler; + class Shader; /// - /// 用来做一些opengl状态的追踪。在编辑器多窗口环境下,一个窗口对应一个hwnd,一个hdc,以及 - /// 数个opengl context,如果使用wglMakeCurrent(hdc, glc)指定当前线程耳朵渲染窗口hdc和 - /// opengl上下文glc,gl中记录的就是任意一个线程的任意一个窗口的任意一个opengl上下文的状态, + /// OpenGL上下文,用来做一些opengl状态的追踪。在编辑器多窗口环境下,一个窗口对应一个hwnd, + /// 一个hdc,以及数个opengl context,如果使用wglMakeCurrent(hdc, glc)指定当前线程耳朵 + /// 渲染窗口hdc和opengl上下文glc,gl中记录的就是任意一个线程的任意一个窗口的任意一个OpenGL + /// 上下文的状态, /// class OpenGL { @@ -26,23 +33,28 @@ namespace AsuraEngine void SetViewport(const AEMath::Recti viewport); AEMath::Recti GetViewport(); - private: - - friend class Profiler; + void UseShader(Shader* shader); + void UnuseShader(); - /// - /// 控制opengl单例。 /// - static bool instantiated; - - /// - /// 记录opengl状态。 + /// OpenGL3.0以后由用户管理矩阵变换、视口、shader等参数,这里保存一些OpenGL状态。注意 + /// 似乎全进程的,也就是说,Asura不支持多线程渲染。OpenGL上下文的创建使得一个上下 + /// 文绑定在一个HDC\窗口上,由于窗口是在特定线程创建的,所以OpenGL上下文也绑定了一个 + /// 特定的线程。同一个线程的不同HDC\窗口可以共享同一个OpenGL上下文。共享上下文是为了 + /// 共享上下文中创建的textuer\shader等handle。 /// struct { - AEMath::Recti viewport; + Shader* shader; ///< 当前使用的shader + AEMath::Recti viewport; ///< 当前的视区,在切换HDC或者本窗口大小改变或者部分刷新时变动 + MatrixStack projectionMatrix; ///< 投影矩阵 + MatrixStack modelViewMatrix; ///< 变换矩阵 } state; + private: + + friend class Profiler; + }; /// -- cgit v1.1-26-g67d0