Exemplo n.º 1
0
        public static Texture2D LoadTexture(IGraphicsContext context, Stream stream)
        {
            Bitmap     bitmap = new Bitmap(stream);
            BitmapData data   = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);

            int id = context.GenTexture();

            context.BindTexture(TextureTarget.Texture2D, id);

            context.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, data.Width, data.Height, false,
                               OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0);

            bitmap.UnlockBits(data);

            context.GenerateMipmap(GenerateMipmapTarget.Texture2D);

            return(new Texture2D(context, id, data.Width, data.Height));
        }
Exemplo n.º 2
0
 public void GenerateMipmap(GenerateMipmapTarget target)
 {
     forwarding.GenerateMipmap(target);
     CheckGLError();
     GLCALLS++;
 }