It is now possible to use const shaders

A non-constant shader is no longer required to bind or to send uniform


Former-commit-id: 8fd7c03b65a2d9fcea69516c023fee034299148c
This commit is contained in:
Lynix 2012-12-25 12:26:40 +01:00
parent d63c12bbd5
commit c65e3d5def
6 changed files with 36 additions and 36 deletions

View File

@ -44,7 +44,7 @@ class NAZARA_API NzRenderer
static unsigned int GetMaxRenderTargets(); static unsigned int GetMaxRenderTargets();
static unsigned int GetMaxTextureUnits(); static unsigned int GetMaxTextureUnits();
static float GetPointSize(); static float GetPointSize();
static NzShader* GetShader(); static const NzShader* GetShader();
static NzRenderTarget* GetTarget(); static NzRenderTarget* GetTarget();
static NzRectui GetViewport(); static NzRectui GetViewport();
@ -67,7 +67,7 @@ class NAZARA_API NzRenderer
static void SetLineWidth(float size); static void SetLineWidth(float size);
static void SetMatrix(nzMatrixType type, const NzMatrix4f& matrix); static void SetMatrix(nzMatrixType type, const NzMatrix4f& matrix);
static void SetPointSize(float size); static void SetPointSize(float size);
static bool SetShader(NzShader* shader); static bool SetShader(const NzShader* shader);
static void SetStencilCompareFunction(nzRendererComparison compareFunc); static void SetStencilCompareFunction(nzRendererComparison compareFunc);
static void SetStencilFailOperation(nzStencilOperation failOperation); static void SetStencilFailOperation(nzStencilOperation failOperation);
static void SetStencilMask(nzUInt32 mask); static void SetStencilMask(nzUInt32 mask);

View File

@ -51,20 +51,20 @@ class NAZARA_API NzShader : public NzResource, NzNonCopyable
bool Lock(); bool Lock();
bool SendBoolean(int location, bool value); bool SendBoolean(int location, bool value) const;
bool SendColor(int location, const NzColor& color); bool SendColor(int location, const NzColor& color) const;
bool SendDouble(int location, double value); bool SendDouble(int location, double value) const;
bool SendFloat(int location, float value); bool SendFloat(int location, float value) const;
bool SendInteger(int location, int value); bool SendInteger(int location, int value) const;
bool SendMatrix(int location, const NzMatrix4d& matrix); bool SendMatrix(int location, const NzMatrix4d& matrix) const;
bool SendMatrix(int location, const NzMatrix4f& matrix); bool SendMatrix(int location, const NzMatrix4f& matrix) const;
bool SendTexture(int location, const NzTexture* texture, nzUInt8* textureUnit = nullptr); bool SendTexture(int location, const NzTexture* texture, nzUInt8* textureUnit = nullptr) const;
bool SendVector(int location, const NzVector2d& vector); bool SendVector(int location, const NzVector2d& vector) const;
bool SendVector(int location, const NzVector2f& vector); bool SendVector(int location, const NzVector2f& vector) const;
bool SendVector(int location, const NzVector3d& vector); bool SendVector(int location, const NzVector3d& vector) const;
bool SendVector(int location, const NzVector3f& vector); bool SendVector(int location, const NzVector3f& vector) const;
bool SendVector(int location, const NzVector4d& vector); bool SendVector(int location, const NzVector4d& vector) const;
bool SendVector(int location, const NzVector4f& vector); bool SendVector(int location, const NzVector4f& vector) const;
void Unlock(); void Unlock();

View File

