Microsoft.Xna.Framework.Graphics.ESTexture2D.InitWithBitmapGL11 C# (CSharp) Метод

InitWithBitmapGL11() публичный Метод

public InitWithBitmapGL11 ( Bitmap imageSource, OpenTK.Graphics.ES11 filter ) : void
imageSource System.Drawing.Bitmap
filter OpenTK.Graphics.ES11
Результат void
        public void InitWithBitmapGL11(Bitmap imageSource, GL11.All filter)
        {
            //TODO:  Android.Opengl.GLUtils.GetInternalFormat()
            openGLVersion = GLContextVersion.Gles1_1;

            _format = SurfaceFormat.Color;
            if (imageSource.HasAlpha)
                _format = SurfaceFormat.Color;

            // scale up bitmap to be power of 2 dimensions but dont exceed 1024x1024.
            // Note: may not have to do this with OpenGL 2+

            _width = (int)Math.Pow(2, Math.Min(10, Math.Ceiling(Math.Log10(imageSource.Width) / Math.Log10(2))));
            _height = (int)Math.Pow(2, Math.Min(10, Math.Ceiling(Math.Log10(imageSource.Height) / Math.Log10(2))));

            _size.Width = imageSource.Width;
            _size.Height = imageSource.Height;

            using (Bitmap imageScaled = Bitmap.CreateScaledBitmap(imageSource, _width, _height, false))
            {
                GL11.GL.GenTextures(1, ref _name);
                GL11.GL.BindTexture(GL11.All.Texture2D, _name);
                GL11.GL.TexParameter(GL11.All.Texture2D, GL11.All.TextureMinFilter, (int)filter);
                GL11.GL.TexParameter(GL11.All.Texture2D, GL11.All.TextureMagFilter, (int)filter);

                Android.Opengl.GLUtils.TexImage2D((int)GL11.All.Texture2D, 0, imageScaled, 0);
            }

            _maxS = _size.Width / (float)_width;
            _maxT = _size.Height / (float)_height;

            _pixelData = imageSource.Handle;
        }