#region usings
using System.Drawing;
using OpenTK;
using OpenTK.Graphics;
using SM.Base.Drawing;
using SM.Base.Objects.Static;
using SM.Base.Scene;
using SM.Base.Textures;
using SM.Base.Window;
using SM.OGL.Texture;
using SM2D.Scene;
#endregion
namespace SM2D.Drawing
{
///
/// Allows easy access to draw something on the background.
///
public class DrawBackground : DrawingBasis, IBackgroundItem
{
///
/// Sets the color or tint (in case a texture is set).
///
public Color4 Color
{
get => Material.Tint;
set => Material.Tint = value;
}
///
/// Sets the texture of the background.
///
public TextureBase Texture
{
get => Material.Texture;
set
{
if (Material.Tint == Color4.Black) Material.Tint = Color4.White;
Material.Texture = value;
}
}
///
/// Creates a black background.
///
public DrawBackground() : this(Color4.Black) {}
///
/// Creates a background with a color.
///
///
public DrawBackground(Color4 color)
{
Color = color;
Mesh = Plate.Object;
}
///
/// Creates a background with a texture.
///
///
public DrawBackground(Bitmap texture)
{
Texture = (Texture) texture;
Mesh = Plate.Object;
}
///
/// Creates a background with a texture and a tint.
///
///
///
public DrawBackground(Bitmap texture, Color4 tint)
{
Color = tint;
Texture = (Texture) texture;
Mesh = Plate.Object;
}
///
protected override void DrawContext(ref DrawContext context)
{
base.DrawContext(ref context);
context.ModelMatrix = Matrix4.CreateScale((context.UseCamera as Camera).WorldScale.X, (context.UseCamera as Camera).WorldScale.Y, 0) * Matrix4.CreateTranslation(0,0, -1.1f);
context.Shader.Draw(context);
}
}
}