drawBufferInfo static method

dynamic drawBufferInfo(
  1. OpenGLContextES gl,
  2. BufferInfo bufferInfo, [
  3. dynamic type,
  4. dynamic count,
  5. dynamic offset,
])

Draws the buffer info.

  • gl the OpenGlES context.
  • bufferInfo the object buffer info.
  • type the draw type. default value is gl.TRIANGLES.
  • tycountpe the count value. default value is 0.
  • offset the offset value. default value is 0.

Implementation

static drawBufferInfo(OpenGLContextES gl, BufferInfo bufferInfo, [type, count, offset]) {
  // type = type == null ? gl.TRIANGLES : type;
  type ??= gl.TRIANGLES;
  var indices = bufferInfo.indices;
  var elementType = bufferInfo.elementType;
  // var numElements = count == null ? bufferInfo.numElements : count;
  int numElements;
  if (count == null) {
    numElements = bufferInfo.numElements;
  } else {
    numElements = count;
  }
  offset ??= 0;
  if (elementType != null || indices != null) {
    int primitiveType = type;
    int _count = numElements;
    int _type = elementType == null ? gl.UNSIGNED_SHORT : bufferInfo.elementType;
    int _offset = offset;
    // 4, 3, 5123, 0
    gl.drawElements(primitiveType, _count, _type, _offset);
  } else {
    gl.drawArrays(type, offset, numElements);
  }
}