renderTextureMesh method
void
renderTextureMesh(
- RenderState renderState,
- Int16List ixList,
- Float32List vxList,
- num r,
- num g,
- num b,
- num a,
Implementation
void renderTextureMesh(RenderState renderState, Int16List ixList,
Float32List vxList, num r, num g, num b, num a) {
final matrix = renderState.globalMatrix;
final alpha = renderState.globalAlpha;
final ixListCount = ixList.length;
final vxListCount = vxList.length >> 2;
// check buffer sizes and flush if necessary
final ixData = renderBufferIndex.data;
final ixPosition = renderBufferIndex.position;
if (ixPosition + ixListCount >= ixData.length) flush();
final vxData = renderBufferVertex.data;
final vxPosition = renderBufferVertex.position;
if (vxPosition + vxListCount * 8 >= vxData.length) flush();
final ixIndex = renderBufferIndex.position;
var vxIndex = renderBufferVertex.position;
final vxCount = renderBufferVertex.count;
// copy index list
for (var i = 0; i < ixListCount; i++) {
ixData[ixIndex + i] = vxCount + ixList[i];
}
renderBufferIndex.position += ixListCount;
renderBufferIndex.count += ixListCount;
// copy vertex list
final ma = matrix.a;
final mb = matrix.b;
final mc = matrix.c;
final md = matrix.d;
final mx = matrix.tx;
final my = matrix.ty;
final colorA = a * alpha;
final colorR = r * colorA;
final colorG = g * colorA;
final colorB = b * colorA;
for (var i = 0, o = 0; i < vxListCount; i++, o += 4) {
final x = vxList[o + 0];
final y = vxList[o + 1];
vxData[vxIndex + 0] = mx + ma * x + mc * y;
vxData[vxIndex + 1] = my + mb * x + md * y;
vxData[vxIndex + 2] = vxList[o + 2];
vxData[vxIndex + 3] = vxList[o + 3];
vxData[vxIndex + 4] = colorR;
vxData[vxIndex + 5] = colorG;
vxData[vxIndex + 6] = colorB;
vxData[vxIndex + 7] = colorA;
vxIndex += 8;
}
renderBufferVertex.position += vxListCount * 8;
renderBufferVertex.count += vxListCount;
}