Holidays 12.10. -> 25.10.2020
~ Moved code around in files. SM.Base: + PostProcessing-system + OnInitialization() for Scenes. + Shader-Extensions + Added option to not react while unfocused to the window. + Added Screenshots to the window. + Connected the log system to the SM.OGL-action system. ~ Replaced IShader with abstract MaterialShader. ~ When a log compression folder doesn't exist, it will create one. SM.OGL: + Added support for UniformArrays + Added ShaderPreProcessing + Added Shader Extensions. + Added Debug actions. + SM.OGL settings ~ Framebuffer Size is automaticly changed, when the window and scale is set. SM2D: + Added easy shader drawing.
This commit is contained in:
parent
2c00dbd31a
commit
03b3942732
102 changed files with 2683 additions and 1398 deletions
|
|
@ -1,27 +1,35 @@
|
|||
using OpenTK;
|
||||
#region usings
|
||||
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
using SM.OGL.Texture;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace SM.OGL.Shaders
|
||||
{
|
||||
/// <summary>
|
||||
/// Manages the uniforms.
|
||||
/// Manages the uniforms.
|
||||
/// </summary>
|
||||
public struct Uniform
|
||||
public struct Uniform : IUniform
|
||||
{
|
||||
/// <summary>
|
||||
/// This contains the location for the uniform.
|
||||
/// This contains the location for the uniform.
|
||||
/// </summary>
|
||||
private int Location;
|
||||
/// <summary>
|
||||
/// This contains the Parent collection of this uniform.
|
||||
/// </summary>
|
||||
internal UniformCollection Parent;
|
||||
|
||||
public int Location { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// This create a new uniform manager
|
||||
/// This contains the Parent collection of this uniform.
|
||||
/// </summary>
|
||||
public UniformCollection Parent { get; }
|
||||
|
||||
public Uniform(int location) : this(location, null)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This create a new uniform manager
|
||||
/// </summary>
|
||||
/// <param name="location">Location id</param>
|
||||
/// <param name="parent">Parent collection</param>
|
||||
|
|
@ -38,114 +46,343 @@ namespace SM.OGL.Shaders
|
|||
GL.Uniform1(Location, value ? 1 : 0);
|
||||
}
|
||||
|
||||
public void SetUniform1(int value) { GL.Uniform1(Location, value); }
|
||||
public void SetUniform1(int count, params int[] values) { GL.Uniform1(Location, count, values); }
|
||||
public void SetUniform1(int count, ref int values) { GL.Uniform1(Location, count, ref values); }
|
||||
public void SetUniform1(int value)
|
||||
{
|
||||
GL.Uniform1(Location, value);
|
||||
}
|
||||
|
||||
public void SetUniform1(int count, params int[] values)
|
||||
{
|
||||
GL.Uniform1(Location, count, values);
|
||||
}
|
||||
|
||||
public void SetUniform1(int count, ref int values)
|
||||
{
|
||||
GL.Uniform1(Location, count, ref values);
|
||||
}
|
||||
|
||||
|
||||
public void SetUniform1(uint value) { GL.Uniform1(Location, value); }
|
||||
public void SetUniform1(int count, params uint[] values) { GL.Uniform1(Location, count, values); }
|
||||
public void SetUniform1(int count, ref uint values) { GL.Uniform1(Location, count, ref values); }
|
||||
public void SetUniform1(uint value)
|
||||
{
|
||||
GL.Uniform1(Location, value);
|
||||
}
|
||||
|
||||
public void SetUniform1(int count, params uint[] values)
|
||||
{
|
||||
GL.Uniform1(Location, count, values);
|
||||
}
|
||||
|
||||
public void SetUniform1(int count, ref uint values)
|
||||
{
|
||||
GL.Uniform1(Location, count, ref values);
|
||||
}
|
||||
|
||||
|
||||
public void SetUniform1(float value) { GL.Uniform1(Location, value); }
|
||||
public void SetUniform1(int count, params float[] values) { GL.Uniform1(Location, count, values); }
|
||||
public void SetUniform1(int count, ref float value) { GL.Uniform1(Location, count, ref value); }
|
||||
public void SetUniform1(float value)
|
||||
{
|
||||
GL.Uniform1(Location, value);
|
||||
}
|
||||
|
||||
public void SetUniform1(int count, params float[] values)
|
||||
{
|
||||
GL.Uniform1(Location, count, values);
|
||||
}
|
||||
|
||||
public void SetUniform1(int count, ref float value)
|
||||
{
|
||||
GL.Uniform1(Location, count, ref value);
|
||||
}
|
||||
|
||||
|
||||
public void SetUniform1(double value) { GL.Uniform1(Location, value); }
|
||||
public void SetUniform1(int count, params double[] values) { GL.Uniform1(Location, count, values); }
|
||||
public void SetUniform1(int count, ref double value) { GL.Uniform1(Location, count, ref value); }
|
||||
public void SetUniform1(double value)
|
||||
{
|
||||
GL.Uniform1(Location, value);
|
||||
}
|
||||
|
||||
public void SetUniform1(int count, params double[] values)
|
||||
{
|
||||
GL.Uniform1(Location, count, values);
|
||||
}
|
||||
|
||||
public void SetUniform1(int count, ref double value)
|
||||
{
|
||||
GL.Uniform1(Location, count, ref value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Uniform2
|
||||
|
||||
public void SetUniform2(float x, float y) { GL.Uniform2(Location, x, y); }
|
||||
public void SetUniform2(double x, double y) { GL.Uniform2(Location, x, y); }
|
||||
public void SetUniform2(uint x, uint y) { GL.Uniform2(Location, x, y); }
|
||||
public void SetUniform2(int x, int y) { GL.Uniform2(Location, x, y); }
|
||||
public void SetUniform2(float x, float y)
|
||||
{
|
||||
GL.Uniform2(Location, x, y);
|
||||
}
|
||||
|
||||
public void SetUniform2(int count, params float[] values) { GL.Uniform2(Location, count, values); }
|
||||
public void SetUniform2(int count, params double[] values) { GL.Uniform2(Location, count, values); }
|
||||
public void SetUniform2(int count, params int[] values) { GL.Uniform2(Location, count, values); }
|
||||
public void SetUniform2(int count, params uint[] values) { GL.Uniform2(Location, count, values); }
|
||||
public void SetUniform2(double x, double y)
|
||||
{
|
||||
GL.Uniform2(Location, x, y);
|
||||
}
|
||||
|
||||
public void SetUniform2(int count, ref float values) { GL.Uniform2(Location, count, ref values); }
|
||||
public void SetUniform2(int count, ref double values) { GL.Uniform2(Location, count, ref values); }
|
||||
public void SetUniform2(int count, ref uint values) { GL.Uniform2(Location, count, ref values); }
|
||||
public void SetUniform2(uint x, uint y)
|
||||
{
|
||||
GL.Uniform2(Location, x, y);
|
||||
}
|
||||
|
||||
public void SetUniform2(Vector2 vector2) { GL.Uniform2(Location, vector2); }
|
||||
public void SetUniform2(ref Vector2 vector2) { GL.Uniform2(Location, ref vector2); }
|
||||
public void SetUniform2(int x, int y)
|
||||
{
|
||||
GL.Uniform2(Location, x, y);
|
||||
}
|
||||
|
||||
public void SetUniform2(int count, params float[] values)
|
||||
{
|
||||
GL.Uniform2(Location, count, values);
|
||||
}
|
||||
|
||||
public void SetUniform2(int count, params double[] values)
|
||||
{
|
||||
GL.Uniform2(Location, count, values);
|
||||
}
|
||||
|
||||
public void SetUniform2(int count, params int[] values)
|
||||
{
|
||||
GL.Uniform2(Location, count, values);
|
||||
}
|
||||
|
||||
public void SetUniform2(int count, params uint[] values)
|
||||
{
|
||||
GL.Uniform2(Location, count, values);
|
||||
}
|
||||
|
||||
public void SetUniform2(int count, ref float values)
|
||||
{
|
||||
GL.Uniform2(Location, count, ref values);
|
||||
}
|
||||
|
||||
public void SetUniform2(int count, ref double values)
|
||||
{
|
||||
GL.Uniform2(Location, count, ref values);
|
||||
}
|
||||
|
||||
public void SetUniform2(int count, ref uint values)
|
||||
{
|
||||
GL.Uniform2(Location, count, ref values);
|
||||
}
|
||||
|
||||
public void SetUniform2(Vector2 vector2)
|
||||
{
|
||||
GL.Uniform2(Location, vector2);
|
||||
}
|
||||
|
||||
public void SetUniform2(ref Vector2 vector2)
|
||||
{
|
||||
GL.Uniform2(Location, ref vector2);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Uniform3
|
||||
|
||||
public void SetUniform3(float x, float y, float z) { GL.Uniform3(Location, x, y, z); }
|
||||
public void SetUniform3(double x, double y, double z) { GL.Uniform3(Location, x, y, z); }
|
||||
public void SetUniform3(uint x, uint y, uint z) { GL.Uniform3(Location, x, y, z); }
|
||||
public void SetUniform3(int x, int y, int z) { GL.Uniform3(Location, x, y, z); }
|
||||
public void SetUniform3(float x, float y, float z)
|
||||
{
|
||||
GL.Uniform3(Location, x, y, z);
|
||||
}
|
||||
|
||||
public void SetUniform3(int count, params float[] values) { GL.Uniform3(Location, count, values); }
|
||||
public void SetUniform3(int count, params double[] values) { GL.Uniform3(Location, count, values); }
|
||||
public void SetUniform3(int count, params int[] values) { GL.Uniform3(Location, count, values); }
|
||||
public void SetUniform3(int count, params uint[] values) { GL.Uniform3(Location, count, values); }
|
||||
public void SetUniform3(double x, double y, double z)
|
||||
{
|
||||
GL.Uniform3(Location, x, y, z);
|
||||
}
|
||||
|
||||
public void SetUniform3(int count, ref float values) { GL.Uniform3(Location, count, ref values); }
|
||||
public void SetUniform3(int count, ref double values) { GL.Uniform3(Location, count, ref values); }
|
||||
public void SetUniform3(int count, ref uint values) { GL.Uniform3(Location, count, ref values); }
|
||||
public void SetUniform3(uint x, uint y, uint z)
|
||||
{
|
||||
GL.Uniform3(Location, x, y, z);
|
||||
}
|
||||
|
||||
public void SetUniform3(Vector3 vector) { GL.Uniform3(Location, vector); }
|
||||
public void SetUniform3(ref Vector3 vector) { GL.Uniform3(Location, ref vector); }
|
||||
public void SetUniform3(int x, int y, int z)
|
||||
{
|
||||
GL.Uniform3(Location, x, y, z);
|
||||
}
|
||||
|
||||
public void SetUniform3(int count, params float[] values)
|
||||
{
|
||||
GL.Uniform3(Location, count, values);
|
||||
}
|
||||
|
||||
public void SetUniform3(int count, params double[] values)
|
||||
{
|
||||
GL.Uniform3(Location, count, values);
|
||||
}
|
||||
|
||||
public void SetUniform3(int count, params int[] values)
|
||||
{
|
||||
GL.Uniform3(Location, count, values);
|
||||
}
|
||||
|
||||
public void SetUniform3(int count, params uint[] values)
|
||||
{
|
||||
GL.Uniform3(Location, count, values);
|
||||
}
|
||||
|
||||
public void SetUniform3(int count, ref float values)
|
||||
{
|
||||
GL.Uniform3(Location, count, ref values);
|
||||
}
|
||||
|
||||
public void SetUniform3(int count, ref double values)
|
||||
{
|
||||
GL.Uniform3(Location, count, ref values);
|
||||
}
|
||||
|
||||
public void SetUniform3(int count, ref uint values)
|
||||
{
|
||||
GL.Uniform3(Location, count, ref values);
|
||||
}
|
||||
|
||||
public void SetUniform3(Vector3 vector)
|
||||
{
|
||||
GL.Uniform3(Location, vector);
|
||||
}
|
||||
|
||||
public void SetUniform3(ref Vector3 vector)
|
||||
{
|
||||
GL.Uniform3(Location, ref vector);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Uniform4
|
||||
|
||||
public void SetUniform4(float x, float y, float z, float w) { GL.Uniform4(Location, x, y, z, w); }
|
||||
public void SetUniform4(double x, double y, double z, double w) { GL.Uniform4(Location, x, y, z, w); }
|
||||
public void SetUniform4(uint x, uint y, uint z, uint w) { GL.Uniform4(Location, x, y, z, w); }
|
||||
public void SetUniform4(int x, int y, int z, int w) { GL.Uniform4(Location, x, y, z, w); }
|
||||
public void SetUniform4(float x, float y, float z, float w)
|
||||
{
|
||||
GL.Uniform4(Location, x, y, z, w);
|
||||
}
|
||||
|
||||
public void SetUniform4(int count, params float[] values) { GL.Uniform4(Location, count, values); }
|
||||
public void SetUniform4(int count, params double[] values) { GL.Uniform4(Location, count, values); }
|
||||
public void SetUniform4(int count, params int[] values) { GL.Uniform4(Location, count, values); }
|
||||
public void SetUniform4(int count, params uint[] values) { GL.Uniform4(Location, count, values); }
|
||||
public void SetUniform4(double x, double y, double z, double w)
|
||||
{
|
||||
GL.Uniform4(Location, x, y, z, w);
|
||||
}
|
||||
|
||||
public void SetUniform4(int count, ref float values) { GL.Uniform4(Location, count, ref values); }
|
||||
public void SetUniform4(int count, ref double values) { GL.Uniform4(Location, count, ref values); }
|
||||
public void SetUniform4(int count, ref uint values) { GL.Uniform4(Location, count, ref values); }
|
||||
public void SetUniform4(uint x, uint y, uint z, uint w)
|
||||
{
|
||||
GL.Uniform4(Location, x, y, z, w);
|
||||
}
|
||||
|
||||
public void SetUniform4(Vector4 vector) { GL.Uniform4(Location, vector); }
|
||||
public void SetUniform4(ref Vector4 vector) { GL.Uniform4(Location, ref vector); }
|
||||
public void SetUniform4(int x, int y, int z, int w)
|
||||
{
|
||||
GL.Uniform4(Location, x, y, z, w);
|
||||
}
|
||||
|
||||
public void SetUniform4(Color4 color) { GL.Uniform4(Location, color); }
|
||||
public void SetUniform4(Quaternion quaternion) { GL.Uniform4(Location, quaternion); }
|
||||
public void SetUniform4(int count, params float[] values)
|
||||
{
|
||||
GL.Uniform4(Location, count, values);
|
||||
}
|
||||
|
||||
public void SetUniform4(int count, params double[] values)
|
||||
{
|
||||
GL.Uniform4(Location, count, values);
|
||||
}
|
||||
|
||||
public void SetUniform4(int count, params int[] values)
|
||||
{
|
||||
GL.Uniform4(Location, count, values);
|
||||
}
|
||||
|
||||
public void SetUniform4(int count, params uint[] values)
|
||||
{
|
||||
GL.Uniform4(Location, count, values);
|
||||
}
|
||||
|
||||
public void SetUniform4(int count, ref float values)
|
||||
{
|
||||
GL.Uniform4(Location, count, ref values);
|
||||
}
|
||||
|
||||
public void SetUniform4(int count, ref double values)
|
||||
{
|
||||
GL.Uniform4(Location, count, ref values);
|
||||
}
|
||||
|
||||
public void SetUniform4(int count, ref uint values)
|
||||
{
|
||||
GL.Uniform4(Location, count, ref values);
|
||||
}
|
||||
|
||||
public void SetUniform4(Vector4 vector)
|
||||
{
|
||||
GL.Uniform4(Location, vector);
|
||||
}
|
||||
|
||||
public void SetUniform4(ref Vector4 vector)
|
||||
{
|
||||
GL.Uniform4(Location, ref vector);
|
||||
}
|
||||
|
||||
public void SetUniform4(Color4 color)
|
||||
{
|
||||
GL.Uniform4(Location, color);
|
||||
}
|
||||
|
||||
public void SetUniform4(Quaternion quaternion)
|
||||
{
|
||||
GL.Uniform4(Location, quaternion);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Matrix2
|
||||
|
||||
public void SetMatrix2(ref Matrix2 matrix, bool transpose = false) { GL.UniformMatrix2(Location, transpose, ref matrix); }
|
||||
public void SetMatrix2(ref Matrix2 matrix, bool transpose = false)
|
||||
{
|
||||
GL.UniformMatrix2(Location, transpose, ref matrix);
|
||||
}
|
||||
|
||||
public void SetMatrix2(int count, ref double value, bool transpose = false) { GL.UniformMatrix2(Location, count, transpose, ref value); }
|
||||
public void SetMatrix2(int count, ref float value, bool transpose = false) { GL.UniformMatrix2(Location, count, transpose, ref value); }
|
||||
public void SetMatrix2(int count, ref double value, bool transpose = false)
|
||||
{
|
||||
GL.UniformMatrix2(Location, count, transpose, ref value);
|
||||
}
|
||||
|
||||
public void SetMatrix2(int count, double[] value, bool transpose = false) { GL.UniformMatrix2(Location, count, transpose, value); }
|
||||
public void SetMatrix2(int count, float[] value, bool transpose = false) { GL.UniformMatrix2(Location, count, transpose, value); }
|
||||
public void SetMatrix2(int count, ref float value, bool transpose = false)
|
||||
{
|
||||
GL.UniformMatrix2(Location, count, transpose, ref value);
|
||||
}
|
||||
|
||||
public void SetMatrix2(int count, double[] value, bool transpose = false)
|
||||
{
|
||||
GL.UniformMatrix2(Location, count, transpose, value);
|
||||
}
|
||||
|
||||
public void SetMatrix2(int count, float[] value, bool transpose = false)
|
||||
{
|
||||
GL.UniformMatrix2(Location, count, transpose, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Matrix3
|
||||
|
||||
public void SetMatrix3(ref Matrix3 matrix, bool transpose = false) { GL.UniformMatrix3(Location, transpose, ref matrix); }
|
||||
public void SetMatrix3(ref Matrix3 matrix, bool transpose = false)
|
||||
{
|
||||
GL.UniformMatrix3(Location, transpose, ref matrix);
|
||||
}
|
||||
|
||||
public void SetMatrix3(int count, ref double value, bool transpose = false) { GL.UniformMatrix3(Location, count, transpose, ref value); }
|
||||
public void SetMatrix3(int count, ref float value, bool transpose = false) { GL.UniformMatrix3(Location, count, transpose, ref value); }
|
||||
public void SetMatrix3(int count, ref double value, bool transpose = false)
|
||||
{
|
||||
GL.UniformMatrix3(Location, count, transpose, ref value);
|
||||
}
|
||||
|
||||
public void SetMatrix3(int count, double[] value, bool transpose = false) { GL.UniformMatrix3(Location, count, transpose, value); }
|
||||
public void SetMatrix3(int count, float[] value, bool transpose = false) { GL.UniformMatrix3(Location, count, transpose, value); }
|
||||
public void SetMatrix3(int count, ref float value, bool transpose = false)
|
||||
{
|
||||
GL.UniformMatrix3(Location, count, transpose, ref value);
|
||||
}
|
||||
|
||||
public void SetMatrix3(int count, double[] value, bool transpose = false)
|
||||
{
|
||||
GL.UniformMatrix3(Location, count, transpose, value);
|
||||
}
|
||||
|
||||
public void SetMatrix3(int count, float[] value, bool transpose = false)
|
||||
{
|
||||
GL.UniformMatrix3(Location, count, transpose, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -155,18 +392,36 @@ namespace SM.OGL.Shaders
|
|||
{
|
||||
GL.UniformMatrix4(Location, transpose, ref matrix);
|
||||
}
|
||||
public void SetMatrix4(ref Matrix4 matrix, bool transpose = false) { GL.UniformMatrix4(Location, transpose, ref matrix); }
|
||||
|
||||
public void SetMatrix4(int count, ref double value, bool transpose = false) { GL.UniformMatrix4(Location, count, transpose, ref value); }
|
||||
public void SetMatrix4(int count, ref float value, bool transpose = false) { GL.UniformMatrix4(Location, count, transpose, ref value); }
|
||||
public void SetMatrix4(ref Matrix4 matrix, bool transpose = false)
|
||||
{
|
||||
GL.UniformMatrix4(Location, transpose, ref matrix);
|
||||
}
|
||||
|
||||
public void SetMatrix4(int count, double[] value, bool transpose = false) { GL.UniformMatrix4(Location, count, transpose, value); }
|
||||
public void SetMatrix4(int count, float[] value, bool transpose = false) { GL.UniformMatrix4(Location, count, transpose, value); }
|
||||
public void SetMatrix4(int count, ref double value, bool transpose = false)
|
||||
{
|
||||
GL.UniformMatrix4(Location, count, transpose, ref value);
|
||||
}
|
||||
|
||||
public void SetMatrix4(int count, ref float value, bool transpose = false)
|
||||
{
|
||||
GL.UniformMatrix4(Location, count, transpose, ref value);
|
||||
}
|
||||
|
||||
public void SetMatrix4(int count, double[] value, bool transpose = false)
|
||||
{
|
||||
GL.UniformMatrix4(Location, count, transpose, value);
|
||||
}
|
||||
|
||||
public void SetMatrix4(int count, float[] value, bool transpose = false)
|
||||
{
|
||||
GL.UniformMatrix4(Location, count, transpose, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Try to sets the texture at the next possible position and tells the checkUniform, if worked or not.
|
||||
/// Try to sets the texture at the next possible position and tells the checkUniform, if worked or not.
|
||||
/// </summary>
|
||||
/// <param name="texture">The texture you want to add</param>
|
||||
/// <param name="checkUniform">The check uniform.</param>
|
||||
|
|
@ -177,7 +432,7 @@ namespace SM.OGL.Shaders
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Try to sets the texture at the specified position and tells the checkUniform, if worked or not.
|
||||
/// Try to sets the texture at the specified position and tells the checkUniform, if worked or not.
|
||||
/// </summary>
|
||||
/// <param name="texture">The texture you want to add</param>
|
||||
/// <param name="pos">The position</param>
|
||||
|
|
@ -187,14 +442,18 @@ namespace SM.OGL.Shaders
|
|||
checkUniform.SetUniform1(texture != null);
|
||||
if (texture != null) SetTexture(texture);
|
||||
}
|
||||
/// <summary>
|
||||
/// Sets the texture to the next possible position.
|
||||
/// </summary>
|
||||
/// <param name="texture"></param>
|
||||
public void SetTexture(TextureBase texture) => SetTexture(texture, Parent.NextTexture++);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the texture to the specified position.
|
||||
/// Sets the texture to the next possible position.
|
||||
/// </summary>
|
||||
/// <param name="texture"></param>
|
||||
public void SetTexture(TextureBase texture)
|
||||
{
|
||||
if (Parent != null) SetTexture(texture, Parent.NextTexture++);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the texture to the specified position.
|
||||
/// </summary>
|
||||
/// <param name="texture"></param>
|
||||
/// <param name="texturePos"></param>
|
||||
|
|
@ -206,9 +465,12 @@ namespace SM.OGL.Shaders
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the location from the uniform
|
||||
/// Returns the location from the uniform
|
||||
/// </summary>
|
||||
/// <param name="u"></param>
|
||||
public static implicit operator int(Uniform u) => u.Location;
|
||||
public static implicit operator int(Uniform u)
|
||||
{
|
||||
return u.Location;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue