20.09.2020

+ Instance Drawing
+ Text and Font

~ Made "DrawBackground" forced Background for 2D

- DrawEmpty
This commit is contained in:
Michel Fedde 2020-09-20 18:29:09 +02:00
parent acccf5f0e7
commit c4a0847567
29 changed files with 365 additions and 85 deletions

View file

@ -7,6 +7,8 @@ namespace SM.OGL
protected int _id = -1;
protected virtual bool AutoCompile { get; } = false;
public bool WasCompiled => _id > 0;
public virtual int ID
{
get

View file

@ -36,7 +36,8 @@ namespace SM.OGL.Shaders
string key = GL.GetActiveUniform(_id, i, out _, out _);
int loc = GL.GetUniformLocation(_id, key);
if (key.StartsWith("[")) key = key.Split('[', ']')[0];
if (key.EndsWith("]"))
key = key.Split('[', ']')[0];
Uniforms.Add(key, loc);
}
@ -47,10 +48,10 @@ namespace SM.OGL.Shaders
Load();
}
public void DrawObject(Mesh.Mesh mesh, bool bindVAO = false)
public void DrawObject(Mesh.Mesh mesh, int amount, bool bindVAO = false)
{
if (bindVAO) GL.BindVertexArray(mesh);
GL.DrawArrays(mesh.PrimitiveType, 0, mesh.Vertex.Count);
}
GL.DrawArraysInstanced(mesh.PrimitiveType, 0, mesh.Vertex.Count, amount);
}
}
}

View file

@ -181,5 +181,7 @@ namespace SM.OGL.Shaders
GL.BindTexture(TextureTarget.Texture2D, texture);
SetUniform1(texturePos);
}
public static implicit operator int(Uniform u) => u.Location;
}
}