20.09.2020

+ Instance Drawing
+ Text and Font

~ Made "DrawBackground" forced Background for 2D

- DrawEmpty
This commit is contained in:
Michel Fedde 2020-09-20 18:29:09 +02:00
parent acccf5f0e7
commit c4a0847567
29 changed files with 365 additions and 85 deletions

View file

@ -3,14 +3,17 @@ using OpenTK;
using OpenTK.Graphics;
using SM.Base.Contexts;
using SM.Base.Scene;
using SM.Base.StaticObjects;
using SM.Base.Textures;
using SM.OGL.Texture;
using SM2D.Types;
namespace SM2D.Drawing
{
public class DrawBackground : DrawingBasis
public class DrawBackground : IBackgroundItem
{
private Material _material = new Material();
public Color4 Color
{
get => _material.Tint;
@ -38,11 +41,17 @@ namespace SM2D.Drawing
Texture = (Texture) texture;
}
public override void Draw(DrawContext context)
public void Update(UpdateContext context)
{
ApplyContext(ref context);
throw new System.NotImplementedException();
}
context.ModelMatrix = Matrix4.CreateScale(context.WorldScale.X, context.WorldScale.Y, 1);
public void Draw(DrawContext context)
{
context.Material = _material;
context.Mesh = Plate.Object;
context.Instances[0].ModelMatrix = Matrix4.CreateScale(context.WorldScale.X, context.WorldScale.Y, 1);
_material.Shader.Draw(context);
}
}

View file

@ -1,24 +0,0 @@
using OpenTK;
using SM.Base.Contexts;
using SM.Base.Scene;
using SM.Base.Shader;
using SM.Base.StaticObjects;
using SM.OGL.Mesh;
namespace SM2D.Drawing
{
public class DrawEmpty : IShowItem
{
public void Update(UpdateContext context)
{
throw new System.NotImplementedException();
}
public void Draw(DrawContext context)
{
context.ModelMatrix = Matrix4.CreateScale(100, 100, 1);
Shaders.Default.Draw(context);
}
}
}

View file

@ -0,0 +1,25 @@
using SM.Base.Contexts;
using SM.Base.Text;
using SM2D.Types;
namespace SM2D.Drawing
{
public class DrawText : TextDrawingBasis<Transformation>
{
public DrawText(Font font, string text) : base(font)
{
_text = text;
}
public override void Draw(DrawContext context)
{
base.Draw(context);
context.Instances = _modelMatrixs;
ApplyContext(ref context);
context.View = Transform.GetMatrix() * context.View;
_material.Shader.Draw(context);
}
}
}

View file

@ -44,7 +44,7 @@ namespace SM2D.Drawing
ApplyContext(ref context);
Transform.Size = new Vector2(Texture.Map.Width * MasterScale * Scale, Texture.Map.Height * MasterScale * Scale);
context.ModelMatrix = Transform.GetMatrix();
context.Instances[0].ModelMatrix = Transform.GetMatrix();
_material.Shader.Draw(context);
}

View file

@ -46,7 +46,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Drawing\DrawBackground.cs" />
<Compile Include="Drawing\DrawEmpty.cs" />
<Compile Include="Drawing\DrawText.cs" />
<Compile Include="Drawing\DrawTexture.cs" />
<Compile Include="GLWindow2D.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />

View file

@ -1,9 +1,16 @@
using SM.Base.Scene;
using OpenTK.Graphics;
using SM.Base.Scene;
using SM2D.Drawing;
namespace SM2D.Scene
{
public class Scene : GenericScene<Camera>
{
public DrawBackground Background => (DrawBackground)_background;
public Scene()
{
_background = new DrawBackground(Color4.Black);
}
}
}