19.09.2020
+ Vector-classes + Added Background ~ Changed OpenTK.Vector2 to SM.Base.Types.Vector2
This commit is contained in:
parent
a603ecc417
commit
acccf5f0e7
22 changed files with 295 additions and 27 deletions
49
SMCode/SM2D/Drawing/DrawBackground.cs
Normal file
49
SMCode/SM2D/Drawing/DrawBackground.cs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
using System.Drawing;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using SM.Base.Contexts;
|
||||
using SM.Base.Scene;
|
||||
using SM.Base.Textures;
|
||||
using SM.OGL.Texture;
|
||||
using SM2D.Types;
|
||||
|
||||
namespace SM2D.Drawing
|
||||
{
|
||||
public class DrawBackground : DrawingBasis
|
||||
{
|
||||
public Color4 Color
|
||||
{
|
||||
get => _material.Tint;
|
||||
set => _material.Tint = value;
|
||||
}
|
||||
|
||||
public TextureBase Texture
|
||||
{
|
||||
get => _material.Texture;
|
||||
set => _material.Texture = value;
|
||||
}
|
||||
public DrawBackground(Color4 color)
|
||||
{
|
||||
Color = color;
|
||||
}
|
||||
|
||||
public DrawBackground(Bitmap texture)
|
||||
{
|
||||
Texture = (Texture)texture;
|
||||
}
|
||||
|
||||
public DrawBackground(Bitmap texture, Color4 tint)
|
||||
{
|
||||
Color = tint;
|
||||
Texture = (Texture) texture;
|
||||
}
|
||||
|
||||
public override void Draw(DrawContext context)
|
||||
{
|
||||
ApplyContext(ref context);
|
||||
|
||||
context.ModelMatrix = Matrix4.CreateScale(context.WorldScale.X, context.WorldScale.Y, 1);
|
||||
_material.Shader.Draw(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +1,19 @@
|
|||
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;
|
||||
|
|
@ -21,6 +26,9 @@ namespace SM2D.Drawing
|
|||
set => _material.Tint = value;
|
||||
}
|
||||
|
||||
public float Scale = 1;
|
||||
|
||||
|
||||
public DrawTexture(Bitmap map) : this(map, Color4.White)
|
||||
{ }
|
||||
|
||||
|
|
@ -35,6 +43,7 @@ namespace SM2D.Drawing
|
|||
base.Draw(context);
|
||||
ApplyContext(ref context);
|
||||
|
||||
Transform.Size = new Vector2(Texture.Map.Width * MasterScale * Scale, Texture.Map.Height * MasterScale * Scale);
|
||||
context.ModelMatrix = Transform.GetMatrix();
|
||||
|
||||
_material.Shader.Draw(context);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue