replaceSampler2DUniform method

bool replaceSampler2DUniform(
  1. String name,
  2. int width,
  3. int height,
  4. Uint8List val,
)

**** REPLACE SAMPLER2D UNIFORM

  • replace Sampler2D uniform texture with another one with different size

Implementation

bool replaceSampler2DUniform(
  String name,
  int width,
  int height,
  Uint8List val,
) {
  assert(
      val.length == width * height * 4,
      "\nAssert error: RGBA32 raw image length mismatch."
      "\nYou have passed a Uint8list with ${val.length}"
      "\nIt should be $width x $height * 4 = ${width * height * 4}");
  ffi.Pointer<ffi.Int8> valT = calloc(ffi.sizeOf<ffi.Int8>() * val.length);
  for (int i = 0; i < val.length; ++i) {
    valT[i] = val[i];
  }

  int ret = _replaceSampler2DUniform(
    name.toNativeUtf8().cast<ffi.Char>(),
    width,
    height,
    valT.cast<ffi.Void>(),
  );
  calloc.free(valT);
  return ret == 0 ? false : true;
}