smrendererv3/SMCode/SM2D/Drawing/DrawBackground.cs
Michel Fedde c6bf5c75bc 2021-04-03
+ Added Field to DrawingBasis to enfore PrimitiveTypes
+ LastObject to context for Debugging
+ AppendRenderbuffer to Framebuffer

~ Added a depthbuffer to RenderPipeline.CreateWindowFramebuffer
~ Proper ZIndices over Z-Translation and DepthBuffer
~ Made "ShaderArguments["LineWidth"]" set the LineWidth even if the object isn't maked as LineMesh
~ Made that the SM2D.PolygonVertex can translate OpenTK.Vector2 by itself.
~ Made the SM2D.Transformation.ZIndex a CVector1 instead a float
2021-03-04 22:17:03 +01:00

64 lines
No EOL
1.5 KiB
C#

#region usings
using System.Collections.Generic;
using System.Drawing;
using OpenTK;
using OpenTK.Graphics;
using SM.Base;
using SM.Base.Drawing;
using SM.Base.Objects.Static;
using SM.Base.Scene;
using SM.Base.Textures;
using SM.Base.Windows;
using SM.OGL.Texture;
using SM2D.Scene;
#endregion
namespace SM2D.Drawing
{
public class DrawBackground : DrawingBasis, IBackgroundItem
{
public Color4 Color
{
get => Material.Tint;
set => Material.Tint = value;
}
public TextureBase Texture
{
get => Material.Texture;
set
{
if (Material.Tint == Color4.Black) Material.Tint = Color4.White;
Material.Texture = value;
}
}
public DrawBackground() : this(Color4.Black) {}
public DrawBackground(Color4 color)
{
Color = color;
}
public DrawBackground(Bitmap texture)
{
Texture = (Texture) texture;
}
public DrawBackground(Bitmap texture, Color4 tint)
{
Color = tint;
Texture = (Texture) texture;
}
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);
}
}
}