Esempio n. 1
0
        /// <summary>Draws a batch of indexed primitives</summary>
        /// <param name="startVertex">
        ///   Index of the first vertex in the vertex array. This vertex will become
        ///   the new index 0 for the index buffer.
        /// </param>
        /// <param name="vertexCount">Number of vertices used in the call</param>
        /// <param name="startIndex">
        ///   Position at which to begin processing the index array
        /// </param>
        /// <param name="indexCount">Number of indices that will be processed</param>
        /// <param name="type">Type of primitives to draw</param>
        /// <param name="context">Desired graphics device settings for the primitives</param>
        public void Draw(
            int startVertex, int vertexCount,
            int startIndex, int indexCount,
            PrimitiveType type, DrawContext context
            )
        {
#if XNA_4
            startIndex += PrimitiveBatch <VertexType> .BatchSize * this.currentDivisionIndex;

            int primitiveCount = VertexHelper.GetPrimitiveCount(indexCount, type);

            // If the DrawContext requires more than one pass, we have to draw the
            // primitives multiple times
            for (int pass = 0; pass < context.Passes; ++pass)
            {
                // Enter the pass and send all primitives to the graphics card
                context.Apply(pass);

                this.graphicsDevice.DrawIndexedPrimitives(
                    type,          // type of primitives to render
                    startVertex,   // offset that will be added to all vertex indices
                    0,             // lowest vertex used in the call (relative to previous parameter)
                    vertexCount,   // number of vertices used in the call
                    startIndex,    // where in the index array to begin processing
                    primitiveCount // number of primitives
                    );
            } // for
#else
            startIndex += PrimitiveBatch <VertexType> .BatchSize * this.currentDivisionIndex;

            context.Begin();
            try {
                int primitiveCount = VertexHelper.GetPrimitiveCount(indexCount, type);

                // If the DrawContext requires more than one pass, we have to draw the
                // primitives multiple times
                for (int pass = 0; pass < context.Passes; ++pass)
                {
                    // Enter the pass and send all primitives to the graphics card
                    context.BeginPass(pass);
                    try {
                        this.graphicsDevice.DrawIndexedPrimitives(
                            type,          // type of primitives to render
                            startVertex,   // offset that will be added to all vertex indices
                            0,             // lowest vertex used in the call (relative to previous parameter)
                            vertexCount,   // number of vertices used in the call
                            startIndex,    // where in the index array to begin processing
                            primitiveCount // number of primitives
                            );
                    }
                    finally {
                        context.EndPass();
                    }
                } // for
            }
            finally {
                context.End();
            }
#endif
        }
Esempio n. 2
0
        /// <summary>Draws a batch of indexed primitives</summary>
        /// <param name="startVertex">
        ///   Index of the first vertex in the vertex array. This vertex will become
        ///   the new index 0 for the index buffer.
        /// </param>
        /// <param name="vertexCount">Number of vertices used in the call</param>
        /// <param name="startIndex">
        ///   Position at which to begin processing the index array
        /// </param>
        /// <param name="indexCount">Number of indices that will be processed</param>
        /// <param name="type">Type of primitives to draw</param>
        /// <param name="context">Desired graphics device settings for the primitives</param>
        public void Draw(
            int startVertex, int vertexCount,
            int startIndex, int indexCount,
            PrimitiveType type, DrawContext context
            )
        {
#if XNA_4
            int primitiveCount = VertexHelper.GetPrimitiveCount(indexCount, type);

            // If the DrawContext requires more than one pass, we have to draw the
            // primitives multiple times
            for (int pass = 0; pass < context.Passes; ++pass)
            {
                // Enter the effect pass and send all primitives to the graphics card
                context.Apply(pass);

                this.graphicsDevice.DrawUserIndexedPrimitives <VertexType>(
                    type,          // type of primitives to render
                    this.vertices, // vertex array
                    startVertex,   // offset that will be added to all vertex indices
                    vertexCount,   // number of vertices used in the call
                    this.indices,  // index array
                    startIndex,    // where in the index array to begin processing
                    primitiveCount // number of primitives
                    );
            } // for
#else
            context.Begin();
            try {
                int primitiveCount = VertexHelper.GetPrimitiveCount(indexCount, type);

                // If the DrawContext requires more than one pass, we have to draw the
                // primitives multiple times
                for (int pass = 0; pass < context.Passes; ++pass)
                {
                    // Enter the pass and send all primitives to the graphics card
                    context.BeginPass(pass);
                    try {
                        this.graphicsDevice.DrawUserIndexedPrimitives <VertexType>(
                            type,          // type of primitives to render
                            this.vertices, // vertex array
                            startVertex,   // offset that will be added to all vertex indices
                            vertexCount,   // number of vertices used in the call
                            this.indices,  // index array
                            startIndex,    // where in the index array to begin processing
                            primitiveCount // number of primitives
                            );
                    }
                    finally {
                        context.EndPass();
                    }
                } // for
            }
            finally {
                context.End();
            }
#endif
        }
Esempio n. 3
0
        /// <summary>Draws a batch of primitives</summary>
        /// <param name="startVertex">Index of vertex to begin drawing with</param>
        /// <param name="vertexCount">Number of vertices used</param>
        /// <param name="type">Type of primitives that will be drawn</param>
        /// <param name="context">Desired graphics device settings for the primitives</param>
        public void Draw(
            int startVertex, int vertexCount,
            PrimitiveType type, DrawContext context
            )
        {
#if XNA_4
            int primitiveCount = VertexHelper.GetPrimitiveCount(vertexCount, type);

            // If the DrawContext requires more than one pass, we have to draw the
            // primitives multiple times
            for (int pass = 0; pass < context.Passes; ++pass)
            {
                // Enter the pass and send all primitives to the graphics card
                context.Apply(pass);

                this.graphicsDevice.DrawPrimitives(
                    type,          // type of primitives to render
                    startVertex,   // offset that will be added to all vertex indices
                    primitiveCount // number of primitives being drawn
                    );
            } // for
#else
            context.Begin();
            try {
                int primitiveCount = VertexHelper.GetPrimitiveCount(vertexCount, type);

                // If the DrawContext requires more than one pass, we have to draw the
                // primitives multiple times
                for (int pass = 0; pass < context.Passes; ++pass)
                {
                    // Enter the pass and send all primitives to the graphics card
                    context.BeginPass(pass);
                    try {
                        this.graphicsDevice.DrawPrimitives(
                            type,          // type of primitives to render
                            startVertex,   // offset that will be added to all vertex indices
                            primitiveCount // number of primitives being drawn
                            );
                    }
                    finally {
                        context.EndPass();
                    }
                } // for
            }
            finally {
                context.End();
            }
#endif
        }