drawBufferInfo static method

dynamic drawBufferInfo(
  1. OpenGLContextES gl,
  2. BufferInfo bufferInfo, [
  3. dynamic mode,
  4. dynamic count,
  5. int offset = 0,
])

Draws the buffer info.

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

Implementation

static drawBufferInfo(OpenGLContextES gl, BufferInfo bufferInfo, [mode, count, int offset = 0]) {
  mode ??= gl.TRIANGLES;
  count ??= bufferInfo.numElements;

  var indices = bufferInfo.indices;
  dynamic elementType = bufferInfo.elementType;

  // glClearError(gl);
  if (elementType != null || indices != null) {
    int type = elementType == null ? gl.UNSIGNED_SHORT : bufferInfo.elementType;
    // 4, 3, 5123, 0
    // Draw ellements if you have an index buffer.
    gl.drawElements(mode, count, type, offset);
  } else {
    // Draw arrays if you don't have an index buffer.
    gl.drawArrays(mode, offset, count);
  }
  // glLogCall(gl);
}