Axiom.RenderSystems.OpenGLES.GLESTextureBuffer.BuildMipmaps C# (CSharp) Method

BuildMipmaps() protected static method

protected static BuildMipmaps ( PixelBox data ) : void
data Axiom.Media.PixelBox
return void
		protected static void BuildMipmaps( PixelBox data )
		{
			int width = 0;
			int height = 0;
			int logW = 0;
			int logH = 0;
			int level = 0;
			PixelBox scaled = data;
			scaled.Data = data.Data;
			scaled.Left = data.Left;
			scaled.Right = data.Right;
			scaled.Top = data.Top;
			scaled.Bottom = data.Bottom;
			scaled.Front = data.Front;
			scaled.Back = data.Back;

			All format = GLESPixelUtil.GetGLOriginFormat( data.Format );
			All dataType = GLESPixelUtil.GetGLOriginDataType( data.Format );
			width = data.Width;
			height = data.Height;

			logW = ComputeLog( width );
			logH = ComputeLog( height );
			level = ( logW > logH ? logW : logH );

			for ( int mip = 0; mip <= level; mip++ )
			{
				format = GLESPixelUtil.GetGLOriginFormat( scaled.Format );
				dataType = GLESPixelUtil.GetGLOriginDataType( scaled.Format );

				OpenGL.TexImage2D( All.Texture2D, mip, (int)format, width, height, 0, format, dataType, scaled.Data );

				GLESConfig.GlCheckError( null );

				if ( mip != 0 )
				{
					scaled.Data = IntPtr.Zero;
				}

				if ( width > 1 )
				{
					width = width / 2;
				}
				if ( height > 1 )
				{
					height = height / 2;
				}

				int sizeInBytes = PixelUtil.GetMemorySize( width, height, 1, data.Format );
				scaled = new PixelBox( width, height, 1, data.Format );
				byte[] dataarr = new byte[ sizeInBytes ];
				scaled.Data = Memory.PinObject( dataarr );
				Image.Scale( data, scaled, ImageFilter.Linear );
			}
		}