summaryrefslogtreecommitdiff
path: root/source/modules/asura-core/graphics/gl.h
blob: 9ca1f44d7dfff42f2165ce66092f0b4731f6d20c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef __ASURA_ENGINE_OPENGL_H__
#define __ASURA_ENGINE_OPENGL_H__

#include <stack>

#include <glad/glad.h>

#include <asura-utils/math/rect.hpp>
#include <asura-utils/math/matrix44.h>

#include "matrix_stack.h"

namespace AsuraEngine
{
	namespace Graphics
	{

		class Profiler;
		class Shader;

		///
		/// OpenGLģһЩopengl״̬׷١ڱ༭രڻ£һڶӦһhwnd
		/// һhdcԼopengl contextʹwglMakeCurrent(hdc, glc)ָǰ̶߳
		/// Ⱦhdcopenglglcglм¼ľһ̵߳һڵһOpenGL
		/// ĵ״̬
		///
		class OpenGL
		{
		public:
			OpenGL();
			~OpenGL();

			void SetViewport(const AEMath::Recti viewport);
			AEMath::Recti GetViewport();

			void UseShader(Shader* shader);
			void UnuseShader();

			/// 
			/// OpenGL3.0Ժû任ӿڡshaderȲﱣһЩOpenGL״̬ע
			/// ƺȫ̵ģҲ˵Asuraֶ֧߳ȾOpenGLĵĴʹһ
			/// İһHDC\ϣڴض̴߳ģOpenGLҲһ
			/// ض̡߳ͬһ̵߳IJͬHDC\ڿԹͬһOpenGLġΪ
			/// дtextuer\shaderhandle
			/// 
			struct
			{
				Shader*       shader;           ///< ǰʹõshader
				AEMath::Recti viewport;         ///< ǰлHDC߱ڴСı߲ˢʱ䶯
				MatrixStack   projectionMatrix; ///< ͶӰ 
				MatrixStack   modelViewMatrix;  ///< 任
			} state;

		private:

			friend class Profiler;

		};

		///
		/// OpenGL
		///
		extern OpenGL gl;

	}
}

#endif