18.09.2020

+ Textures
~ Changed 2D coordnate system to lower right as XY+
This commit is contained in:
Michel Fedde 2020-09-19 15:04:04 +02:00
parent 589d131246
commit a603ecc417
26 changed files with 267 additions and 16 deletions

View file

@ -30,6 +30,7 @@ namespace SM.OGL.Shaders
throw new Exception("[Critical] No uniforms has been found.");
Uniforms = new UniformCollection();
Uniforms._parentShader = this;
for (int i = 0; i < uniformCount; i++)
{
string key = GL.GetActiveUniform(_id, i, out _, out _);

View file

@ -1,6 +1,7 @@
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL4;
using SM.OGL.Texture;
namespace SM.OGL.Shaders
{
@ -160,5 +161,14 @@ namespace SM.OGL.Shaders
public void SetMatrix4(int count, float[] value, bool transpose = false) { GL.UniformMatrix4(Location, count, transpose, value); }
#endregion
public void SetTexture(TextureBase texture) => SetTexture(texture, Parent.NextTexture++);
public void SetTexture(TextureBase texture, int texturePos)
{
GL.ActiveTexture(TextureUnit.Texture0 + texturePos);
GL.BindTexture(TextureTarget.Texture2D, texture);
SetUniform1(texturePos);
}
}
}

View file

@ -6,6 +6,8 @@ namespace SM.OGL.Shaders
{
public class UniformCollection : Dictionary<string, Uniform>
{
internal int NextTexture = 0;
internal GenericShader _parentShader;
public new Uniform this[string key]