///// <summary> ///// ///// </summary> ///// <typeparam name="T"></typeparam> ///// <param name="blockName"></param> ///// <param name="value"></param> ///// <returns></returns> //public bool SetUniformBlock<T>(string blockName, T value) where T : struct,IEquatable<T> //{ // //if ((!this.Initialized) && (!this.Initializing)) { this.Initialize(); } // bool gotUniform = false; // bool updated = false; // foreach (UniformVariable item in this.uniformVariables) // { // if (item.VarName == blockName) // { // var variable = item as UniformBlock<T>; // if (variable == null) // { throw new ArgumentException(string.Format("Wrong type[{0}] for uniform block [{1}] [{2}];", typeof(T), item.GetType().Name, item.VarName)); } // variable.Value = value; // updated = variable.Updated; // gotUniform = true; // break; // } // } // if (!gotUniform) // { // //if (ShaderProgram == null) // //{ throw new Exception(string.Format("{0} is not initialized!", this.GetType().Name)); } // //int location = ShaderProgram.GetUniformLocation(varNameInShader); // //if (location < 0) // //{ // // throw new Exception(string.Format( // // "niform variable [{0}] not exists! Remember to invoke RendererBase.Initialize(); before this method.", varNameInShader)); // //} // var variable = new UniformBlock<T>(blockName); // variable.Value = value; // this.uniformVariables.Add(variable); // updated = true; // } // return updated; //} /// <summary> /// Sets up a new value to specified uniform variable and mark it as updated so that the new value will be sent to shader before rendering. /// </summary> /// <param name="varNameInShader"></param> /// <param name="texture"></param> /// <returns></returns> public bool SetUniform(string varNameInShader, Texture texture) { return(this.SetUniform(varNameInShader, texture.ToSamplerValue())); }