Haxiomic
I found subarray does not work as expected on Cpp when using bufferSubData.
This code creates 3 triangles ( x,y,z,red,green,blue,a ) and can be placed in the repo link demo I shared.
var datum = new Float32Array([
0.100, 0.100, 0. , 1, 1, 1, 1
, 0.500, 0.500, 0. , 1, 1, 1, 1
, 0.100, 0.500, 0. , 1, 1, 1, 1
, 0.100, 0.100, 0 , 1, 0, 0, 1
, 0.500, 0.100, 0 , 1, 0, 0, 1
, 0.500, 0.500, 0 , 1, 0, 0, 1
, 0.300, 0.300, 0 , 1, 1, 0, 1
, 0.400, 0.300, 0 , 1, 1, 0, 1
, 0.400, 0.400, 0 , 1, 1, 0, 1
]);
// use middle triangle ( start at 3, end at 6 )
//var datum2 = new Float32Array( datum.subarray( 0 + 21, 21 + 22 ) );
var datum2 = datum.subarray( 0 + 21, 21 + 22 );
var info = [ 'x','y','z','r','g','b','a'];
// check the contents...
trace( '__' );
for( i in 0...Std.int(datum2.length/7) ){
var str = '';
for( j in 0...7 ) str +=
info[j] +':' + Std.string( Math.round( 1000*datum2[Std.int(i*j)] )/1000 ) + ' ';
trace( str );
str = '';
}
trace( '__' );
This outputs
Demo.hx:130: __
Demo.hx:136: x:0.1 y:0.1 z:0.1 r:0.1 g:0.1 b:0.1 a:0.1
Demo.hx:136: x:0.1 y:0.1 z:0 r:1 g:0 b:0 a:1
Demo.hx:136: x:0.1 y:0 z:0 r:1 g:0.1 b:1 a:0
Demo.hx:139: __
which as you your may remember is passed to the shader
gl.bufferSubData( ARRAY_BUFFER, 0, datum2 );
But draws all three triangles!!!
To fix it I need to force linking to a different part of memory.
var datum2 = new Float32Array( datum.subarray( 0 + 21, 21 + 22 ) );`
I am not too sure if this is a Haxe C++ issue or a Gluon problem, I also found my clearAll depending on size provided seemed to effect the render position which is rather odd.
Really need to work on my CV and not playing with shaders, but thought I should share.
I'll let you know when I am rendering something nice, at moment my engine is just drawing these 3 triangles so pretty much the same as setting them manually, as I have disabled the lineTo test for now. Would the best approach for me to use haxe.io.Float32Array internally in trilateral and then for render, loop through to build the gluon one? I use this[0] and this[1] to store position and length.
JS seems so much more forgiving than c++.