Shader::SendTexture can now return texture unit
Former-commit-id: 38d5e5dedf94113933bb2090040feec602a4716c
This commit is contained in:
parent
119a1420d1
commit
eb585116b1
|
|
@ -58,7 +58,7 @@ class NAZARA_API NzShader : public NzResource, NzNonCopyable
|
||||||
bool SendInteger(int location, int value);
|
bool SendInteger(int location, int value);
|
||||||
bool SendMatrix(int location, const NzMatrix4d& matrix);
|
bool SendMatrix(int location, const NzMatrix4d& matrix);
|
||||||
bool SendMatrix(int location, const NzMatrix4f& matrix);
|
bool SendMatrix(int location, const NzMatrix4f& matrix);
|
||||||
bool SendTexture(int location, const NzTexture* texture);
|
bool SendTexture(int location, const NzTexture* texture, nzUInt8* textureUnit = nullptr);
|
||||||
bool SendVector(int location, const NzVector2d& vector);
|
bool SendVector(int location, const NzVector2d& vector);
|
||||||
bool SendVector(int location, const NzVector2f& vector);
|
bool SendVector(int location, const NzVector2f& vector);
|
||||||
bool SendVector(int location, const NzVector3d& vector);
|
bool SendVector(int location, const NzVector3d& vector);
|
||||||
|
|
|
||||||
|
|
@ -430,7 +430,7 @@ bool NzGLSLShader::SendMatrix(int location, const NzMatrix4f& matrix)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NzGLSLShader::SendTexture(int location, const NzTexture* texture)
|
bool NzGLSLShader::SendTexture(int location, const NzTexture* texture, nzUInt8* textureUnit)
|
||||||
{
|
{
|
||||||
auto it = m_textures.find(location);
|
auto it = m_textures.find(location);
|
||||||
if (it != m_textures.end())
|
if (it != m_textures.end())
|
||||||
|
|
@ -451,6 +451,9 @@ bool NzGLSLShader::SendTexture(int location, const NzTexture* texture)
|
||||||
else
|
else
|
||||||
m_textures.erase(it); // On supprime le slot
|
m_textures.erase(it); // On supprime le slot
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (textureUnit)
|
||||||
|
*textureUnit = slot.unit;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -493,9 +496,6 @@ bool NzGLSLShader::SendTexture(int location, const NzTexture* texture)
|
||||||
slot.enabled = texture->IsValid();
|
slot.enabled = texture->IsValid();
|
||||||
slot.unit = unit;
|
slot.unit = unit;
|
||||||
slot.texture = texture;
|
slot.texture = texture;
|
||||||
texture->AddResourceListener(this, location);
|
|
||||||
|
|
||||||
m_textures[location] = slot;
|
|
||||||
|
|
||||||
if (slot.enabled)
|
if (slot.enabled)
|
||||||
{
|
{
|
||||||
|
|
@ -513,6 +513,12 @@ bool NzGLSLShader::SendTexture(int location, const NzTexture* texture)
|
||||||
Unlock();
|
Unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_textures[location] = slot;
|
||||||
|
texture->AddResourceListener(this, location);
|
||||||
|
|
||||||
|
if (textureUnit)
|
||||||
|
*textureUnit = unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ class NzGLSLShader : public NzShaderImpl, NzResourceListener
|
||||||
bool SendInteger(int location, int value);
|
bool SendInteger(int location, int value);
|
||||||
bool SendMatrix(int location, const NzMatrix4d& matrix);
|
bool SendMatrix(int location, const NzMatrix4d& matrix);
|
||||||
bool SendMatrix(int location, const NzMatrix4f& matrix);
|
bool SendMatrix(int location, const NzMatrix4f& matrix);
|
||||||
bool SendTexture(int location, const NzTexture* texture);
|
bool SendTexture(int location, const NzTexture* texture, nzUInt8* textureUnit = nullptr);
|
||||||
bool SendVector(int location, const NzVector2d& vector);
|
bool SendVector(int location, const NzVector2d& vector);
|
||||||
bool SendVector(int location, const NzVector2f& vector);
|
bool SendVector(int location, const NzVector2f& vector);
|
||||||
bool SendVector(int location, const NzVector3d& vector);
|
bool SendVector(int location, const NzVector3d& vector);
|
||||||
|
|
|
||||||
|
|
@ -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)
|
bool NzShader::SendTexture(int location, const NzTexture* texture, nzUInt8* textureUnit)
|
||||||
{
|
{
|
||||||
#if NAZARA_RENDERER_SAFE
|
#if NAZARA_RENDERER_SAFE
|
||||||
if (!m_impl)
|
if (!m_impl)
|
||||||
|
|
@ -461,7 +461,7 @@ bool NzShader::SendTexture(int location, const NzTexture* texture)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return m_impl->SendTexture(location, texture);
|
return m_impl->SendTexture(location, texture, textureUnit);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NzShader::SendVector(int location, const NzVector2d& vector)
|
bool NzShader::SendVector(int location, const NzVector2d& vector)
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ class NzShaderImpl
|
||||||
virtual bool SendInteger(int location, int value) = 0;
|
virtual bool SendInteger(int location, int value) = 0;
|
||||||
virtual bool SendMatrix(int location, const NzMatrix4d& matrix) = 0;
|
virtual bool SendMatrix(int location, const NzMatrix4d& matrix) = 0;
|
||||||
virtual bool SendMatrix(int location, const NzMatrix4f& matrix) = 0;
|
virtual bool SendMatrix(int location, const NzMatrix4f& matrix) = 0;
|
||||||
virtual bool SendTexture(int location, const NzTexture* texture) = 0;
|
virtual bool SendTexture(int location, const NzTexture* texture, nzUInt8* textureUnit = nullptr) = 0;
|
||||||
virtual bool SendVector(int location, const NzVector2d& vector) = 0;
|
virtual bool SendVector(int location, const NzVector2d& vector) = 0;
|
||||||
virtual bool SendVector(int location, const NzVector2f& vector) = 0;
|
virtual bool SendVector(int location, const NzVector2f& vector) = 0;
|
||||||
virtual bool SendVector(int location, const NzVector3d& vector) = 0;
|
virtual bool SendVector(int location, const NzVector3d& vector) = 0;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue