public void TextureUnits() { using (GraphicsWindow window = Device.CreateWindow(1, 1)) using (Texture2D texture = Device.CreateTexture2D(new Texture2DDescription(1, 1, TextureFormat.RedGreenBlueAlpha8, false))) using (TextureSampler sampler = Device.CreateTexture2DSampler( TextureMinificationFilter.Nearest, TextureMagnificationFilter.Nearest, TextureWrap.Clamp, TextureWrap.Clamp, 2)) { window.Context.TextureUnits[0].Texture = texture; window.Context.TextureUnits[0].TextureSampler = Device.TextureSamplers.LinearRepeat; Assert.AreEqual(texture, window.Context.TextureUnits[0].Texture); Assert.AreEqual(Device.TextureSamplers.LinearRepeat, window.Context.TextureUnits[0].TextureSampler); // // Assign same texture with different filter // window.Context.TextureUnits[0].Texture = texture; window.Context.TextureUnits[0].TextureSampler = sampler; Assert.AreEqual(texture, window.Context.TextureUnits[0].Texture); Assert.AreEqual(sampler, window.Context.TextureUnits[0].TextureSampler); } }
public void Texture2DSampler() { using (GraphicsWindow window = Device.CreateWindow(1, 1)) { using (TextureSampler filter = Device.CreateTexture2DSampler( TextureMinificationFilter.Linear, TextureMagnificationFilter.Nearest, TextureWrap.MirroredRepeat, TextureWrap.Repeat, 2)) { Assert.AreEqual(TextureMinificationFilter.Linear, filter.MinificationFilter); Assert.AreEqual(TextureMagnificationFilter.Nearest, filter.MagnificationFilter); Assert.AreEqual(TextureWrap.MirroredRepeat, filter.WrapS); Assert.AreEqual(TextureWrap.Repeat, filter.WrapT); Assert.AreEqual(2, filter.MaximumAnisotropic); } } }
private void ApplySampler(TextureSampler sampler) { TextureMinFilter minFilter = TypeConverterGL3x.To(sampler.MinificationFilter); TextureMagFilter magFilter = TypeConverterGL3x.To(sampler.MagnificationFilter); TextureWrapMode wrapS = TypeConverterGL3x.To(sampler.WrapS); TextureWrapMode wrapT = TypeConverterGL3x.To(sampler.WrapT); GL.TexParameter(_target, TextureParameterName.TextureMinFilter, (int)minFilter); GL.TexParameter(_target, TextureParameterName.TextureMagFilter, (int)magFilter); GL.TexParameter(_target, TextureParameterName.TextureWrapS, (int)wrapS); GL.TexParameter(_target, TextureParameterName.TextureWrapT, (int)wrapT); }