diff options
author | chai <chaifix@163.com> | 2019-08-01 09:15:04 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-08-01 09:15:04 +0800 |
commit | 99b90496765df21c5f377f42b9ed073ccb34c1fd (patch) | |
tree | 201cade18b6571d6ab5318945aed59a3610295a5 /source/modules/asura-core/graphics/shader.cpp | |
parent | 084623519e95f0ab0cf4bc328b5fa736d679c5bd (diff) |
*misc
Diffstat (limited to 'source/modules/asura-core/graphics/shader.cpp')
-rw-r--r-- | source/modules/asura-core/graphics/shader.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/source/modules/asura-core/graphics/shader.cpp b/source/modules/asura-core/graphics/shader.cpp index eff62f0..74bf7a8 100644 --- a/source/modules/asura-core/graphics/shader.cpp +++ b/source/modules/asura-core/graphics/shader.cpp @@ -24,12 +24,12 @@ Shader::~Shader() void Shader::SetActive(Shader* shader) { - gfx.SetActiveShader(shader); + g_Device.SetActiveShader(shader); } Shader* Shader::GetActive() { - return gfx.GetActiveShader(); + return g_Device.GetActiveShader(); } bool Shader::Load(const string& vert, const string& frag) @@ -157,56 +157,56 @@ GLuint Shader::GetGLProgram() void Shader::SetUniformFloat(uint loc, float value) { - if(gfx.GetActiveShader() == this) + if(g_Device.GetActiveShader() == this) glUniform1f(loc, value); } bool Shader::SetUniformTexture(uint loc, const Texture& texture) { - if (gfx.GetActiveShader() != this) + if (g_Device.GetActiveShader() != this) return false; - gfx.WipeError(); + g_Device.WipeError(); glActiveTexture(GL_TEXTURE0 + texUnit); - if (gfx.HasError()) + if (g_Device.HasError()) return false; GLint tex = texture.GetGLTexture(); glBindTexture(GL_TEXTURE_2D, tex); - if (gfx.HasError()) + if (g_Device.HasError()) return false; glUniform1i(loc, texUnit); - if (gfx.HasError()) + if (g_Device.HasError()) return false; ++texUnit; } void Shader::SetUniformVector2(uint loc, const Math::Vector2f& vec2) { - if (gfx.GetActiveShader() == this) + if (g_Device.GetActiveShader() == this) glUniform2f(loc, vec2.x, vec2.y); } void Shader::SetUniformVector3(uint loc, const Math::Vector3f& vec3) { - if (gfx.GetActiveShader() == this) + if (g_Device.GetActiveShader() == this) glUniform3f(loc, vec3.x, vec3.y, vec3.z); } void Shader::SetUniformVector4(uint loc, const Math::Vector4f& vec4) { - if (gfx.GetActiveShader() == this) + if (g_Device.GetActiveShader() == this) glUniform4f(loc, vec4.x, vec4.y, vec4.z, vec4.w); } void Shader::SetUniformMatrix44(uint loc, const Math::Matrix44& mat) { - if (gfx.GetActiveShader() == this) + if (g_Device.GetActiveShader() == this) glUniformMatrix4fv(loc, 1, GL_FALSE, mat.GetElements()); } void Shader::SetUniformColor(uint loc, const Color& color) { - if (gfx.GetActiveShader() == this) + if (g_Device.GetActiveShader() == this) glUniform4f(loc, color.r, color.g, color.b, color.a); } |