setValueV4f method

dynamic setValueV4f(
  1. dynamic gl,
  2. dynamic v, [
  3. WebGLTextures? textures
])

Implementation

setValueV4f(gl, v, [WebGLTextures? textures]) {
  var cache = this.cache;

  if (v.runtimeType == Vector4) {
    if (cache[0] != v.x ||
        cache[1] != v.y ||
        cache[2] != v.z ||
        cache[3] != v.w) {
      gl.uniform4f(addr, v.x, v.y, v.z, v.w);

      cache[0] = v.x;
      cache[1] = v.y;
      cache[2] = v.z;
      cache[3] = v.w;
    }
  } else if (v is Color) {
    if (cache[0] != v.r ||
        cache[1] != v.g ||
        cache[2] != v.b ||
        cache[3] != 1.0) {
      gl.uniform4f(addr, v.r, v.g, v.b, 1.0);

      cache[0] = v.r.toDouble();
      cache[1] = v.g.toDouble();
      cache[2] = v.b.toDouble();
      cache[3] = 1.0;
    }
  } else if (v is List) {
    if (cache[0] != v[0] ||
        cache[1] != v[1] ||
        cache[2] != v[2] ||
        cache[3] != v[3]) {
      gl.uniform4f(addr, v[0], v[1], v[2], v[3]);

      cache[0] = v[0];
      cache[1] = v[1];
      cache[2] = v[2];
      cache[3] = v[3];
    }
  } else {
    if (arraysEqual(cache, v)) return;

    gl.uniform4fv(addr, v);

    copyArray(cache, v);
  }
}