Adding provisional getBytes for html5 and fixing Main.hx compile issues for SimpleOpenGL
Although the PNG decoding is failing due to invalid header.
This commit is contained in:
@@ -14,6 +14,7 @@ import lime.utils.ByteArray;
|
|||||||
import format.swf.lite.SWFLite;
|
import format.swf.lite.SWFLite;
|
||||||
#else
|
#else
|
||||||
import format.SWF;
|
import format.SWF;
|
||||||
|
import lime.utils.UInt8Array;
|
||||||
#end //js
|
#end //js
|
||||||
#end //swf
|
#end //swf
|
||||||
|
|
||||||
@@ -69,35 +70,30 @@ import lime.utils.ByteArray;
|
|||||||
|
|
||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
#if (tools && !display)
|
|
||||||
|
|
||||||
if (AssetData.type.exists(id)) {
|
if (AssetData.type.exists(id)) {
|
||||||
|
|
||||||
#if flash
|
#if lime_html5
|
||||||
return Type.createInstance(AssetData.className.get(id), []);
|
|
||||||
#elseif js
|
|
||||||
|
|
||||||
#if !lime_html5
|
var req = new haxe.Http(id);
|
||||||
var bytes:ByteArray = null;
|
var results : Dynamic = null;
|
||||||
var data = ApplicationMain.urlLoaders.get(AssetData.path.get(id)).data;
|
|
||||||
if (Std.is(data, String)) {
|
req.async = false;
|
||||||
var bytes = new ByteArray();
|
req.onData = function(e) {
|
||||||
bytes.writeUTFBytes(data);
|
results = e;
|
||||||
} else if (Std.is(data, ByteArray)) {
|
}
|
||||||
bytes = cast data;
|
req.request();
|
||||||
} else {
|
req = null;
|
||||||
bytes = null;
|
|
||||||
|
var len : Int = results.length;
|
||||||
|
var bytearray : ByteArray = new ByteArray();
|
||||||
|
for( i in 0 ... len ) {
|
||||||
|
bytearray.writeByte(results.charCodeAt(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bytes != null) {
|
bytearray.position = 0;
|
||||||
bytes.position = 0;
|
return bytearray;
|
||||||
return bytes;
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
#end //lime_html5
|
|
||||||
|
|
||||||
#else //js or flash
|
#else //lime_html5
|
||||||
|
|
||||||
return ByteArray.readFile(AssetData.path.get(id));
|
return ByteArray.readFile(AssetData.path.get(id));
|
||||||
|
|
||||||
@@ -107,8 +103,6 @@ import lime.utils.ByteArray;
|
|||||||
trace("[lime.utils.Assets] There is no String or ByteArray asset with an ID of \"" + id + "\"");
|
trace("[lime.utils.Assets] There is no String or ByteArray asset with an ID of \"" + id + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
#end
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
} //getBytes
|
} //getBytes
|
||||||
|
|||||||
@@ -3,11 +3,15 @@ package;
|
|||||||
|
|
||||||
import format.png.Reader;
|
import format.png.Reader;
|
||||||
import format.png.Tools;
|
import format.png.Tools;
|
||||||
|
import haxe.io.Bytes;
|
||||||
|
import haxe.io.BytesData;
|
||||||
import haxe.io.BytesInput;
|
import haxe.io.BytesInput;
|
||||||
import lime.gl.GL;
|
import lime.gl.GL;
|
||||||
import lime.gl.GLBuffer;
|
import lime.gl.GLBuffer;
|
||||||
import lime.gl.GLProgram;
|
import lime.gl.GLProgram;
|
||||||
import lime.gl.GLTexture;
|
import lime.gl.GLTexture;
|
||||||
|
import lime.gl.GLUniformLocation;
|
||||||
|
import lime.utils.ByteArray;
|
||||||
import lime.utils.Matrix3D;
|
import lime.utils.Matrix3D;
|
||||||
import lime.utils.Assets;
|
import lime.utils.Assets;
|
||||||
import lime.utils.Float32Array;
|
import lime.utils.Float32Array;
|
||||||
@@ -21,10 +25,10 @@ class Main {
|
|||||||
private var imageData:UInt8Array;
|
private var imageData:UInt8Array;
|
||||||
private var imageHeight:Int;
|
private var imageHeight:Int;
|
||||||
private var imageWidth:Int;
|
private var imageWidth:Int;
|
||||||
private var imageUniform:Int;
|
private var imageUniform:GLUniformLocation;
|
||||||
private var lime:Lime;
|
private var lime:Lime;
|
||||||
private var modelViewMatrixUniform:Int;
|
private var modelViewMatrixUniform:GLUniformLocation;
|
||||||
private var projectionMatrixUniform:Int;
|
private var projectionMatrixUniform:GLUniformLocation;
|
||||||
private var shaderProgram:GLProgram;
|
private var shaderProgram:GLProgram;
|
||||||
private var texCoordAttribute:Int;
|
private var texCoordAttribute:Int;
|
||||||
private var texCoordBuffer:GLBuffer;
|
private var texCoordBuffer:GLBuffer;
|
||||||
@@ -146,13 +150,25 @@ class Main {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function arrayToBytes( array:ByteArray ):haxe.io.Bytes {
|
||||||
|
|
||||||
|
if (array == null) return null;
|
||||||
|
var bytes:haxe.io.Bytes = haxe.io.Bytes.alloc(array.length);
|
||||||
|
for (n in 0 ... array.length) {
|
||||||
|
bytes.set(n, array.readByte());
|
||||||
|
}
|
||||||
|
|
||||||
|
return bytes;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function ready (lime:Lime):Void {
|
public function ready (lime:Lime):Void {
|
||||||
|
|
||||||
this.lime = lime;
|
this.lime = lime;
|
||||||
|
|
||||||
var bytes = Assets.getBytes ("assets/lime.png");
|
var bytes : ByteArray = Assets.getBytes ("assets/lime.png");
|
||||||
var byteInput = new BytesInput (bytes, 0, bytes.length);
|
var io_bytes : haxe.io.Bytes = arrayToBytes( bytes );
|
||||||
|
var byteInput = new BytesInput ( io_bytes, 0, io_bytes.length);
|
||||||
var png = new Reader (byteInput).read ();
|
var png = new Reader (byteInput).read ();
|
||||||
var data = Tools.extract32 (png);
|
var data = Tools.extract32 (png);
|
||||||
var header = Tools.getHeader (png);
|
var header = Tools.getHeader (png);
|
||||||
|
|||||||
Reference in New Issue
Block a user