Added summeries to SM.OGL

This commit is contained in:
Michel Fedde 2020-09-27 13:01:50 +02:00
parent 2aa12f8d25
commit 16366fa015
15 changed files with 363 additions and 27 deletions

View file

@ -4,25 +4,48 @@ using OpenTK.Graphics.OpenGL4;
namespace SM.OGL.Shaders
{
/// <summary>
/// Collects all files that are needed for a shader.
/// </summary>
public struct ShaderFileCollection
{
/// <summary>
/// Contains the vertex file.
/// </summary>
public ShaderFile Vertex;
/// <summary>
/// Contains the geometry file.
/// </summary>
public ShaderFile Geometry;
/// <summary>
/// Contains the fragment file.
/// </summary>
public ShaderFile Fragment;
public Action<UniformCollection> SetUniforms;
/// <summary>
/// Creating the collection with vertex and fragment files.
/// </summary>
/// <param name="vertex">The vertex source file.</param>
/// <param name="fragment">The fragment source file.</param>
public ShaderFileCollection(string vertex, string fragment) : this(new ShaderFile(vertex), new ShaderFile(fragment)) {}
/// <summary>
/// Creating the collection with shader files.
/// </summary>
/// <param name="vertex"></param>
/// <param name="fragment"></param>
/// <param name="geometry"></param>
public ShaderFileCollection(ShaderFile vertex, ShaderFile fragment, ShaderFile geometry = default)
{
Vertex = vertex;
Geometry = geometry;
Fragment = fragment;
SetUniforms = u => { };
}
/// <summary>
/// Appends the files to the shader.
/// </summary>
/// <param name="shader"></param>
internal void Append(GenericShader shader)
{
Vertex.Compile(shader, ShaderType.VertexShader);
@ -30,6 +53,10 @@ namespace SM.OGL.Shaders
Fragment.Compile(shader, ShaderType.FragmentShader);
}
/// <summary>
/// Removes the files form the shader.
/// </summary>
/// <param name="shader"></param>
internal void Detach(GenericShader shader)
{
GL.DetachShader(Vertex, shader);