
Untitled
By: a guest on
Jun 14th, 2012 | syntax:
None | size: 1.14 KB | hits: 18 | expires: Never
/// <summary>
/// Helper function sets up the graphics device and
/// effect ready for drawing instanced geometry.
/// </summary>
void SetRenderStates(InstancingTechnique instancingTechnique,
Matrix view, Matrix projection)
{
// Set the graphics device to use our vertex data.
graphicsDevice.VertexDeclaration = vertexDeclaration;
graphicsDevice.Vertices[0].SetSource(vertexBuffer, 0, vertexStride);
graphicsDevice.Indices = indexBuffer;
// Make sure our effect is set to use the right technique.
if (techniqueChanged)
{
string techniqueName = instancingTechnique.ToString();
effect.CurrentTechnique = effect.Techniques[techniqueName];
techniqueChanged = false;
}
// Pass camera matrices through to the effect.
effect.Parameters["View"].SetValue(view);
effect.Parameters["Projection"].SetValue(projection);
//effect.Parameters["TargetColor"].SetValue(Color.Green.ToVector3());