samplerSetter method

dynamic samplerSetter(
  1. OpenGLContextES gl,
  2. dynamic type,
  3. int unit,
  4. dynamic location, [
  5. dynamic test,
])

Implementation

samplerSetter(OpenGLContextES gl, type, int unit, location, [test]) {
  var bindPoint = getBindPointForSamplerType(gl, type);
  return (dynamic textureOrPair) {
    int texture = textureOrPair;
    // if (textureOrPair is WebGLTexture) {
    //   texture = textureOrPair;
    // } else {
    //   // maybe I don't need this part for now.
    //   texture = textureOrPair.texture;
    //   gl.bindSampler(unit, textureOrPair.sampler); // ! fix this
    // }

    gl.uniform1i(location, unit);
    gl.activeTexture(gl.TEXTURE0 + unit);
    gl.bindTexture(bindPoint, texture);
  };
}