关于 AGAL 中Texture的Mip映射的函数:

  1. public function uploadTextureWithMipmaps($dest:Texture, $BitmapData):void{

  2. var $ws:int = $src.width;

  3. var $hs:int = $src.height;

  4. var $level:int = 0;

  5. var $tmp:BitmapData;

  6. var $transform:Matrix = new Matrix();

  7. var $tmp2:BitmapData;$tmp = new BitmapData( $src.width, $src.height, true, 0x00000000);

  8. while ( $ws >= 1 && $hs >= 1 ){

  9. $tmp.draw($src, transform, null, null, null, true);

  10. $dest.uploadFromBitmapData($tmp, $level);

  11. transform.scale(0.5, 0.5);

  12. $level += 1;

  13. $ws >>= 1;

  14. $hs >>= 1;

  15. if ($hs && $ws) {

  16. $tmp.dispose();

  17. $tmp = new BitmapData($ws, $hs, true, 0x00000000);

  18. }

  19. }

  20. $tmp.dispose();

  21. }