public AsAtfData(AsByteArray data) { String signature = AsString.fromCharCode((As_AS_REST)(data.getOwnProperty(0)), data.getOwnProperty(1), data.getOwnProperty(2)); if(signature != "ATF") { throw new AsArgumentError("Invalid ATF data"); } switch(data.getOwnProperty(6)) { case 0: case 1: mFormat = AsContext3DTextureFormat.BGRA; break; case 2: case 3: mFormat = AsContext3DTextureFormat.COMPRESSED; break; case 4: case 5: mFormat = "compressedAlpha"; break; default: throw new AsError("Invalid ATF format"); } mWidth = (int)(AsMath.pow(2, (float)(data.getOwnProperty(7)))); mHeight = (int)(AsMath.pow(2, (float)(data.getOwnProperty(8)))); mNumTextures = (int)(data.getOwnProperty(9)); mData = data; }
public static AsTexture getTexture() { AsBitmapData bmpData = new AsBitmapData(BITMAP_WIDTH, BITMAP_HEIGHT); AsByteArray bmpBytes = new AsByteArray(); int numBytes = (int)(BITMAP_DATA.getLength()); int i = 0; for (; i < numBytes; ++i) { bmpBytes.writeUnsignedInt((uint)(BITMAP_DATA[i])); } bmpBytes.uncompress(); bmpData.setPixels(new AsRectangle(0, 0, BITMAP_WIDTH, BITMAP_HEIGHT), bmpBytes); return AsTexture.fromBitmapData(bmpData, false); }
public virtual void writeBytes(AsByteArray bytes) { writeBytes(bytes, (uint)(0), (uint)(0)); }
public void uploadCompressedTextureFromByteArray(AsByteArray data, uint byteArrayOffset, bool async) { }
public virtual void writeBytes(AsByteArray bytes, uint offset) { writeBytes(bytes, offset, (uint)(0)); }
public virtual void readBytes(AsByteArray bytes, uint offset) { readBytes(bytes, offset, (uint)(0)); }
public virtual void loadBytes(AsByteArray bytes) { loadBytes(bytes, null); }
public virtual void uploadFromByteArray(AsByteArray data, int byteArrayOffset, int startVertex, int numVertices) { throw new AsNotImplementedError(); }
public virtual void readBytes(AsByteArray bytes, uint offset, uint length) { throw new AsNotImplementedError(); }
public virtual void readBytes(AsByteArray bytes) { readBytes(bytes, (uint)(0), (uint)(0)); }
public void upload(AsByteArray vertexProgram, AsByteArray fragmentProgram) { throw new AsNotImplementedError(); }
public void uploadFromByteArray(AsByteArray data, int byteArrayOffset, int startOffset, int count) { throw new AsNotImplementedError(); }
public void uploadFromByteArray(AsByteArray data, uint byteArrayOffset) { uploadFromByteArray(data, byteArrayOffset, (uint)(0)); }
public void uploadFromByteArray(AsByteArray data, uint byteArrayOffset, uint miplevel) { throw new AsNotImplementedError(); }
public void uploadCompressedTextureFromByteArray(AsByteArray data, uint byteArrayOffset) { uploadCompressedTextureFromByteArray(data, byteArrayOffset, false); }
public void uploadCompressedTextureFromByteArray(AsByteArray data, uint byteArrayOffset, bool async) { throw new AsNotImplementedError(); }
public void uploadFromByteArray(AsByteArray data, uint byteArrayOffset, uint side, uint miplevel) { }
public static AsTexture fromAtfData(AsByteArray data) { return fromAtfData(data, 1); }
public void setPixels(AsRectangle rect, AsByteArray bytes) { throw new NotImplementedException(); }
public static void uploadAtfData(bc.flash.display3D.textures.AsTexture nativeTexture, AsByteArray data, int offset) { nativeTexture.uploadCompressedTextureFromByteArray(data, (uint)(offset)); }
public static void uploadAtfData(bc.flash.display3D.textures.AsTexture nativeTexture, AsByteArray data) { uploadAtfData(nativeTexture, data, 0); }
public static AsTexture fromAtfData(AsByteArray data, float scale) { AsContext3D context = AsStarling.getContext(); if(context == null) { throw new AsMissingContextError(); } AsAtfData atfData = new AsAtfData(data); bc.flash.display3D.textures.AsTexture nativeTexture = context.createTexture(atfData.getWidth(), atfData.getHeight(), atfData.getFormat(), false); uploadAtfData(nativeTexture, data); AsConcreteTexture concreteTexture = new AsConcreteTexture(nativeTexture, atfData.getFormat(), atfData.getWidth(), atfData.getHeight(), atfData.getNumTextures() > 1, false, false, scale); if(AsStarling.getHandleLostContext()) { concreteTexture.restoreOnLostContext(atfData); } return concreteTexture; }
public virtual void setProgramConstantsFromByteArray(String programType, int firstRegister, int numRegisters, AsByteArray data, uint byteArrayOffset) { throw new AsNotImplementedError(); }
public virtual void loadBytes(AsByteArray bytes, AsLoaderContext context) { throw new AsNotImplementedError(); }
public virtual void registerProgram(String name, AsByteArray vertexProgram, AsByteArray fragmentProgram) { if(mPrograms.containsKey(name)) { throw new AsError("Another program with this name is already registered"); } AsProgram3D program = mContext.createProgram(); program.upload(vertexProgram, fragmentProgram); mPrograms[name] = program; }