Пример #1
0
 /// <summary> Vector4 and Vector2 and Vector4 in a tuple. See Vector4Vector2Vector4</summary>
 public static GLRenderableItem CreateVector4Vector2Vector4(GLItemsList items, PrimitiveType prim, GLRenderState pt,
                                                            Tuple <Vector4[], Vector2[]> pos,
                                                            Vector4[] instanceposition,
                                                            IGLRenderItemData id = null, int ic               = 1,
                                                            bool separbuf        = false, int divisorinstance = 1)
 {
     return(CreateVector4Vector2Vector4(items, prim, pt, pos.Item1, pos.Item2, instanceposition, id, ic, separbuf, divisorinstance));
 }
Пример #2
0
        ///<summary> Matrix4 as a buffer reference.
        /// Attributes in 4-7 set up.</summary>
        public static GLRenderableItem CreateMatrix4(GLItemsList items, PrimitiveType prim, GLRenderState pt, GLBuffer vb, int bufoffset, int drawcount,
                                                     IGLRenderItemData id = null, int ic = 1, int matrixdivisor = 1)
        {
            var va = items.NewArray();

            vb.Bind(va, 2, bufoffset, 64, matrixdivisor);     // use a binding
            va.MatrixAttribute(2, 4);                         // bp 2 at attribs 4-7
            return(new GLRenderableItem(prim, pt, drawcount, va, id, ic));
        }
Пример #3
0
        /// <summary> Use a buffer for Vector4 elements in attribute 0</summary>
        public static GLRenderableItem CreateVector4(GLItemsList items, PrimitiveType prim, GLRenderState pt, GLBuffer vb, int drawcount, int pos = 0,
                                                     IGLRenderItemData id = null, int ic = 1)
        {
            var va = items.NewArray();

            vb.Bind(va, 0, pos, 16);
            va.Attribute(0, 0, 4, VertexAttribType.Float);
            return(new GLRenderableItem(prim, pt, drawcount, va, id, ic));
        }
Пример #4
0
        /// <summary> Vector4 and Vector2 and index array in a tuple. Element index is created. In attributes 0,1. No primitive restart</summary>
        public static GLRenderableItem CreateVector4Vector2Indexed(GLItemsList items, PrimitiveType prim, GLRenderState pt, Tuple <Vector4[], Vector2[], uint[]> vectors,
                                                                   IGLRenderItemData id = null, int ic = 1, int seconddivisor = 0)
        {
            var dt = GL4Statics.DrawElementsTypeFromMaxEID((uint)vectors.Item1.Length - 1);
            var ri = CreateVector4Vector2(items, prim, pt, vectors.Item1, vectors.Item2, id, ic, seconddivisor);

            ri.CreateElementIndex(items.NewBuffer(), vectors.Item3, dt);
            return(ri);
        }
Пример #5
0
        /// <summary> Vector4 and Vector2 in one buffer, with buffer given and positions given. Second vector can be instance divided.  In attributes 0,1</summary>
        public static GLRenderableItem CreateVector4Vector2(GLItemsList items, PrimitiveType prim, GLRenderState pt, GLBuffer vb, int pos1, int pos2, int drawcount,
                                                            IGLRenderItemData id = null, int ic = 1, int seconddivisor = 0)
        {
            var va = items.NewArray();

            vb.Bind(va, 0, vb.Positions[0], 16);
            va.Attribute(0, 0, 4, VertexAttribType.Float);
            vb.Bind(va, 1, vb.Positions[1], 8, seconddivisor);
            va.Attribute(1, 1, 2, VertexAttribType.Float);
            return(new GLRenderableItem(prim, pt, drawcount, va, id, ic));
        }
Пример #6
0
        /// <summary> Two Vector4s, both in buffers. Second vector can be instance divided.  In attributes 0,1</summary>
        public static GLRenderableItem CreateVector4Vector4(GLItemsList items, PrimitiveType prim, GLRenderState pt, GLBuffer buf1, int buf1off, int drawcount, GLBuffer buf2, int buf2off = 0,
                                                            IGLRenderItemData id = null, int ic = 1, int seconddivisor = 0)
        {
            var va = items.NewArray();

            buf1.Bind(va, 0, buf1off, 16);                 // binding index 0
            va.Attribute(0, 0, 4, VertexAttribType.Float); // attribute 0

            buf2.Bind(va, 1, buf2off, 16, seconddivisor);  // binding index 1
            va.Attribute(1, 1, 4, VertexAttribType.Float); // attribute 1
            return(new GLRenderableItem(prim, pt, drawcount, va, id, ic));
        }
