encodeMaterialCompileRequest function
request as the text a compiler's process reads: JSON, with the
stages, their GLSL and the engine's headers, and the options that are
JSON already (a compiler from outside reads none of the engine's own).
Implementation
String encodeMaterialCompileRequest(MaterialCompileRequest request) =>
jsonEncode(<String, Object?>{
'name': request.name,
'from': request.from,
'source': request.source,
'atRunTime': request.atRunTime,
'stages': <Object?>[
for (final stage in request.stages)
<String, Object?>{
'name': stage.name,
'kind': stage.kind.name,
'glsl': stage.glsl,
},
],
'engineSources': request.engineSources,
'options': <String, Object?>{
for (final MapEntry(:key, :value) in request.options.entries)
if (value == null || value is String || value is num || value is bool)
key: value,
},
});