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:
Michel Fedde 2020-10-24 15:10:36 +02:00
parent 2c00dbd31a
commit 03b3942732
102 changed files with 2683 additions and 1398 deletions

View file

@ -1,19 +1,22 @@
using System;
#region usings
using System.Collections.Generic;
using OpenTK;
using System.Dynamic;
using SM.Base.Contexts;
#endregion
namespace SM.Base.Scene
{
/// <summary>
/// A generic scene, that imports functions for scene control.
/// A generic scene, that imports functions for scene control.
/// </summary>
public abstract class GenericScene
{
private IBackgroundItem _background;
/// <summary>
/// This contains the background.
/// This contains the background.
/// </summary>
protected IBackgroundItem _Background
{
@ -24,41 +27,53 @@ namespace SM.Base.Scene
_background = value;
}
}
public bool IsInitialized { get; private set; }
/// <summary>
/// Updates this scene.
/// Updates this scene.
/// </summary>
/// <param name="context"></param>
public virtual void Update(UpdateContext context)
{
}
/// <summary>
/// Draws this scene.
/// Draws this scene.
/// </summary>
public virtual void Draw(DrawContext context)
{
}
/// <summary>
/// Called, when the user activates the scene.
/// Called, when the user activates the scene.
/// </summary>
internal void Activate()
{
if (!IsInitialized)
{
OnInitialization();
IsInitialized = true;
}
OnActivating();
}
/// <summary>
/// Called, when the user activates the scene.
/// Called, when the user activates the scene for the first time.
/// </summary>
protected virtual void OnInitialization()
{ }
/// <summary>
/// Called, when the user activates the scene.
/// </summary>
protected virtual void OnActivating()
{ }
{
}
}
/// <summary>
/// A generic scene that imports different functions.
/// A generic scene that imports different functions.
/// </summary>
/// <typeparam name="TCamera">The type of cameras.</typeparam>
/// <typeparam name="TItem">The type of show items.</typeparam>
@ -68,25 +83,32 @@ namespace SM.Base.Scene
where TCollection : GenericItemCollection<TItem>, new()
where TItem : IShowItem
{
private TCollection _objectCollection = new TCollection();
private TCollection _hud = new TCollection();
private TCollection _objectCollection = new TCollection();
/// <summary>
/// The active camera, that is used if the context doesn't force the viewport camera.
/// <para>If none set, it automaticly uses the viewport camera.</para>
/// A collection for cameras to switch easier to different cameras.
/// </summary>
public Dictionary<string, TCamera> Cameras = new Dictionary<string, TCamera>();
/// <summary>
/// The active camera, that is used if the context doesn't force the viewport camera.
/// <para>If none set, it automaticly uses the viewport camera.</para>
/// </summary>
public TCamera Camera { get; set; }
/// <summary>
/// A camera to control the background.
/// A camera to control the background.
/// </summary>
public TCamera BackgroundCamera { get; set; } = new TCamera();
/// <summary>
/// A camera to control the HUD.
/// A camera to control the HUD.
/// </summary>
public TCamera HUDCamera { get; set; } = new TCamera();
/// <summary>
/// Objects inside the scene.
/// Objects inside the scene.
/// </summary>
public TCollection Objects
{
@ -99,7 +121,7 @@ namespace SM.Base.Scene
}
/// <summary>
/// This defines the HUD objects.
/// This defines the HUD objects.
/// </summary>
public TCollection HUD
{
@ -110,10 +132,6 @@ namespace SM.Base.Scene
_hud = value;
}
}
/// <summary>
/// A collection for cameras to switch easier to different cameras.
/// </summary>
public Dictionary<string, TCamera> Cameras = new Dictionary<string, TCamera>();
/// <inheritdoc />
@ -127,14 +145,28 @@ namespace SM.Base.Scene
/// <inheritdoc />
public override void Draw(DrawContext context)
{
if (!context.ForceViewport && Camera != null) context.View = Camera.CalculateViewMatrix();
DrawBackground(context);
DrawContext backgroundDrawContext = context;
DrawMainObjects(context);
DrawHUD(context);
}
public void DrawBackground(DrawContext context)
{
var backgroundDrawContext = context;
backgroundDrawContext.View = BackgroundCamera.CalculateViewMatrix();
_Background?.Draw(backgroundDrawContext);
}
public void DrawMainObjects(DrawContext context)
{
if (!context.ForceViewport && Camera != null) context.View = Camera.CalculateViewMatrix();
_objectCollection.Draw(context);
}
public void DrawHUD(DrawContext context)
{
context.View = HUDCamera.CalculateViewMatrix();
_hud.Draw(context);
}