Esempio n. 1
0
 public static Texture Create(int width, int height, PixelInternalFormat internalFormat = PixelInternalFormat.Rgba8
     , PixelFormat inputPixelFormat = PixelFormat.Rgba, PixelType type = PixelType.UnsignedByte)
 {
     var texture = new Texture();
     //create empty texture of given size
     texture.LoadPixels(IntPtr.Zero, width, height, internalFormat, inputPixelFormat, type);
     //set default parameters for filtering and clamping
     texture.FilterBilinear();
     texture.WrapMode(TextureWrapMode.Repeat);
     return texture;
 }
Esempio n. 2
0
 public static Texture FromBitmap(Bitmap bitmap)
 {
     Texture texture = new Texture();
     texture.FilterTrilinear();
     texture.BeginUse();
     //todo: 16bit channels
     using (Bitmap bmp = new Bitmap(bitmap))
     {
         bmp.RotateFlip(RotateFlipType.RotateNoneFlipY);
         BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, bmp.PixelFormat);
         PixelInternalFormat internalFormat = selectInternalPixelFormat(bmp.PixelFormat);
         OpenTK.Graphics.OpenGL.PixelFormat inputPixelFormat = selectInputPixelFormat(bmp.PixelFormat);
         texture.LoadPixels(bmpData.Scan0, bmpData.Width, bmpData.Height, internalFormat, inputPixelFormat, PixelType.UnsignedByte);
         bmp.UnlockBits(bmpData);
     }
     texture.EndUse();
     return texture;
 }
Esempio n. 3
0
        public static Texture FromBitmap(Bitmap bitmap)
        {
            Texture texture = new Texture();

            texture.BeginUse();
            texture.FilterTrilinear();
            //todo: 16bit channels
            using (Bitmap bmp = new Bitmap(bitmap))
            {
                bmp.RotateFlip(RotateFlipType.RotateNoneFlipY);
                BitmapData          bmpData        = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, bmp.PixelFormat);
                PixelInternalFormat internalFormat = selectInternalPixelFormat(bmp.PixelFormat);
                OpenTK.Graphics.OpenGL.PixelFormat inputPixelFormat = selectInputPixelFormat(bmp.PixelFormat);
                texture.LoadPixels(bmpData.Scan0, bmpData.Width, bmpData.Height, internalFormat, inputPixelFormat, PixelType.UnsignedByte);
                bmp.UnlockBits(bmpData);
            }
            texture.EndUse();
            return(texture);
        }