matAttribSetter method

dynamic matAttribSetter(
  1. OpenGLContextES gl,
  2. dynamic index,
  3. dynamic typeInfo
)

Implementation

matAttribSetter(OpenGLContextES gl, index, typeInfo) {
  var defaultSize = typeInfo.size;
  int count = typeInfo.count;

  return (AttributeBufferInfo b) {
    gl.bindBuffer(gl.ARRAY_BUFFER, b.buffer);
    int numComponents = b.numComponents;
    int size = numComponents ~/ count;
    int type = b.type;
    var typeInfo = typeMap[type];
    int stride = typeInfo.size * numComponents;
    bool normalize = b.normalize || false;
    int offset = b.offset;
    int rowOffset = stride ~/ count;
    for (var i = 0; i < count; ++i) {
      gl.enableVertexAttribArray(index + i);
      gl.vertexAttribPointer(index + i, size, type, normalize, stride, offset + rowOffset * i);
    }
  };
}