Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated ATF texture support for final data format
- Loading branch information
1 parent
bf10073
commit 7739a9e
Showing
11 changed files
with
278 additions
and
224 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// ================================================================================================= | ||
// | ||
// Starling Framework | ||
// Copyright 2012 Gamua OG. All Rights Reserved. | ||
// | ||
// This program is free software. You can redistribute and/or modify it | ||
// in accordance with the terms of the accompanying license agreement. | ||
// | ||
// ================================================================================================= | ||
|
||
package starling.textures | ||
{ | ||
import flash.display3D.Context3DTextureFormat; | ||
import flash.utils.ByteArray; | ||
|
||
/** A parser for the ATF data format. */ | ||
internal class AtfData | ||
{ | ||
private var mFormat:String; | ||
private var mWidth:int; | ||
private var mHeight:int; | ||
private var mNumTextures:int; | ||
private var mData:ByteArray; | ||
|
||
/** Create a new instance by parsing the given byte array. */ | ||
public function AtfData(data:ByteArray) | ||
{ | ||
var signature:String = String.fromCharCode(data[0], data[1], data[2]); | ||
if (signature != "ATF") throw new ArgumentError("Invalid ATF data"); | ||
|
||
var format:String; | ||
switch (data[6]) | ||
{ | ||
case 0: | ||
case 1: mFormat = Context3DTextureFormat.BGRA; break; | ||
case 2: | ||
case 3: mFormat = Context3DTextureFormat.COMPRESSED; break; | ||
case 4: | ||
case 5: mFormat = "compressedAlpha"; break; // explicit string to stay compatible | ||
// with older versions | ||
default: throw new Error("Invalid ATF format"); | ||
} | ||
|
||
mWidth = Math.pow(2, data[7]); | ||
mHeight = Math.pow(2, data[8]); | ||
mNumTextures = data[9]; | ||
mData = data; | ||
} | ||
|
||
public function get format():String { return mFormat; } | ||
public function get width():int { return mWidth; } | ||
public function get height():int { return mHeight; } | ||
public function get numTextures():int { return mNumTextures; } | ||
public function get data():ByteArray { return mData; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.