public void CopyToTexture( Axiom.Core.Texture target )
{
// TODO: Check usage and format, need Usage property on Texture
if ( target.Usage != this.Usage ||
target.TextureType != this.TextureType )
{
throw new Exception( "Source and destination textures must have the same usage and texture type" );
}
D3DTexture texture = (D3DTexture)target;
System.Drawing.Rectangle srcRect = new System.Drawing.Rectangle( 0, 0, this.Width, this.Height );
System.Drawing.Rectangle destRect = new System.Drawing.Rectangle( 0, 0, target.Width, target.Height );
switch ( target.TextureType )
{
case TextureType.TwoD:
using ( D3D.Surface srcSurface = this._normTexture.GetSurfaceLevel( 0 ),
dstSurface = texture.NormalTexture.GetSurfaceLevel( 0 ) )
{
// copy this texture surface to the target
this._device.StretchRectangle(
srcSurface,
srcRect,
dstSurface,
destRect,
D3D.TextureFilter.None );
}
break;
case TextureType.CubeMap:
for ( int face = 0; face < 6; face++ )
{
using ( D3D.Surface srcSurface = this._cubeTexture.GetCubeMapSurface( (D3D.CubeMapFace)face, 0 ),
dstSurface = texture.CubeTexture.GetCubeMapSurface( (D3D.CubeMapFace)face, 0 ) )
{
// copy this texture surface to the target
this._device.StretchRectangle(
srcSurface,
srcRect,
dstSurface,
destRect,
D3D.TextureFilter.None );
}
}
break;
default:
throw new Exception( "Copy to texture is implemented only for 2D and cube textures !!!" );
}
}