summaryrefslogtreecommitdiff
path: root/source/modules/asura-core/graphics/shader.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-06-06 00:11:18 +0800
committerchai <chaifix@163.com>2019-06-06 00:11:18 +0800
commit88b882ed0b432c6aff2063213e2f793a36dd25f7 (patch)
tree5fe5d5334050e1a1146aa63e61e88aa2f5170727 /source/modules/asura-core/graphics/shader.cpp
parentf6c0498c9728a286c13980ed3b60763d02e1b3a0 (diff)
*misc
Diffstat (limited to 'source/modules/asura-core/graphics/shader.cpp')
-rw-r--r--source/modules/asura-core/graphics/shader.cpp55
1 files changed, 18 insertions, 37 deletions
diff --git a/source/modules/asura-core/graphics/shader.cpp b/source/modules/asura-core/graphics/shader.cpp
index 833cef0..866c4da 100644
--- a/source/modules/asura-core/graphics/shader.cpp
+++ b/source/modules/asura-core/graphics/shader.cpp
@@ -1,6 +1,6 @@
#include <asura-utils/exceptions/exception.h>
-#include "gl.h"
+#include "gfx_device.h"
#include "shader.h"
using namespace std;
@@ -123,59 +123,65 @@ namespace AsuraEngine
void Shader::SetUniformFloat(uint loc, float value)
{
- if(gl.state.shader == this)
+ if(gfx.state.shader == this)
glUniform1f(loc, value);
}
bool Shader::SetUniformTexture(uint loc, const Texture& texture)
{
- if (gl.state.shader != this)
+ if (gfx.state.shader != this)
return false;
- gl.WipeError();
+ gfx.WipeError();
glActiveTexture(GL_TEXTURE0 + _texture_unit);
- if (gl.HasError())
+ if (gfx.HasError())
return false;
GLint tex = texture.GetGLTexture();
glBindTexture(GL_TEXTURE_2D, tex);
- if (gl.HasError())
+ if (gfx.HasError())
return false;
glUniform1i(loc, _texture_unit);
- if (gl.HasError())
+ if (gfx.HasError())
return false;
++_texture_unit;
}
void Shader::SetUniformVector2(uint loc, const Math::Vector2f& vec2)
{
- if (gl.state.shader == this)
+ if (gfx.state.shader == this)
glUniform2f(loc, vec2.x, vec2.y);
}
void Shader::SetUniformVector3(uint loc, const Math::Vector3f& vec3)
{
- if (gl.state.shader == this)
+ if (gfx.state.shader == this)
glUniform3f(loc, vec3.x, vec3.y, vec3.z);
}
void Shader::SetUniformVector4(uint loc, const Math::Vector4f& vec4)
{
- if (gl.state.shader == this)
+ if (gfx.state.shader == this)
glUniform4f(loc, vec4.x, vec4.y, vec4.z, vec4.w);
}
void Shader::SetUniformMatrix44(uint loc, const Math::Matrix44& mat)
{
- if (gl.state.shader == this)
+ if (gfx.state.shader == this)
glUniformMatrix4fv(loc, 1, GL_FALSE, mat.GetElements());
}
void Shader::SetUniformColor(uint loc, const Color& color)
{
- if (gl.state.shader == this)
+ if (gfx.state.shader == this)
glUniform4f(loc, color.r, color.g, color.b, color.a);
}
+ //void Shader::GetUniform()
+ //{
+ // //if(gfx.state.shader == this)
+ // // glGetUniformfv()
+ //}
+
uint Shader::GetGLTextureUnitCount()
{
GLint maxTextureUnits;
@@ -244,30 +250,5 @@ namespace AsuraEngine
glDisableVertexAttribArray(loc);
}
- void Shader::SetBuiltInModelMatrix(uint loc)
- {
- SetUniformMatrix44(loc, gl.GetMatrix(MATRIX_MODE_MODEL));
- }
-
- void Shader::SetBuiltInViewMatrix(uint loc)
- {
- SetUniformMatrix44(loc, gl.GetMatrix(MATRIX_MODE_VIEW));
- }
-
- void Shader::SetBuiltInProjectionMatrix(uint loc)
- {
- SetUniformMatrix44(loc, gl.GetMatrix(MATRIX_MODE_PROJECTION));
- }
-
- void Shader::SetBuiltInMVPMatrix(uint loc)
- {
- SetUniformMatrix44(loc, gl.GetMVPMatrix());
- }
-
- void Shader::SetBuiltInDrawColor(uint loc)
- {
- SetUniformColor(loc, gl.GetDrawColor());
- }
-
}
} \ No newline at end of file