using System;
using System.Collections.Generic;
using OpenTK.Graphics.OpenGL4;
namespace SM.OGL.Shaders
{
///
/// Contains and manages the uniform of the parent shader.
///
public class UniformCollection : Dictionary
{
///
/// The next texture id for the uniform.
///
internal int NextTexture = 0;
///
/// The parent shader.
///
internal GenericShader _parentShader;
///
/// Get you the uniform under the variable name.
/// If it don't find the uniform, it tries to recreate it.
/// If the variable doesn't exist in the first place, it will after the recreation send everything to -1, what is the void.
///
///
///
public new Uniform this[string key]
{
get
{
try
{
return base[key];
}
catch (KeyNotFoundException)
{
Console.WriteLine("[Error] Uniform '"+key+"' was not found. Tried to recreate it.");
Uniform u = new Uniform(GL.GetUniformLocation(_parentShader, key), this);
Add(key, u);
return u;
}
}
}
///
/// Adds a uniform with a location.
///
///
///
public void Add(string key, int location)
{
base.Add(key, new Uniform(location, this));
}
}
}