/// <summary> /// /// </summary> protected override void DoInitialize() { this.RenderUnit.Initialize(); { var bitmap = this.bitmap; bitmap.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipX); var texImageBitmap = new TexImageBitmap(bitmap); var texture = new Texture(texImageBitmap); texture.BuiltInSampler.Add(new TexParameteri(TexParameter.PropertyName.TextureWrapS, (int)GL.GL_CLAMP_TO_EDGE)); texture.BuiltInSampler.Add(new TexParameteri(TexParameter.PropertyName.TextureWrapT, (int)GL.GL_CLAMP_TO_EDGE)); texture.BuiltInSampler.Add(new TexParameteri(TexParameter.PropertyName.TextureWrapR, (int)GL.GL_CLAMP_TO_EDGE)); texture.BuiltInSampler.Add(new TexParameteri(TexParameter.PropertyName.TextureMinFilter, (int)GL.GL_LINEAR)); texture.BuiltInSampler.Add(new TexParameteri(TexParameter.PropertyName.TextureMagFilter, (int)GL.GL_LINEAR)); texture.Initialize(); if (this.autoDispose) { bitmap.Dispose(); } this.bitmap = null; RenderMethod method = this.RenderUnit.Methods[0]; method.Program.SetUniform("tex", texture); } }
/// <summary> /// Provides a <see cref="Texture"/> object generated from specified bitmap file. /// </summary> /// <param name="filename"></param> public BitmapTextureSource(string filename) { var bmp = new System.Drawing.Bitmap(filename); bmp.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipX); var storage = new TexImageBitmap(bmp); texture = new Texture(storage); texture.BuiltInSampler.Add(new TexParameteri(TexParameter.PropertyName.TextureWrapS, (int)GL.GL_CLAMP_TO_EDGE)); texture.BuiltInSampler.Add(new TexParameteri(TexParameter.PropertyName.TextureWrapT, (int)GL.GL_CLAMP_TO_EDGE)); texture.BuiltInSampler.Add(new TexParameteri(TexParameter.PropertyName.TextureWrapR, (int)GL.GL_CLAMP_TO_EDGE)); texture.BuiltInSampler.Add(new TexParameteri(TexParameter.PropertyName.TextureMinFilter, (int)GL.GL_LINEAR)); texture.BuiltInSampler.Add(new TexParameteri(TexParameter.PropertyName.TextureMagFilter, (int)GL.GL_LINEAR)); texture.Initialize(); bmp.Dispose(); }