Skip to content

Instantly share code, notes, and snippets.

@jt0dd
Created August 30, 2018 18:47
Show Gist options
  • Save jt0dd/869cbb85998f91f13792157ff6143b2e to your computer and use it in GitHub Desktop.
Save jt0dd/869cbb85998f91f13792157ff6143b2e to your computer and use it in GitHub Desktop.
_getMainConstantsString() {
const result = [];
if (this.constants) {
for (let name in this.constants) {
if (!this.constants.hasOwnProperty(name)) continue;
let value = this.constants[name];
let type = utils.getArgumentType(value);
console.log("Constant detected of type:", type);
switch (type) {
case 'Integer':
result.push('const float constants_' + name + ' = ' + parseInt(value) + '.0');
break;
case 'Float':
result.push('const float constants_' + name + ' = ' + parseFloat(value));
break;
case 'Texture':
result.push(
`uniform sampler2D constants_${ name }`,
`uniform ivec2 constants_${ name }Size`,
`uniform ivec3 constants_${ name }Dim`
);
break;
default:
throw new Error(`Unsupported constant ${ name } type ${ type }`);
}
}
}
return this._linesToString(result);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment