(function() {"use strict";var __module = CC_EDITOR ? module : {exports:{}};var __filename = 'preview-scripts/assets/Script/Shader/ShaderUtils.js';var __require = CC_EDITOR ? function (request) {return cc.require(request, require);} : function (request) {return cc.require(request, __filename);};function __define (exports, require, module) {"use strict";
cc._RF.push(module, '4c680n1xh5EoZhDNiPPTxkC', 'ShaderUtils', __filename);
// Script/Shader/ShaderUtils.js

"use strict";

var ShaderUtils = {
    shaderPrograms: {},

    setShader: function setShader(sprite, vertName, fragName) {
        // var glProgram = this.shaderPrograms[shaderName];
        // if (!glProgram) {
        var glProgram = new cc.GLProgram();
        var vert = require(cc.js.formatStr("%s.vert", vertName));
        var frag = require(cc.js.formatStr("%s.frag", fragName));
        glProgram.initWithString(vert, frag);
        if (!cc.sys.isNative) {
            glProgram.initWithVertexShaderByteArray(vert, frag);
            glProgram.addAttribute(cc.macro.ATTRIBUTE_NAME_POSITION, cc.macro.VERTEX_ATTRIB_POSITION);
            glProgram.addAttribute(cc.macro.ATTRIBUTE_NAME_COLOR, cc.macro.VERTEX_ATTRIB_COLOR);
            glProgram.addAttribute(cc.macro.ATTRIBUTE_NAME_TEX_COORD, cc.macro.VERTEX_ATTRIB_TEX_COORDS);
        }
        glProgram.link();
        glProgram.updateUniforms();
        // this.shaderPrograms[shaderName] = glProgram;
        // }
        sprite._sgNode.setShaderProgram(glProgram);
        var g1 = cc._renderContext;

        var a_position = g1.getAttribLocation(glProgram._programObj, 'a_position');
        var a_texCoord = g1.getAttribLocation(glProgram._programObj, 'a_texCoord');
        console.log('a_position', a_position);
        console.log('a_texCoord', a_texCoord);
        return glProgram;
    }
};

module.exports = ShaderUtils;

cc._RF.pop();
        }
        if (CC_EDITOR) {
            __define(__module.exports, __require, __module);
        }
        else {
            cc.registerModuleFunc(__filename, function () {
                __define(__module.exports, __require, __module);
            });
        }
        })();
        //# sourceMappingURL=ShaderUtils.js.map
        