diff --git a/include/Nazara/Renderer/Shader.hpp b/include/Nazara/Renderer/Shader.hpp index c019a1dd0..7e3b9c4f4 100644 --- a/include/Nazara/Renderer/Shader.hpp +++ b/include/Nazara/Renderer/Shader.hpp @@ -8,6 +8,7 @@ #define NAZARA_SHADER_HPP #include +#include #include #include #include @@ -51,6 +52,7 @@ class NAZARA_API NzShader : public NzResource, NzNonCopyable bool Lock(); bool SendBoolean(int location, bool value); + bool SendColor(int location, const NzColor& color); bool SendDouble(int location, double value); bool SendFloat(int location, float value); bool SendInteger(int location, int value); diff --git a/src/Nazara/Renderer/GLSLShader.cpp b/src/Nazara/Renderer/GLSLShader.cpp index d68bdb62c..34608c57a 100644 --- a/src/Nazara/Renderer/GLSLShader.cpp +++ b/src/Nazara/Renderer/GLSLShader.cpp @@ -318,6 +318,27 @@ bool NzGLSLShader::SendBoolean(int location, bool value) return true; } +bool NzGLSLShader::SendColor(int location, const NzColor& color) +{ + NzVector3f vecColor(color.r/255.f, color.g/255.f, color.b/255.f); + + if (glProgramUniform3fv) + glProgramUniform3fv(m_program, location, 1, vecColor); + else + { + if (!Lock()) + { + NazaraError("Failed to lock shader"); + return false; + } + + glUniform3fv(location, 1, vecColor); + Unlock(); + } + + return true; +} + bool NzGLSLShader::SendDouble(int location, double value) { if (glProgramUniform1d) diff --git a/src/Nazara/Renderer/GLSLShader.hpp b/src/Nazara/Renderer/GLSLShader.hpp index 35735c678..551bc43b7 100644 --- a/src/Nazara/Renderer/GLSLShader.hpp +++ b/src/Nazara/Renderer/GLSLShader.hpp @@ -41,6 +41,7 @@ class NzGLSLShader : public NzShaderImpl, NzResourceListener bool Lock(); bool SendBoolean(int location, bool value); + bool SendColor(int location, const NzColor& color); bool SendDouble(int location, double value); bool SendFloat(int location, float value); bool SendInteger(int location, int value); diff --git a/src/Nazara/Renderer/Shader.cpp b/src/Nazara/Renderer/Shader.cpp index bb4d63ebb..0a606f78d 100644 --- a/src/Nazara/Renderer/Shader.cpp +++ b/src/Nazara/Renderer/Shader.cpp @@ -327,6 +327,25 @@ bool NzShader::SendBoolean(int location, bool value) return m_impl->SendBoolean(location, value); } +bool NzShader::SendColor(int location, const NzColor& color) +{ + #if NAZARA_RENDERER_SAFE + if (!m_impl) + { + NazaraError("Shader not created"); + return false; + } + + if (location == -1) + { + NazaraError("Invalid location"); + return false; + } + #endif + + return m_impl->SendColor(location, color); +} + bool NzShader::SendDouble(int location, double value) { #if NAZARA_RENDERER_SAFE diff --git a/src/Nazara/Renderer/ShaderImpl.hpp b/src/Nazara/Renderer/ShaderImpl.hpp index cc826788e..939c39756 100644 --- a/src/Nazara/Renderer/ShaderImpl.hpp +++ b/src/Nazara/Renderer/ShaderImpl.hpp @@ -9,10 +9,6 @@ #include -class NzTexture; -class NzVertexBuffer; -class NzVertexDeclaration; - class NzShaderImpl { friend class NzRenderer; @@ -41,6 +37,7 @@ class NzShaderImpl virtual bool Lock() = 0; virtual bool SendBoolean(int location, bool value) = 0; + virtual bool SendColor(int location, const NzColor& color) = 0; virtual bool SendDouble(int location, double value) = 0; virtual bool SendFloat(int location, float value) = 0; virtual bool SendInteger(int location, int value) = 0;