OpenGLRenderer: Implement TextureSampler (and texture units)

This commit is contained in:
Lynix
2020-04-26 16:29:31 +02:00
parent cbd81e3abf
commit e9f0b01e02
13 changed files with 244 additions and 66 deletions

View File

@@ -37,12 +37,33 @@ namespace Nz::GL
return m_supportedExtensions.find(extension) != m_supportedExtensions.end();
}
inline void Context::NotifySamplerDestruction(GLuint sampler) const
{
for (auto& unit : m_state.textureUnits)
{
if (unit.sampler == sampler)
unit.sampler = 0;
}
}
inline void Context::NotifyTextureDestruction(GLuint texture) const
{
for (GLuint& boundTexture : m_state.boundTextures)
for (auto& unit : m_state.textureUnits)
{
if (boundTexture == texture)
boundTexture = 0;
for (GLuint& boundTexture : unit.textureTargets)
{
if (boundTexture == texture)
boundTexture = 0;
}
}
}
inline void Context::SetCurrentTextureUnit(UInt32 textureUnit) const
{
if (m_state.currentTextureUnit != textureUnit)
{
glActiveTexture(GL_TEXTURE0 + textureUnit);
m_state.currentTextureUnit = textureUnit;
}
}
}