using StgSharp.Math; using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Text; namespace StgSharp.Graphics { public class Uniform where T : struct { internal int id; private IglFunc GL; internal unsafe Uniform( Form.Shader program, string name, IglFunc gL) { byte[] namearray = Encoding.ASCII.GetBytes(name); GL = gL; fixed (byte* ptr = namearray) { id = GL.GetUniformLocation(program.programID, ptr); } } internal unsafe Uniform(int id) { this.id = id; } } public class Uniform where T : struct where U : struct { internal int id; private IglFunc GL; internal unsafe Uniform( Form.Shader program, string name, IglFunc glFunc) { byte[] namearray = Encoding.ASCII.GetBytes(name); GL = glFunc; fixed (byte* ptr = namearray) { id = GL.GetUniformLocation(program.programID, ptr); } } internal unsafe Uniform(int id) { this.id = id; } } public class Uniform where T : struct where U : struct where V : struct { internal int id; private IglFunc GL; public unsafe Uniform(Form.Shader program, string name, IglFunc glFunc) { byte[] namearray = Encoding.ASCII.GetBytes(name); GL = glFunc; fixed (byte* ptr = namearray) { id = GL.GetUniformLocation(program.programID, ptr); } } internal unsafe Uniform(int id) { this.id = id; } } public class Uniform where T : struct where U : struct where V : struct where W : struct { internal int id; private IglFunc GL; internal unsafe Uniform(Form.Shader program, string name, IglFunc glFunc) { byte[] namearray = Encoding.ASCII.GetBytes(name); fixed (byte* ptr = namearray) { id = GL.GetUniformLocation(program.programID, ptr); } GL = glFunc; } internal unsafe Uniform(int id) { this.id = id; } } internal partial class GLonRender : IglFunc { /// /// Set data value to a float , /// all types of parameters are float. /// /// The target /// The value to be set void IglFunc.SetValue(Uniform uniform, float v0) { api.Uniform1f(uniform.id, v0); } /// /// Set data value to a int , /// all types of parameters are int. /// /// The target /// The value to be set void IglFunc.SetValue(Uniform uniform, int i0) { api.Uniform1i(uniform.id, i0); } /// /// Set data value to a float , /// all types of parameters are float. /// /// The target /// The first value to be set /// The second value to be set void IglFunc.SetValue(Uniform uniform, float v0, float v1) { api.Uniform2f(uniform.id, v0, v1); } /// /// Set data value to a float , /// all types of parameters are float. /// /// The target /// The first value to be set /// The second value to be set /// The third value to be set void IglFunc.SetValue(Uniform uniform, float v0, float v1, float v2) { api.Uniform3f(uniform.id, v0, v1, v2); } /// /// Set data value to a float , /// all types of parameters are float. /// /// The target /// The first value to be set /// The second value to be set /// The third value to be set /// The forth value to be set void IglFunc.SetValue(Uniform uniform, float v0, float v1, float v2, float v3) { api.Uniform4f(uniform.id, v0, v1, v2, v3); } /// /// Set data value to a float , /// all types of parameters are float. /// /// The target /// A packing four parameters of the uniform public unsafe void SetValue(Uniform uniform, Vec4d vec) { api.Uniform1fv(uniform.id, 4, &vec.fvec); } /// /// Set data value to a float , /// all types of parameters are . /// /// The target /// A value of the uniform public unsafe void SetValue(Uniform uniform, Vec4d vec) { api.Uniform1fv(uniform.id, 4, &vec.fvec); } } internal partial class GLonUpdate { void IglFunc.SetValue(Uniform uniform, float v0, float v1, float v2) { throw new NotImplementedException(); } void IglFunc.SetValue(Uniform uniform, float v0, float v1) { throw new NotImplementedException(); } void IglFunc.SetValue(Uniform uniform, float v0, float v1, float v2, float v3) { throw new NotImplementedException(); } void IglFunc.SetValue(Uniform uniform, Vec4d vec) { throw new NotImplementedException(); } void IglFunc.SetValue(Uniform uniform, float v0) { throw new NotImplementedException(); } void IglFunc.SetValue(Uniform uniform, int i0) { throw new NotImplementedException(); } void IglFunc.SetValue(Uniform uniform, Vec4d vec) { throw new NotImplementedException(); } } }