diff options
author | chai <chaifix@163.com> | 2019-08-16 08:54:08 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-08-16 08:54:08 +0800 |
commit | a077eb38b01292611f4f6031b75e3e2c1c20f06e (patch) | |
tree | 8f760483d7b0290952bbdb5bcd8f3943102aeb3a /source/modules/asura-core/graphics/shader.cpp | |
parent | 6a065c913e9308cc72e1ad0723b6167048f439b6 (diff) |
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 329b3f1..56d638d 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) { - g_Device.SetActiveShader(shader); + g_GfxDevice.SetActiveShader(shader); } Shader* Shader::GetActive() { - return g_Device.GetActiveShader(); + return g_GfxDevice.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(g_Device.GetActiveShader() == this) + if(g_GfxDevice.GetActiveShader() == this) glUniform1f(loc, value); } bool Shader::SetUniformTexture(uint loc, const Texture& texture) { - if (g_Device.GetActiveShader() != this) + if (g_GfxDevice.GetActiveShader() != this) return false; - g_Device.WipeError(); + g_GfxDevice.WipeError(); glActiveTexture(GL_TEXTURE0 + texUnit); - if (g_Device.HasError()) + if (g_GfxDevice.HasError()) return false; GLint tex = texture.GetGLTexture(); glBindTexture(GL_TEXTURE_2D, tex); - if (g_Device.HasError()) + if (g_GfxDevice.HasError()) return false; glUniform1i(loc, texUnit); - if (g_Device.HasError()) + if (g_GfxDevice.HasError()) return false; ++texUnit; } void Shader::SetUniformVector2(uint loc, const Math::Vector2f& vec2) { - if (g_Device.GetActiveShader() == this) + if (g_GfxDevice.GetActiveShader() == this) glUniform2f(loc, vec2.x, vec2.y); } void Shader::SetUniformVector3(uint loc, const Math::Vector3f& vec3) { - if (g_Device.GetActiveShader() == this) + if (g_GfxDevice.GetActiveShader() == this) glUniform3f(loc, vec3.x, vec3.y, vec3.z); } void Shader::SetUniformVector4(uint loc, const Math::Vector4f& vec4) { - if (g_Device.GetActiveShader() == this) + if (g_GfxDevice.GetActiveShader() == this) glUniform4f(loc, vec4.x, vec4.y, vec4.z, vec4.w); } void Shader::SetUniformMatrix44(uint loc, const Math::Matrix44& mat) { - if (g_Device.GetActiveShader() == this) + if (g_GfxDevice.GetActiveShader() == this) glUniformMatrix4fv(loc, 1, GL_FALSE, mat.GetElements()); } void Shader::SetUniformColor(uint loc, const Color& color) { - if (g_Device.GetActiveShader() == this) + if (g_GfxDevice.GetActiveShader() == this) glUniform4f(loc, color.r, color.g, color.b, color.a); } |