CSharpGL.Texture.Bind C# (CSharp) Method

Bind() public method

public Bind ( ) : void
return void
        public void Bind()
        {
            OpenGL.BindTexture(this.Target, this.Id);
            //this.SamplerBuilder.Bind(OpenGL.GL_TEXTURE0 - OpenGL.GL_TEXTURE0, this.Target);
        }

Usage Example

Example #1
0
        /// <summary>
        /// Get image from texture.
        /// </summary>
        /// <param name="texture"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <returns></returns>
        public static unsafe Bitmap GetImage(this Texture texture, int width, int height)
        {
            texture.Bind();

            var bmp  = new Bitmap(width, height);
            var data = bmp.LockBits(new Rectangle(0, 0, width, height), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            GL.Instance.GetTexImage((uint)texture.Target, 0, GL.GL_BGRA, GL.GL_UNSIGNED_BYTE, data.Scan0);
            bmp.UnlockBits(data);
            bmp.RotateFlip(RotateFlipType.Rotate180FlipX);

            texture.Unbind();

            return(bmp);
        }