Пример #7
0
        /// <summary>Vector4, in attribute 0</summary>
        public static GLRenderableItem CreateVector4(GLItemsList items, PrimitiveType prim, GLRenderState pt, Vector4[] vectors,
                                                     IGLRenderItemData id = null, int ic = 1)
        {
            var vb = items.NewBuffer();

            vb.AllocateFill(vectors);

            var va = items.NewArray();

            vb.Bind(va, 0, vb.Positions[0], 16);           // bind buffer to binding point 0
            va.Attribute(0, 0, 4, VertexAttribType.Float); // bind binding point 0 to attribute point 0 with 4 float components
            return(new GLRenderableItem(prim, pt, vectors.Length, va, id, ic));
        }
Пример #8
0
        ///<summary> Vector4 and Matrix4. Both are buffer references.
        /// Attributes in 0,4-7 set up.</summary>
        public static GLRenderableItem CreateVector4Matrix4(GLItemsList items, PrimitiveType prim, GLRenderState pt, GLBuffer shape, GLBuffer matrix, int drawcount,
                                                            IGLRenderItemData id = null, int ic = 1, int matrixdivisor = 1)
        {
            var va = items.NewArray();

            shape.Bind(va, 0, shape.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, drawcount, va, id, ic));
        }
Пример #9
0
        ///<summary> Floats packed into buffer with configurable component number (1,2,4)
        /// Attributes in 0.</summary>
        public static GLRenderableItem CreateFloats(GLItemsList items, PrimitiveType prim, GLRenderState pt, float[] floats, int components,
                                                    IGLRenderItemData id = null, int ic = 1)
        {
            var vb = items.NewBuffer();

            vb.AllocateFill(floats);
            //float[] ouwt = vb.ReadFloats(0, floats.Length); // test read back

            var va = items.NewArray();

            vb.Bind(va, 0, vb.Positions[0], sizeof(float) * components);
            va.Attribute(0, 0, components, VertexAttribType.Float);

            return(new GLRenderableItem(prim, pt, floats.Length / components, va, id, ic));
        }
Пример #10
0
        ///<summary> Vector3 packed using GLBuffer.FillPacked2vec. Offsets and mult specify range
        /// Attributes in 0.</summary>
        public static GLRenderableItem CreateVector3Packed2(GLItemsList items, PrimitiveType prim, GLRenderState pt, Vector3[] vectors, Vector3 offsets, float mult,
                                                            IGLRenderItemData id = null, int ic = 1)
        {
            var vb = items.NewBuffer();

            vb.AllocateBytes(sizeof(uint) * 2 * vectors.Length);
            vb.FillPacked2vec(vectors, offsets, mult);

            var va = items.NewArray();

            vb.Bind(va, 0, vb.Positions[0], 8);
            va.AttributeI(0, 0, 2, VertexAttribType.UnsignedInt);

            return(new GLRenderableItem(prim, pt, vectors.Length, va, id, ic));
        }
Пример #11
0
        ///<summary> Matrix4.
        /// Attributes in 4-7 set up.</summary>
        public static GLRenderableItem CreateMatrix4(GLItemsList items, PrimitiveType prim, GLRenderState pt, Matrix4[] matrix, int drawcount,
                                                     IGLRenderItemData id = null, int ic = 1, int matrixdivisor = 1)
        {
            var vb = items.NewBuffer();

            vb.AllocateBytes(GLBuffer.Mat4size * matrix.Length);
            vb.Fill(matrix);

            var va = items.NewArray();

            vb.Bind(va, 2, vb.Positions[0], 64, matrixdivisor); // use a binding
            va.MatrixAttribute(2, 4);                           // bp 2 at attribs 4-7

            return(new GLRenderableItem(prim, pt, drawcount, va, id, ic));
        }
