summaryrefslogtreecommitdiff
path: root/source/modules/asura-core/graphics/gl.cpp
blob: e199a41d2844dfb788471b3c1deff27f10cd571f (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
#include <asura-utils/type.h>

#include "../core_config.h"

#include "gl.h"
#include "shader.h"

using namespace AEMath;

namespace AsuraEngine
{
	namespace Graphics
	{

		static bool _instantiated = false;

		// 
		OpenGL gl;

		OpenGL::OpenGL()
		{
			// Ҫڶʵ
			ASSERT(!_instantiated);
			_instantiated = true;
		}

		OpenGL::~OpenGL()
		{
		}

		//------------------------------------------------------------------------------//

		void OpenGL::SetViewport(const Recti v)
		{
			glViewport(v.x, v.y, v.w, v.h);
			state.viewport = v; 
		}

		Recti OpenGL::GetViewport()
		{
			return state.viewport;
		}

		void OpenGL::UseShader(Shader* shader)
		{
			glUseProgram(shader->GetGLProgramHandle());
			state.shader = shader;
		}

		void OpenGL::UnuseShader()
		{
			state.shader = nullptr;
		}

	}
}