Newer
Older
pixi.js / packages / core / src / shader / utils / setPrecision.js
@Ivan Popelyshev Ivan Popelyshev on 11 Jan 2019 549 bytes Update Program with shader language version (#5331)
/**
 * Sets the float precision on the shader. If the precision is already present this function will do nothing
 * @private
 * @param {string} src       the shader source
 * @param {string} precision The float precision of the shader. Options are 'lowp', 'mediump' or 'highp'.
 *
 * @return {string} modified shader source
 */
export default function setPrecision(src, precision)
{
    if (src.substring(0, 9) !== 'precision')// && src.substring(0, 1) !== '#')
    {
        return `precision ${precision} float;\n${src}`;
    }

    return src;
}