#region CPL License
/*
Nuclex Framework
Copyright (C) 2002-2009 Nuclex Development Labs
This library is free software; you can redistribute it and/or
modify it under the terms of the IBM Common Public License as
published by the IBM Corporation; either version 1.0 of the
License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
IBM Common Public License for more details.
You should have received a copy of the IBM Common Public
License along with this library
*/
#endregion
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework.Graphics;
using Nuclex.Support.Collections;
namespace Nuclex.Graphics.Batching {
///
/// Queues vertices until the end of the drawing cycle and sorts them
/// by their drawing context.
///
internal class DrawContextQueuer : Queuer
where VertexType : struct, IVertexType {
/// Initializes a new draw context primitive queuer
///
/// Batch drawer that will be used to render completed vertex batches
///
public DrawContextQueuer(IBatchDrawer batchDrawer) :
base(batchDrawer) {
this.contexts = new Dictionary>();
}
/// Informs the queuer that a new drawing cycle is about to start
public override void Begin() { }
/// Informs the queuer that the current drawing cycle has ended
public override void End() { }
/// Queues a series of indexed primitives
/// Primitive vertices
///
/// Index in the vertex array of the first vertex. This vertex will become
/// the new index 0 for the index buffer.
///
/// Number of vertices to draw
/// Indices of the vertices to draw
/// Index of the vertex index to begin drawing with
/// Number of vertex indices to draw
/// Type of primitives to draw
/// Desired graphics device settings for the primitives
public override void Queue(
VertexType[] vertices, int startVertex, int vertexCount,
short[] indices, int startIndex, int indexCount,
PrimitiveType type, DrawContext context
) {
Deque vertexDeque;
if(!this.contexts.TryGetValue(context, out vertexDeque)) {
vertexDeque = new Deque();
this.contexts.Add(context, vertexDeque);
}
// TODO: Implement multi-context deferred queueing
}
/// Queues a series of primitives
/// Primitive vertices
/// Index of vertex to begin drawing with
/// Number of vertices to draw
/// Type of primitives to draw
/// Desired graphics device settings for the primitives
public override void Queue(
VertexType[] vertices, int startVertex, int vertexCount,
PrimitiveType type, DrawContext context
) { }
/// Encountered drawing contexts and their associated vertices
private Dictionary> contexts;
}
} // namespace Nuclex.Graphics.Batching