///<summary> Vector4 and Matrix4. Matrix4 is a buffer reference. /// Attributes in 0,4-7 set up.</summary> public static GLRenderableItem CreateVector4Matrix4(GLItemsList items, PrimitiveType prim, GLRenderState pt, Vector4[] vectors, GLBuffer matrix, IGLRenderItemData id = null, int ic = 1, int matrixdivisor = 1) { var vb = items.NewBuffer(); vb.AllocateFill(vectors); // push in model vectors var va = items.NewArray(); vb.Bind(va, 0, vb.Positions[0], 16); va.Attribute(0, 0, 4, VertexAttribType.Float); // bp 0 at attrib 0 matrix.Bind(va, 2, matrix.Positions[0], 64, matrixdivisor); // use a binding va.MatrixAttribute(2, 4); // bp 2 at attribs 4-7 return(new GLRenderableItem(prim, pt, vectors.Length, va, id, ic)); }
/// <summary> Two Vector4s, second in a given buffer. Second vector can be instance divided. In attributes 0,1</summary> public static GLRenderableItem CreateVector4Vector4(GLItemsList items, PrimitiveType prim, GLRenderState pt, Vector4[] vectors, GLBuffer buf2, int bufoff = 0, IGLRenderItemData id = null, int ic = 1, int seconddivisor = 0) { var vb = items.NewBuffer(); vb.AllocateBytes(GLBuffer.Vec4size * vectors.Length); vb.Fill(vectors); var va = items.NewArray(); vb.Bind(va, 0, vb.Positions[0], 16); va.Attribute(0, 0, 4, VertexAttribType.Float); buf2.Bind(va, 1, bufoff, 16, seconddivisor); va.Attribute(1, 1, 4, VertexAttribType.Float); return(new GLRenderableItem(prim, pt, vectors.Length, va, id, ic)); }
///<summary> Vector4, Vector2 and Matrix4 in buffers. First is model, second is coords, third is instance matrix translation /// if separbuffer = true and instancematrix is null, it makes a buffer for you to fill up externally. /// if separbuffer = true it makes as separate buffer for instancematrix /// if separbuffer = true and instancematrix is null, you fill up the separbuffer yourself outside of this (maybe auto generated). /// You can get this buffer using items.LastBuffer() /// Attributes in 0,1,4-7 set up.</summary> public static GLRenderableItem CreateVector4Vector2Matrix4(GLItemsList items, PrimitiveType prim, GLRenderState pt, Vector4[] vectors, Vector2[] coords, Matrix4[] instancematrix, IGLRenderItemData id = null, int ic = 1, bool separbuf = false, int matrixdivisor = 1) { var va = items.NewArray(); GLBuffer vbuf1 = items.NewBuffer(); GLBuffer vbuf2 = vbuf1; int posi = 2; if (separbuf) { vbuf1.AllocateBytes(GLBuffer.Vec4size * vectors.Length + GLBuffer.Vec2size * coords.Length); vbuf2 = items.NewBuffer(); if (instancematrix != null) { vbuf2.AllocateBytes(GLBuffer.Mat4size * instancematrix.Length); } posi = 0; } else { vbuf1.AllocateBytes(GLBuffer.Vec4size * vectors.Length + GLBuffer.Vec2size * coords.Length + GLBuffer.Vec4size + GLBuffer.Mat4size * instancematrix.Length); // due to alignment, add on a little } vbuf1.Fill(vectors); vbuf1.Fill(coords); if (instancematrix != null) { vbuf2.Fill(instancematrix); } vbuf1.Bind(va, 0, vbuf1.Positions[0], 16); va.Attribute(0, 0, 4, VertexAttribType.Float); // bp 0 at 0 vbuf1.Bind(va, 1, vbuf1.Positions[1], 8); va.Attribute(1, 1, 2, VertexAttribType.Float); // bp 1 at 1 va.MatrixAttribute(2, 4); // bp 2 at 4-7 vbuf2.Bind(va, 2, instancematrix != null ? vbuf2.Positions[posi]: 0, 64, matrixdivisor); // use a binding return(new GLRenderableItem(prim, pt, vectors.Length, va, id, ic)); }
///<summary> Vector4, Vector2 and Matrix4 in buffers. First is model, second is coords, third is instance matrix translation /// All are supplied by buffer references /// Attributes in 0,1,4-7 set up.</summary> public static GLRenderableItem CreateVector4Vector2Matrix4(GLItemsList items, PrimitiveType prim, GLRenderState pt, GLBuffer vbuf1, GLBuffer vbuf2, GLBuffer vbuf3, int vertexcount, IGLRenderItemData id = null, int ic = 1, int matrixdivisor = 1, int buf1pos = 0, int buf2pos = 0, int buf3pos = 0) { var va = items.NewArray(); vbuf1.Bind(va, 0, buf1pos, 16); va.Attribute(0, 0, 4, VertexAttribType.Float); // bp 0 at 0 vbuf2.Bind(va, 1, buf2pos, 8); va.Attribute(1, 1, 2, VertexAttribType.Float); // bp 1 at 1 va.MatrixAttribute(2, 4); // bp 2 at 4-7 vbuf3.Bind(va, 2, buf3pos, 64, matrixdivisor); // use a binding return(new GLRenderableItem(prim, pt, vertexcount, va, id, ic)); }
/// <summary> Two Vector4s, and a Vector2. Second given in buffer. First/Second in one buffer. Second and Third vector can be instance divided. In attributes 0,1,2</summary> public static GLRenderableItem CreateVector4Vector4Vector2(GLItemsList items, PrimitiveType prim, GLRenderState pt, Vector4[] vectors, GLBuffer secondvector, int secondoffset, Vector2[] thirdvector, IGLRenderItemData id = null, int ic = 1, int seconddivisor = 0, int thirddivisor = 0) { var vb = items.NewBuffer(); vb.AllocateBytes(GLBuffer.Vec4size * vectors.Length + GLBuffer.Vec2size * thirdvector.Length); // vec2 aligned vec4 vb.Fill(vectors); vb.Fill(thirdvector); var va = items.NewArray(); vb.Bind(va, 0, vb.Positions[0], 16); va.Attribute(0, 0, 4, VertexAttribType.Float); secondvector.Bind(va, 1, secondoffset, 16, seconddivisor); va.Attribute(1, 1, 4, VertexAttribType.Float); vb.Bind(va, 2, vb.Positions[1], 8, thirddivisor); va.Attribute(2, 2, 2, VertexAttribType.Float); return(new GLRenderableItem(prim, pt, vectors.Length, va, id, ic)); }