protected override void PlatformSetTexture(int slot, ShaderTextureBinding textureBinding) { OpenGLTextureBinding glTextureBinding = (OpenGLTextureBinding)textureBinding; OpenGLTextureBindingSlotInfo info = ShaderResourceBindingSlots.GetTextureBindingInfo(slot); _textureSamplerManager.SetTexture(info.RelativeIndex, glTextureBinding); ShaderSet.UpdateTextureUniform(info.UniformLocation, info.RelativeIndex); }
public void SetTexture(int textureUnit, OpenGLTextureBinding texture) { if (_textureUnitTextures[textureUnit] != texture) { if (_dsaAvailable) { GL.BindTextureUnit(textureUnit, texture.BoundTexture.ID); } else { GL.ActiveTexture(TextureUnit.Texture0 + textureUnit); GL.BindTexture(texture.BoundTexture.Target, texture.BoundTexture.ID); } EnsureSamplerMipmapState(textureUnit, texture.BoundTexture.MipLevels > 1); _textureUnitTextures[textureUnit] = texture; } }
public void SetSampler(int textureUnit, OpenGLSamplerState samplerState) { if (_textureUnitSamplers[textureUnit].SamplerState != samplerState) { bool mipmapped = false; OpenGLTextureBinding texBinding = _textureUnitTextures[textureUnit]; if (texBinding != null) { mipmapped = texBinding.BoundTexture.MipLevels > 1; } samplerState.Apply(textureUnit, mipmapped); _textureUnitSamplers[textureUnit] = new BoundSamplerStateInfo(samplerState, mipmapped); } else if (_textureUnitTextures[textureUnit] != null) { EnsureSamplerMipmapState(textureUnit, _textureUnitTextures[textureUnit].BoundTexture.MipLevels > 1); } }