Added Shader::SendColor(Color)
Former-commit-id: e3af0e2cb75a437304ee274a6123114b41dd7d94
This commit is contained in:
parent
7cc520be95
commit
94bb765a77
|
|
@ -8,6 +8,7 @@
|
||||||
#define NAZARA_SHADER_HPP
|
#define NAZARA_SHADER_HPP
|
||||||
|
|
||||||
#include <Nazara/Prerequesites.hpp>
|
#include <Nazara/Prerequesites.hpp>
|
||||||
|
#include <Nazara/Core/Color.hpp>
|
||||||
#include <Nazara/Core/NonCopyable.hpp>
|
#include <Nazara/Core/NonCopyable.hpp>
|
||||||
#include <Nazara/Core/Resource.hpp>
|
#include <Nazara/Core/Resource.hpp>
|
||||||
#include <Nazara/Core/String.hpp>
|
#include <Nazara/Core/String.hpp>
|
||||||
|
|
@ -51,6 +52,7 @@ class NAZARA_API NzShader : public NzResource, NzNonCopyable
|
||||||
bool Lock();
|
bool Lock();
|
||||||
|
|
||||||
bool SendBoolean(int location, bool value);
|
bool SendBoolean(int location, bool value);
|
||||||
|
bool SendColor(int location, const NzColor& color);
|
||||||
bool SendDouble(int location, double value);
|
bool SendDouble(int location, double value);
|
||||||
bool SendFloat(int location, float value);
|
bool SendFloat(int location, float value);
|
||||||
bool SendInteger(int location, int value);
|
bool SendInteger(int location, int value);
|
||||||
|
|
|
||||||
|
|
@ -318,6 +318,27 @@ bool NzGLSLShader::SendBoolean(int location, bool value)
|
||||||
return true;
|
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)
|
bool NzGLSLShader::SendDouble(int location, double value)
|
||||||
{
|
{
|
||||||
if (glProgramUniform1d)
|
if (glProgramUniform1d)
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ class NzGLSLShader : public NzShaderImpl, NzResourceListener
|
||||||
bool Lock();
|
bool Lock();
|
||||||
|
|
||||||
bool SendBoolean(int location, bool value);
|
bool SendBoolean(int location, bool value);
|
||||||
|
bool SendColor(int location, const NzColor& color);
|
||||||
bool SendDouble(int location, double value);
|
bool SendDouble(int location, double value);
|
||||||
bool SendFloat(int location, float value);
|
bool SendFloat(int location, float value);
|
||||||
bool SendInteger(int location, int value);
|
bool SendInteger(int location, int value);
|
||||||
|
|
|
||||||
|
|
@ -327,6 +327,25 @@ bool NzShader::SendBoolean(int location, bool value)
|
||||||
return m_impl->SendBoolean(location, 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)
|
bool NzShader::SendDouble(int location, double value)
|
||||||
{
|
{
|
||||||
#if NAZARA_RENDERER_SAFE
|
#if NAZARA_RENDERER_SAFE
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,6 @@
|
||||||
|
|
||||||
#include <Nazara/Renderer/Shader.hpp>
|
#include <Nazara/Renderer/Shader.hpp>
|
||||||
|
|
||||||
class NzTexture;
|
|
||||||
class NzVertexBuffer;
|
|
||||||
class NzVertexDeclaration;
|
|
||||||
|
|
||||||
class NzShaderImpl
|
class NzShaderImpl
|
||||||
{
|
{
|
||||||
friend class NzRenderer;
|
friend class NzRenderer;
|
||||||
|
|
@ -41,6 +37,7 @@ class NzShaderImpl
|
||||||
virtual bool Lock() = 0;
|
virtual bool Lock() = 0;
|
||||||
|
|
||||||
virtual bool SendBoolean(int location, bool value) = 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 SendDouble(int location, double value) = 0;
|
||||||
virtual bool SendFloat(int location, float value) = 0;
|
virtual bool SendFloat(int location, float value) = 0;
|
||||||
virtual bool SendInteger(int location, int value) = 0;
|
virtual bool SendInteger(int location, int value) = 0;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue