encodeWebGlSection function
The section bytes for vertex and fragment sources.
Throws a StageAgreementException when a vertex stage and the fragment stage its name pairs it with (pairedFragmentStage) disagree on a varying or a uniform block: the bundle is refused with both names before a browser links the pair and draws zeros.
Implementation
ByteData encodeWebGlSection({
required Map<String, String> vertex,
required Map<String, String> fragment,
}) {
requireBundleAgreement(vertex: vertex, fragment: fragment);
final text = jsonEncode(<String, Object>{
'vertex': vertex,
'fragment': fragment,
});
return Uint8List.fromList(utf8.encode(text)).buffer.asByteData();
}