Reworked texture samplers internal
Former-commit-id: d26f8f12ccc1730519c6fa7d4bec725a0396d9f1
This commit is contained in:
parent
b82cbc074b
commit
200f46b442
|
|
@ -39,8 +39,10 @@ class NAZARA_API NzTextureSampler
|
||||||
static void SetDefaultWrapMode(nzSamplerWrap wrapMode);
|
static void SetDefaultWrapMode(nzSamplerWrap wrapMode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Apply(const NzTexture* texture);
|
void Apply(const NzTexture* texture) const;
|
||||||
void Bind(unsigned int unit);
|
void Bind(unsigned int unit) const;
|
||||||
|
unsigned int GetOpenGLID() const;
|
||||||
|
void UpdateSamplerId() const;
|
||||||
bool UseMipmaps(bool mipmaps);
|
bool UseMipmaps(bool mipmaps);
|
||||||
|
|
||||||
static bool Initialize();
|
static bool Initialize();
|
||||||
|
|
|
||||||
|
|
@ -212,7 +212,7 @@ void NzTextureSampler::SetDefaultWrapMode(nzSamplerWrap wrapMode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzTextureSampler::Apply(const NzTexture* texture)
|
void NzTextureSampler::Apply(const NzTexture* texture) const
|
||||||
{
|
{
|
||||||
// On considère que la texture est déjà active lors de l'appel à cette fonction
|
// On considère que la texture est déjà active lors de l'appel à cette fonction
|
||||||
GLenum target = NzOpenGL::TextureTarget[texture->GetType()];
|
GLenum target = NzOpenGL::TextureTarget[texture->GetType()];
|
||||||
|
|
@ -275,13 +275,27 @@ void NzTextureSampler::Apply(const NzTexture* texture)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzTextureSampler::Bind(unsigned int unit)
|
void NzTextureSampler::Bind(unsigned int unit) const
|
||||||
{
|
{
|
||||||
static_assert(nzSamplerFilter_Max < 0x4, "Maximum sampler filter mode takes more than 2 bits");
|
static_assert(nzSamplerFilter_Max < 0x4, "Maximum sampler filter mode takes more than 2 bits");
|
||||||
static_assert(nzSamplerWrap_Max < 0x4, "Maximum sampler wrap mode takes more than 2 bits");
|
static_assert(nzSamplerWrap_Max < 0x4, "Maximum sampler wrap mode takes more than 2 bits");
|
||||||
|
|
||||||
if (!m_samplerId)
|
if (!m_samplerId)
|
||||||
{
|
UpdateSamplerId();
|
||||||
|
|
||||||
|
glBindSampler(unit, m_samplerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int NzTextureSampler::GetOpenGLID() const
|
||||||
|
{
|
||||||
|
if (!m_samplerId)
|
||||||
|
UpdateSamplerId();
|
||||||
|
|
||||||
|
return m_samplerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NzTextureSampler::UpdateSamplerId() const
|
||||||
|
{
|
||||||
nzUInt32 key = (m_mipmaps << 0) | // 1 bit
|
nzUInt32 key = (m_mipmaps << 0) | // 1 bit
|
||||||
(m_filterMode << 1) | // 2 bits
|
(m_filterMode << 1) | // 2 bits
|
||||||
(m_wrapMode << 3) | // 2 bits
|
(m_wrapMode << 3) | // 2 bits
|
||||||
|
|
@ -344,9 +358,6 @@ void NzTextureSampler::Bind(unsigned int unit)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_samplerId = it->second;
|
m_samplerId = it->second;
|
||||||
}
|
|
||||||
|
|
||||||
glBindSampler(unit, m_samplerId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NzTextureSampler::UseMipmaps(bool mipmaps)
|
bool NzTextureSampler::UseMipmaps(bool mipmaps)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue