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

Upload() protected method

protected Upload ( PixelBox data, BasicBox dest ) : void
data Axiom.Media.PixelBox
dest Axiom.Media.BasicBox
return void
		protected override void Upload( PixelBox data, BasicBox dest )
		{
			OpenGL.BindTexture( _target, _textureId );
			GLESConfig.GlCheckError( this );

			if ( PixelUtil.IsCompressed( data.Format ) )
			{
				if ( data.Format != this.Format || !data.IsConsecutive )
				{
					throw new AxiomException( "Compressed images must be consecutive, in the source format" );
				}

				if ( data.Format != Format || !data.IsConsecutive )
					throw new AxiomException( "Compressed images must be consecutive, in the source format." );

				All format = GLESPixelUtil.GetClosestGLInternalFormat( Format );
				// Data must be consecutive and at beginning of buffer as PixelStorei not allowed
				// for compressed formats
				if ( dest.Left == 0 && dest.Top == 0 )
				{
					OpenGL.CompressedTexImage2D( All.Texture2D, _level, format, dest.Width, dest.Height, 0, data.ConsecutiveSize, data.Data );
				}
				else
				{
					OpenGL.CompressedTexSubImage2D( All.Texture2D, _level, dest.Left, dest.Top, dest.Width, dest.Height, format, data.ConsecutiveSize, data.Data );
				}
				GLESConfig.GlCheckError( this );
			}
			else if ( _softwareMipmap )
			{
				if ( data.Width != data.RowPitch )
				{
					//TODO
					throw new AxiomException( "Unsupported Texture format!" );
				}
				if ( data.Height * data.Width != data.SlicePitch )
				{
					//TODO
					throw new AxiomException( "Unsupported Texture format!" );
				}

				OpenGL.PixelStore( All.UnpackAlignment, 1 );
				GLESConfig.GlCheckError( this );
				BuildMipmaps( data );
			}
			else
			{
				if ( data.Width != data.RowPitch )
				{
					//TODO
					throw new AxiomException( "Unsupported Texture format!" );
				}
				if ( data.Height * data.Width != data.SlicePitch )
				{
					//TODO
					throw new AxiomException( "Unsupported Texture format!" );
				}

				if ( ( ( data.Width * PixelUtil.GetNumElemBytes( data.Format ) ) & 3 ) != 0 )
				{
					// Standard alignment of 4 is not right
					OpenGL.PixelStore( All.UnpackAlignment, 1 );
					GLESConfig.GlCheckError( this );
				}
				All form = GLESPixelUtil.GetGLOriginFormat( data.Format );
				All pix = GLESPixelUtil.GetGLOriginDataType( data.Format );
				GLESConfig.GlCheckError( this );
				GL.TexSubImage2D( _faceTarget, _level, dest.Left, dest.Top, dest.Width, dest.Height, GLESPixelUtil.GetGLOriginFormat( data.Format ), GLESPixelUtil.GetGLOriginDataType( data.Format ), data.Data );
				GLESConfig.GlCheckError( this );
			}

			OpenGL.PixelStore( All.UnpackAlignment, 4 );
			GLESConfig.GlCheckError( this );
		}
		/// <summary>