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

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

public InitWithData ( IntPtr data, SurfaceFormat pixelFormat, int width, int height, Size size, All filter ) : void
data System.IntPtr
pixelFormat SurfaceFormat
width int
height int
size System.Drawing.Size
filter All
Результат void
        public void InitWithData(IntPtr data, SurfaceFormat pixelFormat, int width, int height, Size size, All filter)
        {
            GL.GenTextures(1,ref _name);
            GL.BindTexture(All.Texture2D, _name);
            GL.TexParameter(All.Texture2D, All.TextureMinFilter, (int) filter);
            GL.TexParameter(All.Texture2D, All.TextureMagFilter, (int) filter);
            GL.TexParameter(All.Texture2D, All.TextureWrapS,(int)All.ClampToEdge);
            GL.TexParameter(All.Texture2D, All.TextureWrapT, (int)All.ClampToEdge);

            int sz = 0;

            switch(pixelFormat) {
                case SurfaceFormat.Color /*kTexture2DPixelFormat_RGBA8888*/:
                case SurfaceFormat.Dxt1:
                case SurfaceFormat.Dxt3:
                    sz = 4;
                    GL.TexImage2D(All.Texture2D, 0, (int) All.Rgba, (int) width, (int) height, 0, All.Rgba, All.UnsignedByte, data);
                    break;
                case SurfaceFormat.Bgra4444 /*kTexture2DPixelFormat_RGBA4444*/:
                    sz = 2;
                    GL.TexImage2D(All.Texture2D, 0, (int) All.Rgba, (int) width, (int) height, 0, All.Rgba, All.UnsignedShort4444, data);
                    break;
                case SurfaceFormat.Bgra5551 /*kTexture2DPixelFormat_RGB5A1*/:
                    sz = 2;
                    GL.TexImage2D(All.Texture2D, 0, (int) All.Rgba, (int) width, (int) height, 0, All.Rgba, All.UnsignedShort5551, data);
                    break;
                case SurfaceFormat.Alpha8 /*kTexture2DPixelFormat_A8*/:
                    sz = 1;
                    GL.TexImage2D(All.Texture2D, 0, (int) All.Alpha, (int) width, (int) height, 0, All.Alpha, All.UnsignedByte, data);
                    break;
                default:
                    throw new NotSupportedException("Texture format");;
            }

            _size = size;
            _width = width;
            _height = height;
            _format = pixelFormat;
            _maxS = size.Width / (float)width;
            _maxT = size.Height / (float)height;

            _pixelData = data;
        }