private static Shader CompileFromShaders(IEnumerable <Step> shader_steps) { int id = GL.CreateProgram(); foreach (var shader in shader_steps) { GL.AttachShader(id, shader.ResourceID); } GL.LinkProgram(id); foreach (var shader in shader_steps) { GL.DetachShader(id, shader.ResourceID); } string log = GL.GetProgramInfoLog(id); if (!string.IsNullOrWhiteSpace(log)) { throw new Exception(log); } var model_id = new ShaderMatrix(GL.GetUniformLocation(id, "model_matrix")); int pos_id = GL.GetAttribLocation(id, "position"); int uv_id = GL.GetAttribLocation(id, "vertexUV"); int tex_id = GL.GetUniformLocation(id, "texture"); var proj_id = new ShaderMatrix(GL.GetUniformLocation(id, "projection")); int z_id = GL.GetUniformLocation(id, "z"); var view_id = new ShaderMatrix(GL.GetUniformLocation(id, "view")); var music = new ShaderFloat(GL.GetUniformLocation(id, "music")); var uvo = new ShaderMatrix(GL.GetUniformLocation(id, "uv_at")); return(new Shader(id, model_id, tex_id, pos_id, uv_id, proj_id, z_id, view_id, music, uvo)); }
public Shader(int shader_id, ShaderMatrix model_mat, int texture_location, int vertex_location, int uv_location, ShaderMatrix proj, int z_location, ShaderMatrix view, ShaderFloat music, ShaderMatrix uv_offset) { ShaderID = shader_id; Model = model_mat; TextureLocation = texture_location; VertexLocation = vertex_location; UVLocation = uv_location; Projection = proj; ZLocation = z_location; View = view; Music = music; UVOffset = uv_offset; }
/// <summary> /// NextGenSprites: /// Returns the recomended min value for the selected ShaderProperty. /// You are free to overshoot these values. /// </summary> /// <param name="slot">ShaderFloat Enum</param> /// <returns>float</returns> public static float GetMin(this ShaderFloat slot) { return(MinMaxFloatProperties[(int)slot, 0]); }
/// <summary> /// NextGenSprites: /// Returns a string to pass as ShaderProperty for controlling Material properties. /// </summary> /// <param name="slot">ShaderFloat Enum</param> /// <returns>string</returns> public static string GetString(this ShaderFloat slot) { return(FloatProperties [(int)slot]); }