From f7487e960baa2fee3f783e344e48ad36ced72a01 Mon Sep 17 00:00:00 2001 From: hughsando Date: Mon, 22 May 2017 23:26:27 +0800 Subject: [PATCH] Allow TileData to come from strings for neko too --- acadnme/src/AllNme.hx | 1 + project/src/common/ExternalInterface.cpp | 4 ++-- src/nme/utils/Float32Buffer.hx | 21 +++++++++++++++------ 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/acadnme/src/AllNme.hx b/acadnme/src/AllNme.hx index 1094a31a1..25a8ab568 100644 --- a/acadnme/src/AllNme.hx +++ b/acadnme/src/AllNme.hx @@ -210,6 +210,7 @@ import nme.utils.ByteArray; import nme.utils.CompressionAlgorithm; import nme.utils.Endian; import nme.utils.Float32Array; +import nme.utils.Float32Buffer; import nme.utils.IDataInput; import nme.utils.IDataOutput; import nme.utils.IMemoryRange; diff --git a/project/src/common/ExternalInterface.cpp b/project/src/common/ExternalInterface.cpp index 0de9f5240..f486620ea 100644 --- a/project/src/common/ExternalInterface.cpp +++ b/project/src/common/ExternalInterface.cpp @@ -3284,10 +3284,10 @@ value nme_gfx_draw_tiles(value inGfx,value inSheet, value inXYIDs,value inFlags, if (!buf) buf = val_to_buffer(inXYIDs); if (buf) - { fvals = (float *)buffer_data(buf); - } } + if (!fvals && val_is_string(inXYIDs)) + fvals = (float *)val_string(inXYIDs); if (fvals) TAddTiles( gfx->getPath(), sheet, n, fvals, flags, fullImage ); else diff --git a/src/nme/utils/Float32Buffer.hx b/src/nme/utils/Float32Buffer.hx index 95c8dc7e1..bf2086734 100644 --- a/src/nme/utils/Float32Buffer.hx +++ b/src/nme/utils/Float32Buffer.hx @@ -55,7 +55,8 @@ class Float32Buffer extends ByteArray implements ArrayAccess static function hxcppGetFloat(b:haxe.io.BytesData, pos:Int):Float return 0.0; #end - inline public function setF32(index:Int,val:Float) + #if !cppia inline #end + public function setF32(index:Int,val:Float) { #if jsprime if (index>=count) @@ -72,7 +73,9 @@ class Float32Buffer extends ByteArray implements ArrayAccess count = index+1; ensureElem(bpos+3,true); } - #if (cpp && !cppia) + #if cppia + untyped __global__.__hxcpp_memory_set_float(b,index,val); + #elseif cpp hxcppSetFloat(b,bpos,val); #else setFloat(bpos,val); @@ -80,12 +83,15 @@ class Float32Buffer extends ByteArray implements ArrayAccess #end } - inline public function getF32(index:Int):Float + #if !cppia inline #end + public function getF32(index:Int):Float { #if jsprime return f32View[index]; #else - #if (cpp && !cppia) + #if cppia + untyped return __global__.__hxcpp_memory_get_float(b,index); + #elseif cpp return hxcppGetFloat(b,index<<2); #else return getFloat(index<<2); @@ -95,12 +101,15 @@ class Float32Buffer extends ByteArray implements ArrayAccess - inline public function setF32q(index:Int,val:Float) + #if !cppia inline #end + public function setF32q(index:Int,val:Float) { #if jsprime f32View[index]=val; #else - #if (cpp && !cppia) + #if cppia + untyped __global__.__hxcpp_memory_set_float(b,index,val); + #elseif cpp hxcppSetFloat(b,index<<2,val); #else setFloat(index<<2,val);