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.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'source/modules/asura-core/graphics/gl.cpp') diff --git a/source/modules/asura-core/graphics/gl.cpp b/source/modules/asura-core/graphics/gl.cpp index 9ffe010..e199a41 100644 --- a/source/modules/asura-core/graphics/gl.cpp +++ b/source/modules/asura-core/graphics/gl.cpp @@ -1,7 +1,9 @@ #include #include "../core_config.h" + #include "gl.h" +#include "shader.h" using namespace AEMath; @@ -10,15 +12,16 @@ namespace AsuraEngine namespace Graphics { - bool OpenGL::instantiated = false; + static bool _instantiated = false; // 单例 OpenGL gl; OpenGL::OpenGL() { - ASSERT(!instantiated); - instantiated = true; + // 不要创建第二个实例 + ASSERT(!_instantiated); + _instantiated = true; } OpenGL::~OpenGL() @@ -38,7 +41,16 @@ namespace AsuraEngine return state.viewport; } + void OpenGL::UseShader(Shader* shader) + { + glUseProgram(shader->GetGLProgramHandle()); + state.shader = shader; + } + void OpenGL::UnuseShader() + { + state.shader = nullptr; + } } } \ No newline at end of file -- cgit v1.1-26-g67d0