public void SetSampler(uint textureUnit, OpenGLSampler sampler) { if (_textureUnitSamplers[textureUnit].Sampler != sampler) { bool mipmapped = false; OpenGLTextureView texBinding = _textureUnitTextures[textureUnit]; if (texBinding != null) { mipmapped = texBinding.Target.MipLevels > 1; } uint samplerID = mipmapped ? sampler.MipmapSampler : sampler.NoMipmapSampler; glBindSampler(textureUnit, samplerID); CheckLastError(); _textureUnitSamplers[textureUnit] = new BoundSamplerStateInfo(sampler, mipmapped); } else if (_textureUnitTextures[textureUnit] != null) { EnsureSamplerMipmapState(textureUnit, _textureUnitTextures[textureUnit].Target.MipLevels > 1); } }
public void SetTexture(uint textureUnit, OpenGLTextureView textureView) { uint textureID = textureView.GLTargetTexture; if (_textureUnitTextures[textureUnit] != textureView) { if (_dsaAvailable) { glBindTextureUnit(textureUnit, textureID); CheckLastError(); } else { SetActiveTextureUnit(textureUnit); glBindTexture(textureView.TextureTarget, textureID); CheckLastError(); } EnsureSamplerMipmapState(textureUnit, textureView.MipLevels > 1); _textureUnitTextures[textureUnit] = textureView; } }