createTexture method

WebGLTexture createTexture(
  1. int type,
  2. int target,
  3. int count
)

Implementation

WebGLTexture createTexture(int type, int target, int count) {
  final data = Uint8Array(4);
  // 4 is required to match default unpack alignment of 4.
  //
  final texture = gl.createTexture();

  gl.bindTexture(type, texture);
  gl.texParameteri(type, WebGL.TEXTURE_MIN_FILTER, WebGL.NEAREST);
  gl.texParameteri(type, WebGL.TEXTURE_MAG_FILTER, WebGL.NEAREST);

  for (int i = 0; i < count; i++) {
    gl.texImage2D(target + i, 0, WebGL.RGBA, 1, 1, 0, WebGL.RGBA, WebGL.UNSIGNED_BYTE, data);
  }

  data.dispose();

  return texture;
}