@ -124,7 +124,7 @@ void NzDebugDrawer::Draw(const NzCubef& cube)
if (!vertexBuffer->Unmap()) if (!vertexBuffer->Unmap())
NazaraWarning("Failed to unmap buffer"); NazaraWarning("Failed to unmap buffer");
NzShader* oldShader = NzRenderer::GetShader(); const NzShader* oldShader = NzRenderer::GetShader();
if (!NzRenderer::SetShader(shader)) if (!NzRenderer::SetShader(shader))
{ {
@ -198,7 +198,7 @@ void NzDebugDrawer::Draw(const NzSkeleton* skeleton)
if (vertexCount > 0) if (vertexCount > 0)
{ {
NzShader* oldShader = NzRenderer::GetShader(); const NzShader* oldShader = NzRenderer::GetShader();
if (!NzRenderer::SetShader(shader)) if (!NzRenderer::SetShader(shader))
{ {

View File

@ -30,7 +30,7 @@ NzMaterial::~NzMaterial()
void NzMaterial::Apply() const void NzMaterial::Apply() const
{ {
NzShader* shader = NzRenderer::GetShader(); const NzShader* shader = NzRenderer::GetShader();
#if NAZARA_RENDERER_SAFE #if NAZARA_RENDERER_SAFE
if (!shader) if (!shader)
{ {

View File

@ -76,7 +76,7 @@ namespace
nzUInt32 s_stencilMask; nzUInt32 s_stencilMask;
const NzIndexBuffer* s_indexBuffer; const NzIndexBuffer* s_indexBuffer;
NzRenderTarget* s_target; NzRenderTarget* s_target;
NzShader* s_shader; const NzShader* s_shader;
const NzVertexBuffer* s_vertexBuffer; const NzVertexBuffer* s_vertexBuffer;
const NzVertexDeclaration* s_vertexDeclaration; const NzVertexDeclaration* s_vertexDeclaration;
bool s_vaoUpdated; bool s_vaoUpdated;
@ -322,7 +322,7 @@ float NzRenderer::GetPointSize()
return pointSize; return pointSize;
} }
NzShader* NzRenderer::GetShader() const NzShader* NzRenderer::GetShader()
{ {
return s_shader; return s_shader;
} }
@ -742,7 +742,7 @@ void NzRenderer::SetPointSize(float size)
glPointSize(size); glPointSize(size);
} }
bool NzRenderer::SetShader(NzShader* shader) bool NzRenderer::SetShader(const NzShader* shader)
{ {
if (s_shader == shader) if (s_shader == shader)
return true; return true;

View File

@ -300,7 +300,7 @@ bool NzShader::Lock()
return m_impl->Lock(); return m_impl->Lock();
} }
bool NzShader::SendBoolean(int location, bool value) bool NzShader::SendBoolean(int location, bool value) const
{ {
#if NAZARA_RENDERER_SAFE #if NAZARA_RENDERER_SAFE
if (!m_impl) if (!m_impl)
@ -319,7 +319,7 @@ 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) bool NzShader::SendColor(int location, const NzColor& color) const
{ {
#if NAZARA_RENDERER_SAFE #if NAZARA_RENDERER_SAFE
if (!m_impl) if (!m_impl)
@ -338,7 +338,7 @@ bool NzShader::SendColor(int location, const NzColor& color)
return m_impl->SendColor(location, color); return m_impl->SendColor(location, color);
} }
bool NzShader::SendDouble(int location, double value) bool NzShader::SendDouble(int location, double value) const
{ {
#if NAZARA_RENDERER_SAFE #if NAZARA_RENDERER_SAFE
if (!NzRenderer::HasCapability(nzRendererCap_FP64)) if (!NzRenderer::HasCapability(nzRendererCap_FP64))
@ -363,7 +363,7 @@ bool NzShader::SendDouble(int location, double value)
return m_impl->SendDouble(location, value); return m_impl->SendDouble(location, value);
} }
bool NzShader::SendFloat(int location, float value) bool NzShader::SendFloat(int location, float value) const
{ {
#if NAZARA_RENDERER_SAFE #if NAZARA_RENDERER_SAFE
if (!m_impl) if (!m_impl)
@ -382,7 +382,7 @@ bool NzShader::SendFloat(int location, float value)
return m_impl->SendFloat(location, value); return m_impl->SendFloat(location, value);
} }
bool NzShader::SendInteger(int location, int value) bool NzShader::SendInteger(int location, int value) const
{ {
#if NAZARA_RENDERER_SAFE #if NAZARA_RENDERER_SAFE
if (!m_impl) if (!m_impl)
@ -401,7 +401,7 @@ bool NzShader::SendInteger(int location, int value)
return m_impl->SendInteger(location, value); return m_impl->SendInteger(location, value);
} }
bool NzShader::SendMatrix(int location, const NzMatrix4d& matrix) bool NzShader::SendMatrix(int location, const NzMatrix4d& matrix) const
{ {
#if NAZARA_RENDERER_SAFE #if NAZARA_RENDERER_SAFE
if (!NzRenderer::HasCapability(nzRendererCap_FP64)) if (!NzRenderer::HasCapability(nzRendererCap_FP64))
@ -426,7 +426,7 @@ bool NzShader::SendMatrix(int location, const NzMatrix4d& matrix)
return m_impl->SendMatrix(location, matrix); return m_impl->SendMatrix(location, matrix);
} }
bool NzShader::SendMatrix(int location, const NzMatrix4f& matrix) bool NzShader::SendMatrix(int location, const NzMatrix4f& matrix) const
{ {
#if NAZARA_RENDERER_SAFE #if NAZARA_RENDERER_SAFE
if (!m_impl) if (!m_impl)
@ -445,7 +445,7 @@ bool NzShader::SendMatrix(int location, const NzMatrix4f& matrix)
return m_impl->SendMatrix(location, matrix); return m_impl->SendMatrix(location, matrix);
} }
bool NzShader::SendTexture(int location, const NzTexture* texture, nzUInt8* textureUnit) bool NzShader::SendTexture(int location, const NzTexture* texture, nzUInt8* textureUnit) const
{ {
#if NAZARA_RENDERER_SAFE #if NAZARA_RENDERER_SAFE
if (!m_impl) if (!m_impl)
@ -464,7 +464,7 @@ bool NzShader::SendTexture(int location, const NzTexture* texture, nzUInt8* text
return m_impl->SendTexture(location, texture, textureUnit); return m_impl->SendTexture(location, texture, textureUnit);
} }
bool NzShader::SendVector(int location, const NzVector2d& vector) bool NzShader::SendVector(int location, const NzVector2d& vector) const
{ {
#if NAZARA_RENDERER_SAFE #if NAZARA_RENDERER_SAFE
if (!NzRenderer::HasCapability(nzRendererCap_FP64)) if (!NzRenderer::HasCapability(nzRendererCap_FP64))
@ -489,7 +489,7 @@ bool NzShader::SendVector(int location, const NzVector2d& vector)
return m_impl->SendVector(location, vector); return m_impl->SendVector(location, vector);
} }
bool NzShader::SendVector(int location, const NzVector2f& vector) bool NzShader::SendVector(int location, const NzVector2f& vector) const
{ {
#if NAZARA_RENDERER_SAFE #if NAZARA_RENDERER_SAFE
if (!m_impl) if (!m_impl)
@ -508,7 +508,7 @@ bool NzShader::SendVector(int location, const NzVector2f& vector)
return m_impl->SendVector(location, vector); return m_impl->SendVector(location, vector);
} }
bool NzShader::SendVector(int location, const NzVector3d& vector) bool NzShader::SendVector(int location, const NzVector3d& vector) const
{ {
#if NAZARA_RENDERER_SAFE #if NAZARA_RENDERER_SAFE
if (!NzRenderer::HasCapability(nzRendererCap_FP64)) if (!NzRenderer::HasCapability(nzRendererCap_FP64))
@ -533,7 +533,7 @@ bool NzShader::SendVector(int location, const NzVector3d& vector)
return m_impl->SendVector(location, vector); return m_impl->SendVector(location, vector);
} }
bool NzShader::SendVector(int location, const NzVector3f& vector) bool NzShader::SendVector(int location, const NzVector3f& vector) const
{ {
#if NAZARA_RENDERER_SAFE #if NAZARA_RENDERER_SAFE
if (!m_impl) if (!m_impl)
@ -552,7 +552,7 @@ bool NzShader::SendVector(int location, const NzVector3f& vector)
return m_impl->SendVector(location, vector); return m_impl->SendVector(location, vector);
} }
bool NzShader::SendVector(int location, const NzVector4d& vector) bool NzShader::SendVector(int location, const NzVector4d& vector) const
{ {
#if NAZARA_RENDERER_SAFE #if NAZARA_RENDERER_SAFE
if (!NzRenderer::HasCapability(nzRendererCap_FP64)) if (!NzRenderer::HasCapability(nzRendererCap_FP64))
@ -577,7 +577,7 @@ bool NzShader::SendVector(int location, const NzVector4d& vector)
return m_impl->SendVector(location, vector); return m_impl->SendVector(location, vector);
} }
bool NzShader::SendVector(int location, const NzVector4f& vector) bool NzShader::SendVector(int location, const NzVector4f& vector) const
{ {
#if NAZARA_RENDERER_SAFE #if NAZARA_RENDERER_SAFE
if (!m_impl) if (!m_impl)