Holidays 12.10. -> 25.10.2020
~ Moved code around in files. SM.Base: + PostProcessing-system + OnInitialization() for Scenes. + Shader-Extensions + Added option to not react while unfocused to the window. + Added Screenshots to the window. + Connected the log system to the SM.OGL-action system. ~ Replaced IShader with abstract MaterialShader. ~ When a log compression folder doesn't exist, it will create one. SM.OGL: + Added support for UniformArrays + Added ShaderPreProcessing + Added Shader Extensions. + Added Debug actions. + SM.OGL settings ~ Framebuffer Size is automaticly changed, when the window and scale is set. SM2D: + Added easy shader drawing.
This commit is contained in:
parent
2c00dbd31a
commit
03b3942732
102 changed files with 2683 additions and 1398 deletions
|
|
@ -1,15 +1,16 @@
|
|||
using System.Collections.Generic;
|
||||
#region usings
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using SM.Base;
|
||||
using SM.Base.Contexts;
|
||||
using SM.Base.Objects.Static;
|
||||
using SM.Base.Scene;
|
||||
using SM.Base.Textures;
|
||||
using SM.OGL.Texture;
|
||||
using SM2D.Shader;
|
||||
using SM2D.Types;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace SM2D.Drawing
|
||||
{
|
||||
|
|
@ -17,6 +18,22 @@ namespace SM2D.Drawing
|
|||
{
|
||||
private Material _material = new Material();
|
||||
|
||||
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 Color4 Color
|
||||
{
|
||||
get => _material.Tint;
|
||||
|
|
@ -28,28 +45,14 @@ namespace SM2D.Drawing
|
|||
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 object Parent { get; set; }
|
||||
public string Name { get; set; } = "Background";
|
||||
public ICollection<string> Flags { get; set; } = new string[0];
|
||||
|
||||
public void Update(UpdateContext context)
|
||||
{ }
|
||||
{
|
||||
}
|
||||
|
||||
public void Draw(DrawContext context)
|
||||
{
|
||||
|
|
|
|||
19
SMCode/SM2D/Drawing/DrawBackgroundShader.cs
Normal file
19
SMCode/SM2D/Drawing/DrawBackgroundShader.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
using SM.Base.Contexts;
|
||||
using SM.Base.Scene;
|
||||
using SM2D.Scene;
|
||||
|
||||
namespace SM2D.Drawing
|
||||
{
|
||||
public class DrawBackgroundShader : DrawShader, IBackgroundItem
|
||||
{
|
||||
public DrawBackgroundShader(MaterialShader shader) : base(shader)
|
||||
{ }
|
||||
|
||||
protected override void DrawContext(ref DrawContext context)
|
||||
{
|
||||
Transform.Size.Set(context.WorldScale);
|
||||
|
||||
base.DrawContext(ref context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +1,26 @@
|
|||
using OpenTK.Graphics;
|
||||
using SM.Base;
|
||||
#region usings
|
||||
|
||||
using OpenTK.Graphics;
|
||||
using SM.Base.Contexts;
|
||||
using SM.Base.Scene;
|
||||
using SM2D.Scene;
|
||||
using SM2D.Types;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace SM2D.Drawing
|
||||
{
|
||||
public class DrawColor : DrawingBasis<Transformation>, I2DShowItem
|
||||
{
|
||||
public DrawColor()
|
||||
{
|
||||
}
|
||||
|
||||
public DrawColor(Color4 color)
|
||||
{
|
||||
_material.Tint = color;
|
||||
}
|
||||
|
||||
public Color4 Color
|
||||
{
|
||||
get => _material.Tint;
|
||||
|
|
@ -17,13 +29,6 @@ namespace SM2D.Drawing
|
|||
|
||||
public int ZIndex { get; set; }
|
||||
|
||||
public DrawColor() {}
|
||||
|
||||
public DrawColor(Color4 color)
|
||||
{
|
||||
_material.Tint = color;
|
||||
}
|
||||
|
||||
protected override void DrawContext(ref DrawContext context)
|
||||
{
|
||||
context.Instances[0].ModelMatrix = Transform.GetMatrix();
|
||||
|
|
|
|||
|
|
@ -1,15 +1,17 @@
|
|||
using SM.Base.Contexts;
|
||||
#region usings
|
||||
|
||||
using SM.Base.Contexts;
|
||||
using SM.Base.Scene;
|
||||
using SM.OGL.Mesh;
|
||||
using SM2D.Scene;
|
||||
using SM2D.Types;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace SM2D.Drawing
|
||||
{
|
||||
public class DrawComplex: DrawingBasis<Transformation>, I2DShowItem
|
||||
public class DrawComplex : DrawingBasis<Transformation>, I2DShowItem
|
||||
{
|
||||
public int ZIndex { get; set; }
|
||||
|
||||
public Material Material
|
||||
{
|
||||
get => _material;
|
||||
|
|
@ -22,6 +24,8 @@ namespace SM2D.Drawing
|
|||
set => _mesh = value;
|
||||
}
|
||||
|
||||
public int ZIndex { get; set; }
|
||||
|
||||
protected override void DrawContext(ref DrawContext context)
|
||||
{
|
||||
context.Instances[0].ModelMatrix = Transform.GetMatrix();
|
||||
|
|
|
|||
|
|
@ -1,38 +1,46 @@
|
|||
using System.Drawing;
|
||||
#region usings
|
||||
|
||||
using System.Drawing;
|
||||
using OpenTK.Graphics;
|
||||
using SM.Base.Textures;
|
||||
using SM.OGL.Texture;
|
||||
using SM2D.Object;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace SM2D.Drawing
|
||||
{
|
||||
public class DrawPolygon : DrawColor
|
||||
{
|
||||
public Polygon Polygon
|
||||
public DrawPolygon(Polygon polygon) : this(polygon, Color4.White)
|
||||
{
|
||||
get => (Polygon)_mesh;
|
||||
set => _mesh = value;
|
||||
}
|
||||
|
||||
public Texture Texture
|
||||
public DrawPolygon(Polygon polygon, Bitmap map) : this(polygon, map, Color4.White)
|
||||
{
|
||||
get => (Texture)_material.Texture;
|
||||
set => _material.Texture = value;
|
||||
}
|
||||
|
||||
public DrawPolygon(Polygon polygon) {}
|
||||
|
||||
public DrawPolygon(Polygon polygon, Bitmap map) : this(polygon, map, Color4.White) {}
|
||||
|
||||
public DrawPolygon(Polygon polygon, Color4 color) : base(color)
|
||||
{
|
||||
_mesh = polygon;
|
||||
}
|
||||
|
||||
public DrawPolygon(Polygon polygon, Bitmap map, Color4 tint) : base(tint)
|
||||
{
|
||||
_mesh = polygon;
|
||||
|
||||
_material.Texture = new Texture(map);
|
||||
}
|
||||
|
||||
public Polygon Polygon
|
||||
{
|
||||
get => (Polygon) _mesh;
|
||||
set => _mesh = value;
|
||||
}
|
||||
|
||||
public Texture Texture
|
||||
{
|
||||
get => (Texture) _material.Texture;
|
||||
set => _material.Texture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
24
SMCode/SM2D/Drawing/DrawShader.cs
Normal file
24
SMCode/SM2D/Drawing/DrawShader.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
using SM.Base.Contexts;
|
||||
using SM.Base.Scene;
|
||||
using SM2D.Scene;
|
||||
using SM2D.Types;
|
||||
|
||||
namespace SM2D.Drawing
|
||||
{
|
||||
public class DrawShader : DrawingBasis<Transformation>, I2DShowItem
|
||||
{
|
||||
public int ZIndex { get; set; }
|
||||
|
||||
public DrawShader(MaterialShader shader)
|
||||
{
|
||||
_material.CustomShader = shader;
|
||||
}
|
||||
|
||||
protected override void DrawContext(ref DrawContext context)
|
||||
{
|
||||
context.Instances[0].ModelMatrix = Transform.GetMatrix();
|
||||
|
||||
_material.CustomShader.Draw(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +1,13 @@
|
|||
using SM.Base;
|
||||
#region usings
|
||||
|
||||
using SM.Base.Contexts;
|
||||
using SM.Base.Text;
|
||||
using SM.Base.Types;
|
||||
using SM2D.Scene;
|
||||
using SM2D.Types;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace SM2D.Drawing
|
||||
{
|
||||
public class DrawText : TextDrawingBasis<Transformation>, I2DShowItem
|
||||
|
|
@ -15,6 +18,8 @@ namespace SM2D.Drawing
|
|||
Transform.Size = new CVector2(1);
|
||||
}
|
||||
|
||||
public int ZIndex { get; set; }
|
||||
|
||||
protected override void DrawContext(ref DrawContext context)
|
||||
{
|
||||
base.DrawContext(ref context);
|
||||
|
|
@ -24,7 +29,5 @@ namespace SM2D.Drawing
|
|||
|
||||
context.Shader.Draw(context);
|
||||
}
|
||||
|
||||
public int ZIndex { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +1,37 @@
|
|||
using System.Drawing;
|
||||
using OpenTK;
|
||||
#region usings
|
||||
|
||||
using System.Drawing;
|
||||
using OpenTK.Graphics;
|
||||
using SM.Base.Contexts;
|
||||
using SM.Base.Scene;
|
||||
using SM.Base.Textures;
|
||||
using SM.Base.Types;
|
||||
using SM2D.Scene;
|
||||
using SM2D.Types;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace SM2D.Drawing
|
||||
{
|
||||
public class DrawTexture : DrawColor
|
||||
{
|
||||
public static float MasterScale = .25f;
|
||||
public bool ManualSize = false;
|
||||
|
||||
public float Scale = 1;
|
||||
public bool ManualSize = false;
|
||||
public Texture Texture
|
||||
|
||||
public DrawTexture()
|
||||
{
|
||||
get => (Texture) _material.Texture;
|
||||
set => _material.Texture = value;
|
||||
}
|
||||
|
||||
public DrawTexture() {}
|
||||
|
||||
protected DrawTexture(Color4 color) : base(color) { }
|
||||
protected DrawTexture(Color4 color) : base(color)
|
||||
{
|
||||
}
|
||||
|
||||
public DrawTexture(Bitmap map) : this(map, Color4.White)
|
||||
{ }
|
||||
{
|
||||
}
|
||||
|
||||
public DrawTexture(Bitmap map, Color4 color) : this((Texture)map, color)
|
||||
{ }
|
||||
public DrawTexture(Bitmap map, Color4 color) : this((Texture) map, color)
|
||||
{
|
||||
}
|
||||
|
||||
public DrawTexture(Texture texture, Color4 color)
|
||||
{
|
||||
|
|
@ -38,9 +39,17 @@ namespace SM2D.Drawing
|
|||
_material.Tint = color;
|
||||
}
|
||||
|
||||
public Texture Texture
|
||||
{
|
||||
get => (Texture) _material.Texture;
|
||||
set => _material.Texture = value;
|
||||
}
|
||||
|
||||
protected override void DrawContext(ref DrawContext context)
|
||||
{
|
||||
if (!ManualSize) Transform.Size = new CVector2(Texture.Map.Width * MasterScale * Scale, Texture.Map.Height * MasterScale * Scale);
|
||||
if (!ManualSize)
|
||||
Transform.Size = new CVector2(Texture.Map.Width * MasterScale * Scale,
|
||||
Texture.Map.Height * MasterScale * Scale);
|
||||
base.DrawContext(ref context);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue