关于 AGAL 中Texture的Mip映射的函数:
public function uploadTextureWithMipmaps($dest:Texture, $BitmapData):void{
var $ws:int = $src.width;
var $hs:int = $src.height;
var $level:int = 0;
var $tmp:BitmapData;
var $transform:Matrix = new Matrix();
var $tmp2:BitmapData;$tmp = new BitmapData( $src.width, $src.height, true, 0x00000000);
while ( $ws >= 1 && $hs >= 1 ){
$tmp.draw($src, transform, null, null, null, true);
$dest.uploadFromBitmapData($tmp, $level);
transform.scale(0.5, 0.5);
$level += 1;
$ws >>= 1;
$hs >>= 1;
if ($hs && $ws) {
$tmp.dispose();
$tmp = new BitmapData($ws, $hs, true, 0x00000000);
}
}
$tmp.dispose();
}