#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;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
namespace Nuclex.Graphics.SpecialEffects.Masks {
/// Mask that draws over the entire screen
/// Type of vertices used in the mask
///
/// A 'screen mask' draws over the entire screen with a polygon. This can be used
/// to provide damage feedback to the player (screen flashes red or, like in some
/// FPS games, the screen borders become red when the player's health is low) or
/// to generate post-processing effects.
///
public class ScreenMask : StaticMesh
where VertexType : struct, IVertexType {
/// Initializes as new skybox cube
/// Graphics device the skybox cube lives on
/// Effect by which the screen mask will be rendered
/// Vertices that make up the screen mask
public ScreenMask(
GraphicsDevice graphicsDevice, Effect effect, VertexType[/*4*/] vertices
) :
base(graphicsDevice, 4) {
this.Effect = effect;
this.Vertices = vertices;
base.VertexBuffer.SetData(vertices);
}
/// Draws the screen mask
public void Draw() {
Select();
EffectTechnique technique = this.Effect.CurrentTechnique;
for (int pass = 0; pass < technique.Passes.Count; ++pass) {
technique.Passes[pass].Apply();
base.GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
}
}
/// Effect being used to render the screen mask
protected Effect Effect;
/// Vertices used to render the screen mask
protected VertexType[/*4*/] Vertices;
}
} // namespace Nuclex.Graphics.SpecialEffects.Masks