diff options
Diffstat (limited to 'source/modules/asura-core/graphics')
-rw-r--r-- | source/modules/asura-core/graphics/gfx_device.cpp | 4 | ||||
-rw-r--r-- | source/modules/asura-core/graphics/gfx_device.h | 2 | ||||
-rw-r--r-- | source/modules/asura-core/graphics/gpu_buffer.cpp | 10 | ||||
-rw-r--r-- | source/modules/asura-core/graphics/shader.cpp | 26 |
4 files changed, 21 insertions, 21 deletions
diff --git a/source/modules/asura-core/graphics/gfx_device.cpp b/source/modules/asura-core/graphics/gfx_device.cpp index 234ab23..2751a9d 100644 --- a/source/modules/asura-core/graphics/gfx_device.cpp +++ b/source/modules/asura-core/graphics/gfx_device.cpp @@ -16,7 +16,7 @@ namespace_begin(Graphics) static bool instantiated = false; #endif -GfxDevice gfx; +GfxDevice g_Device; GfxDevice::GfxDevice() { @@ -32,7 +32,7 @@ GfxDevice::~GfxDevice() GfxDevice& GfxDevice::Get() { - return gfx; + return g_Device; } static bool inited = false; diff --git a/source/modules/asura-core/graphics/gfx_device.h b/source/modules/asura-core/graphics/gfx_device.h index 8d401dc..fa22dd4 100644 --- a/source/modules/asura-core/graphics/gfx_device.h +++ b/source/modules/asura-core/graphics/gfx_device.h @@ -131,7 +131,7 @@ luaxport: }; // ȫ GfxDevice -extern GfxDevice gfx; +extern GfxDevice g_Device; namespace_end namespace_end diff --git a/source/modules/asura-core/graphics/gpu_buffer.cpp b/source/modules/asura-core/graphics/gpu_buffer.cpp index bf5ac6a..4271b70 100644 --- a/source/modules/asura-core/graphics/gpu_buffer.cpp +++ b/source/modules/asura-core/graphics/gpu_buffer.cpp @@ -69,16 +69,16 @@ bool GPUBuffer::Fill(const void * data, size_t size, uint offset) return false; if (m_Buffer == 0) { - gfx.WipeError(); + g_Device.WipeError(); glGenBuffers(1, &m_Buffer); if (m_Buffer == 0) throw Exception("OpenGL glGenBuffers failed."); glBindBuffer(m_Target, m_Buffer); glBufferData(m_Target, m_Size, NULL, m_Usage); - if (gfx.HasError()) + if (g_Device.HasError()) { glBindBuffer(m_Target, 0); - throw Exception("OpenGL glBufferData failed. Errorcode=%d.", gfx.GetError()); + throw Exception("OpenGL glBufferData failed. Errorcode=%d.", g_Device.GetError()); } #if ASURA_DEBUG m_Data = (byte*)malloc(size); @@ -88,10 +88,10 @@ bool GPUBuffer::Fill(const void * data, size_t size, uint offset) else glBindBuffer(m_Target, m_Buffer); glBufferSubData(m_Target, offset, size, data); - if (gfx.HasError()) + if (g_Device.HasError()) { glBindBuffer(m_Target, 0); - throw Exception("OpenGL glBufferSubData failed. Errorcode=%d.", gfx.GetError()); + throw Exception("OpenGL glBufferSubData failed. Errorcode=%d.", g_Device.GetError()); } glBindBuffer(m_Target, 0); #if ASURA_DEBUG 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); } |