smrendererv3/SMCode/SM2D/Drawing/DrawTexture.cs
Michel Fedde c4a0847567 20.09.2020
+ Instance Drawing
+ Text and Font

~ Made "DrawBackground" forced Background for 2D

- DrawEmpty
2020-09-20 18:29:09 +02:00

52 lines
No EOL
1.3 KiB
C#

using System.Drawing;
using OpenTK;
using OpenTK.Graphics;
using SM.Base.Contexts;
using SM.Base.Scene;
using SM.Base.Textures;
using SM.Base.Types;
using SM2D.Types;
using Vector2 = SM.Base.Types.Vector2;
namespace SM2D.Drawing
{
public class DrawTexture : DrawingBasis<Transformation>
{
public static float MasterScale = .25f;
public Texture Texture
{
get => (Texture) _material.Texture;
set => _material.Texture = value;
}
public Color4 Tint
{
get => _material.Tint;
set => _material.Tint = value;
}
public float Scale = 1;
public DrawTexture(Bitmap map) : this(map, Color4.White)
{ }
public DrawTexture(Bitmap map, Color4 tint)
{
_material.Texture = new Texture(map);
_material.Tint = tint;
}
public override void Draw(DrawContext context)
{
base.Draw(context);
ApplyContext(ref context);
Transform.Size = new Vector2(Texture.Map.Width * MasterScale * Scale, Texture.Map.Height * MasterScale * Scale);
context.Instances[0].ModelMatrix = Transform.GetMatrix();
_material.Shader.Draw(context);
}
}
}