Example #1
0
        /// <summary>
        /// Creates a defaut buffer containing position, color and texture data
        /// </summary>
        /// <returns>Batch buffer</returns>
        public static BatchBuffer CreatePositionColorBuffer()
        {
            BatchBuffer buffer = new BatchBuffer();

            buffer.AddDeclaration("in_position", 3);
            buffer.AddDeclaration("in_color", 4);

            return(buffer);
        }
Example #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        public Mesh()
        {
            Index  = new IndexBuffer();
            Buffer = new BatchBuffer();

            Position      = new Vector3();
            Rotation      = new Vector3();
            PrimitiveType = PrimitiveType.Triangles;

            Scale = new Vector3(1.0f, 1.0f, 1.0f);
        }
Example #3
0
        /// <summary>
        /// Draws a user batch
        /// </summary>
        /// <param name="batch">Batch to draw</param>
        /// <param name="mode">Drawing mode</param>
        /// <param name="first">Specifies the starting index in the enabled arrays.</param>
        /// <param name="count">Specifies the number of indices to be rendered.</param>
        public static void DrawBatch(BatchBuffer batch, PrimitiveType mode, int first, int count)
        {
            // No batch, or empty batch
            if (batch == null)
            {
                return;
            }

            // Bind buffer
            batch.Bind();

            TK.GL.DrawArrays((TK.BeginMode)mode, first, count);

            Statistics.BatchCall++;

            return;
        }
Example #4
0
        /// <summary>
        /// Binds and draws an IndexBuffer
        /// </summary>
        /// <param name="buffer">Buffer handle</param>
        /// <param name="mode">Drawing mode</param>
        /// <param name="index">Index buffer</param>
        public static void DrawIndexBuffer(BatchBuffer buffer, PrimitiveType mode, IndexBuffer index)
        {
            if (buffer == null || index == null)
            {
                return;
            }

            // Set the index buffer
            index.Bind();

            // Bind shader
            buffer.Bind();

            // Draw
            TK.GL.DrawElements((TK.BeginMode)mode, index.Count, TK.DrawElementsType.UnsignedInt, IntPtr.Zero);

            Statistics.BatchCall++;
        }
Example #5
0
 /// <summary>
 /// Draws a batch
 /// </summary>
 /// <param name="batch">Batch to draw</param>
 /// <param name="first">Specifies the starting index in the enabled arrays.</param>
 /// <param name="count">Specifies the number of indices to be rendered.</param>
 public static void DrawBatch(BatchBuffer batch, int first, int count)
 {
     DrawBatch(batch, PrimitiveType.Triangles, first, count);
 }