diff options
Diffstat (limited to 'source/modules/asura-core/graphics/gl.cpp')
| -rw-r--r-- | source/modules/asura-core/graphics/gl.cpp | 25 | 
1 files changed, 19 insertions, 6 deletions
diff --git a/source/modules/asura-core/graphics/gl.cpp b/source/modules/asura-core/graphics/gl.cpp index 54fadb7..537d40d 100644 --- a/source/modules/asura-core/graphics/gl.cpp +++ b/source/modules/asura-core/graphics/gl.cpp @@ -4,6 +4,7 @@  #include "gl.h"  #include "shader.h" +#include "matrix_stack.h"  using namespace AEMath; @@ -30,6 +31,8 @@ namespace AsuraEngine  		{  		} +		static bool inited = false; +  		bool OpenGL::Init(const AEMath::Recti& view)  		{  			bool loaded = false; @@ -39,10 +42,17 @@ namespace AsuraEngine  #endif  			if (!loaded)  				return false; -			state.viewport = view; +			SetViewport(view); + +			inited = true;  			return true;  		} +		bool OpenGL::Inited() +		{ +			return inited; +		} +  		void OpenGL::WipeError()  		{  			while (glGetError() != GL_NO_ERROR); @@ -60,8 +70,8 @@ namespace AsuraEngine  		void OpenGL::SetViewport(const Recti v)  		{ +			state.viewport = v;  			glViewport(v.x, v.y, v.w, v.h); -			state.viewport = v;   		}  		const Recti& OpenGL::GetViewport() @@ -71,12 +81,15 @@ namespace AsuraEngine  		void OpenGL::UseShader(Shader* shader)  		{ -			glUseProgram(shader->GetGLProgramHandle()); +			glUseProgram(shader->GetGLProgram()); +			int err = gl.HasError();  			state.shader = shader; +			shader->OnUse();  		}  		void OpenGL::UnuseShader()  		{ +			state.shader->OnUnuse();  			state.shader = nullptr;  		} @@ -112,9 +125,9 @@ namespace AsuraEngine  			state.matrix[state.matrixMode].Rotate(angle, x, y, z);  		} -		void OpenGL::Translate(float x, float y, float z) +		void OpenGL::Translate(float x, float y)  		{ -			state.matrix[state.matrixMode].Translate(x, y, z); +			state.matrix[state.matrixMode].Translate(x, y);  		}  		void OpenGL::Scale(float x, float y, float z) @@ -129,7 +142,7 @@ namespace AsuraEngine  		AEMath::Matrix44& OpenGL::GetMatrix(MatrixMode mode)  		{ -			return state.matrix[state.matrixMode].GetTop(); +			return state.matrix[mode].GetTop();  		}  		uint OpenGL::GetMatrixDepth()  | 
