Created
August 30, 2018 18:47
-
-
Save jt0dd/869cbb85998f91f13792157ff6143b2e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_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