Пример #12
0
        /// <summary> Vector4 and Vector2. Second vector can be instance divided.  In attributes 0,1</summary>
        public static GLRenderableItem CreateVector4Vector2(GLItemsList items, PrimitiveType prim, GLRenderState pt, Vector4[] vectors, Vector2[] coords,
                                                            IGLRenderItemData id = null, int ic = 1, int seconddivisor = 0)
        {
            var vb = items.NewBuffer();

            vb.AllocateBytes(GLBuffer.Vec4size * vectors.Length + GLBuffer.Vec2size * coords.Length);
            vb.Fill(vectors);
            vb.Fill(coords);

            var va = items.NewArray();

            vb.Bind(va, 0, vb.Positions[0], 16);
            va.Attribute(0, 0, 4, VertexAttribType.Float);
            vb.Bind(va, 1, vb.Positions[1], 8, seconddivisor);
            va.Attribute(1, 1, 2, VertexAttribType.Float);
            return(new GLRenderableItem(prim, pt, vectors.Length, va, id, ic));
        }
Пример #13
0
        ///<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));
        }
Пример #14
0
        ///<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));
        }
Пример #15
0
        /// <summary>Vector4, Color4, optional instance data and count
        /// in attribute 0 and 1 setup vector4 and vector4 colours</summary>
        public static GLRenderableItem CreateVector4Color4(GLItemsList items, PrimitiveType prim, GLRenderState pt, Vector4[] vectors, Color4[] colours, IGLRenderItemData id = null, int ic = 1)
        {
            var vb = items.NewBuffer();                                     // they all follow this pattern, grab a buffer (unless supplied)

            vb.AllocateBytes(GLBuffer.Vec4size * vectors.Length * 2);       // allocate
            vb.Fill(vectors);                                               // fill
            vb.Fill(colours, vectors.Length);

            var va = items.NewArray();                                          // vertex array

            vb.Bind(va, 0, vb.Positions[0], 16);                                // buffer bind to vertex array at bindingpoint 0, bufferpos, stride
            va.Attribute(0, 0, 4, VertexAttribType.Float);                      // bind bindingpoint 0 to attribute index 0 (in shader), 4 components, float

            vb.Bind(va, 1, vb.Positions[1], 16);                                // buffer bind to vertex array at bindingpoint 1, bufferpos, stride
            va.Attribute(1, 1, 4, VertexAttribType.Float);                      // bind bindingpoint 1 to attribute index 1 (in shader), 4 components, float

            return(new GLRenderableItem(prim, pt, vectors.Length, va, id, ic)); // create new RI
        }
Пример #16
0
        ///<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));
        }
Пример #17
0
        /// <summary> Two Vector4s, in separate buffers. Second vector can be instance divided.  In attributes 0,1</summary>
        public static GLRenderableItem CreateVector4Vector4Buf2(GLItemsList items, PrimitiveType prim, GLRenderState pt, Vector4[] vectors, Vector4[] secondvector,
                                                                IGLRenderItemData id = null, int ic = 1, int seconddivisor = 0)
        {
            var v1 = items.NewBuffer();

            v1.AllocateBytes(GLBuffer.Vec4size * vectors.Length);
            v1.Fill(vectors);

            var v2 = items.NewBuffer();

            v2.AllocateBytes(GLBuffer.Vec4size * secondvector.Length);
            v2.Fill(secondvector);

            var va = items.NewArray();

            v1.Bind(va, 0, v1.Positions[0], 16);
            va.Attribute(0, 0, 4, VertexAttribType.Float);

            v2.Bind(va, 1, v2.Positions[0], 16, seconddivisor);
            va.Attribute(1, 1, 4, VertexAttribType.Float);
            return(new GLRenderableItem(prim, pt, vectors.Length, va, id, ic));
        }
Пример #18
0
 /// <summary> Vector4 and Vector2 in a tuple, into one buffer.  In attributes 0,1</summary>
 public static GLRenderableItem CreateVector4Vector2(GLItemsList items, PrimitiveType prim, GLRenderState pt, Tuple <Vector4[], Vector2[]> vectors,
                                                     IGLRenderItemData id = null, int ic = 1, int seconddivisor = 0)
 {
     return(CreateVector4Vector2(items, prim, pt, vectors.Item1, vectors.Item2, id, ic, seconddivisor));
 }