addSampler2DUniform method
**** ADD SAMPLER2D UNIFORM
- Add a Sampler2D uniform. The raw image stored in val must be in RGBA32 format.
Implementation
bool addSampler2DUniform(
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 = _addSampler2DUniform(
name.toNativeUtf8().cast<ffi.Char>(),
width,
height,
valT.cast<ffi.Void>(),
);
calloc.free(valT);
return ret == 0 ? false : true;
}