Added enabling for all attributes and removed irresponsible default. Untested.

This commit is contained in:
Harrison Deng 2020-03-01 18:09:07 -05:00
parent 5b44fee033
commit 583988c333

View File

@ -23,14 +23,19 @@ namespace RecrownedGTK.Graphics {
/// <param name="textureAttribName">The name of the attribute for the texture's coordinate. Default is "aTexture".</param>
/// <param name="colorAttribName">The name of the attribute for color mixture. Default is "aColor".</param>
/// <returns>The built <see cref="RecrownedGTK.Graphics.VertexAttributesArrayHandle"/>.</returns>
public static VertexAttributesArrayHandle CreateBasicVA(ref Matrix4 transformMat, Shader shader = null, string positionAttribName = "aPosition", string textureAttribName = "aTexture", string colorAttribName = "aColor", string transformUnifName = "transform") {
public static VertexAttributesArrayHandle CreateBasicVA(ref Matrix4 transformMat, Shader shader, string positionAttribName = "aPosition", string textureAttribName = "aTexture", string colorAttribName = "aColor", string transformUnifName = "transform") {
VertexAttributesArrayHandle vertexAttribs = new VertexAttributesArrayHandle();
vertexAttribs.Bind();
if (transformMat == default(Matrix4)) transformMat = Matrix4.Identity;
GL.UniformMatrix4(shader.GetAttribLocation(transformUnifName), true, ref transformMat);
GL.VertexAttribPointer(shader.GetAttribLocation(positionAttribName), 3, VertexAttribPointerType.Float, false, 9 * sizeof(float), 0);
GL.EnableVertexAttribArray(shader.GetAttribLocation(positionAttribName));
GL.VertexAttribPointer(shader.GetAttribLocation(textureAttribName), 2, VertexAttribPointerType.Float, false, 9 * sizeof(float), 3 * sizeof(float));
GL.EnableVertexAttribArray(shader.GetAttribLocation(textureAttribName));
GL.VertexAttribPointer(shader.GetAttribLocation(colorAttribName), 4, VertexAttribPointerType.Float, false, 9 * sizeof(float), 5 * sizeof(float));
GL.EnableVertexAttribArray(shader.GetAttribLocation(colorAttribName));
return vertexAttribs;
}