/* * File: ShaderMaterial.js * Knows how to load aMaterial into the IllumShader * Rederences point to uMaterial. */ /*jslint node: true, vars: true */ /*global gEngine, vec4 */ /* find out more about jslint: http://www.jslint.com/help.html */ "use strict"; // Operate in Strict mode such that variables must be declared before used! // // constructor function ShaderMaterial(aIllumShader) { // reference to the normal map sampler var gl = gEngine.Core.getGL(); this.mKaRef = gl.getUniformLocation(aIllumShader, "uMaterial.Ka"); this.mKdRef = gl.getUniformLocation(aIllumShader, "uMaterial.Kd"); this.mKsRef = gl.getUniformLocation(aIllumShader, "uMaterial.Ks"); this.mShineRef = gl.getUniformLocation(aIllumShader, "uMaterial.Shininess"); } // // // Loads material onto the shader ShaderMaterial.prototype.loadToShader = function (aMaterial) { var gl = gEngine.Core.getGL(); gl.uniform4fv(this.mKaRef, aMaterial.getAmbient()); gl.uniform4fv(this.mKdRef, aMaterial.getDiffuse()); gl.uniform4fv(this.mKsRef, aMaterial.getSpecular()); gl.uniform1f(this.mShineRef, aMaterial.getShininess()); }; //