Added missing summeries #1
This commit is contained in:
parent
03d99ea28e
commit
8665b5b709
104 changed files with 1165 additions and 821 deletions
|
|
@ -1,11 +1,16 @@
|
|||
using System.Collections.Generic;
|
||||
#region usings
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
using SM.Base.Drawing;
|
||||
using SM.Base.Scene;
|
||||
using SM.Base.Shaders;
|
||||
using SM.OGL.Mesh;
|
||||
|
||||
namespace SM.Base.Windows
|
||||
#endregion
|
||||
|
||||
namespace SM.Base.Window
|
||||
{
|
||||
public struct DrawContext
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
using OpenTK.Input;
|
||||
#region usings
|
||||
|
||||
using SM.Base.Scene;
|
||||
|
||||
namespace SM.Base.Windows
|
||||
#endregion
|
||||
|
||||
namespace SM.Base.Window
|
||||
{
|
||||
public struct UpdateContext
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,20 +1,39 @@
|
|||
using System;
|
||||
using System.Windows;
|
||||
#region usings
|
||||
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using OpenTK.Input;
|
||||
using SM.Base.Controls;
|
||||
using SM.Base.Scene;
|
||||
using SM.OGL;
|
||||
using Mouse = SM.Base.Controls.Mouse;
|
||||
|
||||
namespace SM.Base.Windows
|
||||
#endregion
|
||||
|
||||
namespace SM.Base.Window
|
||||
{
|
||||
public class GLWindow : GameWindow, IGenericWindow
|
||||
{
|
||||
private Vector2 _flagWindowSize;
|
||||
|
||||
public WindowFlags WindowFlags;
|
||||
|
||||
public GLWindow() : this(1280, 720, "Generic OpenGL Title", WindowFlags.Window)
|
||||
{
|
||||
}
|
||||
|
||||
public GLWindow(int width, int height, string title, WindowFlags flags, VSyncMode vSync = VSyncMode.On) :
|
||||
base(width, height, default, title, (GameWindowFlags) flags, DisplayDevice.Default,
|
||||
GLSettings.ForcedVersion.MajorVersion, GLSettings.ForcedVersion.MinorVersion,
|
||||
GraphicsContextFlags.Default)
|
||||
{
|
||||
VSync = vSync;
|
||||
_flagWindowSize = new Vector2(width, height);
|
||||
|
||||
ChangeWindowFlag(flags);
|
||||
}
|
||||
|
||||
public bool Loading { get; private set; } = true;
|
||||
public float AspectRatio { get; set; }
|
||||
|
||||
|
|
@ -29,78 +48,12 @@ namespace SM.Base.Windows
|
|||
public ISetup AppliedSetup { get; private set; }
|
||||
public event Action<IGenericWindow> Resize;
|
||||
public event Action<IGenericWindow> Load;
|
||||
public event Action<IGenericWindow> Loaded;
|
||||
|
||||
public GenericScene CurrentScene { get; private set; }
|
||||
public RenderPipeline CurrentRenderPipeline { get; private set; }
|
||||
|
||||
public WindowFlags WindowFlags;
|
||||
|
||||
public GLWindow() : this(1280, 720, "Generic OpenGL Title", WindowFlags.Window) {}
|
||||
|
||||
public GLWindow(int width, int height, string title, WindowFlags flags, VSyncMode vSync = VSyncMode.On) :
|
||||
base(width, height, default, title, (GameWindowFlags)flags, DisplayDevice.Default, GLSettings.ForcedVersion.MajorVersion, GLSettings.ForcedVersion.MinorVersion, GraphicsContextFlags.Default)
|
||||
{
|
||||
VSync = vSync;
|
||||
_flagWindowSize = new Vector2(width, height);
|
||||
|
||||
ChangeWindowFlag(flags);
|
||||
}
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
WindowCode.Load(this);
|
||||
SMRenderer.CurrentWindow = this;
|
||||
|
||||
base.OnLoad(e);
|
||||
}
|
||||
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
|
||||
WindowCode.Resize(this);
|
||||
|
||||
if (WindowFlags == WindowFlags.Window) _flagWindowSize = WindowSize;
|
||||
|
||||
if (Loading)
|
||||
{
|
||||
Loading = false;
|
||||
Loaded?.Invoke(this);
|
||||
AppliedSetup?.Loaded(this);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnUpdateFrame(FrameEventArgs e)
|
||||
{
|
||||
if (!Focused && !UpdateWhileUnfocused) return;
|
||||
|
||||
base.OnUpdateFrame(e);
|
||||
|
||||
WindowCode.Update(this, (float)e.Time);
|
||||
}
|
||||
|
||||
|
||||
protected override void OnRenderFrame(FrameEventArgs e)
|
||||
{
|
||||
base.OnRenderFrame(e);
|
||||
|
||||
WindowCode.Render(this, (float)e.Time);
|
||||
|
||||
SwapBuffers();
|
||||
|
||||
GLDebugging.CheckGLErrors();
|
||||
}
|
||||
|
||||
protected override void OnMouseMove(MouseMoveEventArgs e)
|
||||
{
|
||||
base.OnMouseMove(e);
|
||||
Mouse.MouseMoveEvent(e, this);
|
||||
}
|
||||
|
||||
public void Update(UpdateContext context)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void ApplySetup(ISetup setup)
|
||||
|
|
@ -133,9 +86,68 @@ namespace SM.Base.Windows
|
|||
CurrentRenderPipeline = renderPipeline;
|
||||
}
|
||||
|
||||
public void TriggerLoad() => Load?.Invoke(this);
|
||||
public void TriggerLoad()
|
||||
{
|
||||
Load?.Invoke(this);
|
||||
}
|
||||
|
||||
public void TriggerResize() => Resize?.Invoke(this);
|
||||
public void TriggerResize()
|
||||
{
|
||||
Resize?.Invoke(this);
|
||||
}
|
||||
|
||||
public event Action<IGenericWindow> Loaded;
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
WindowCode.Load(this);
|
||||
SMRenderer.CurrentWindow = this;
|
||||
|
||||
base.OnLoad(e);
|
||||
}
|
||||
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
|
||||
WindowCode.Resize(this);
|
||||
|
||||
if (WindowFlags == WindowFlags.Window) _flagWindowSize = WindowSize;
|
||||
|
||||
if (Loading)
|
||||
{
|
||||
Loading = false;
|
||||
Loaded?.Invoke(this);
|
||||
AppliedSetup?.Loaded(this);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnUpdateFrame(FrameEventArgs e)
|
||||
{
|
||||
if (!Focused && !UpdateWhileUnfocused) return;
|
||||
|
||||
base.OnUpdateFrame(e);
|
||||
|
||||
WindowCode.Update(this, (float) e.Time);
|
||||
}
|
||||
|
||||
|
||||
protected override void OnRenderFrame(FrameEventArgs e)
|
||||
{
|
||||
base.OnRenderFrame(e);
|
||||
|
||||
WindowCode.Render(this, (float) e.Time);
|
||||
|
||||
SwapBuffers();
|
||||
|
||||
GLDebugging.CheckGLErrors();
|
||||
}
|
||||
|
||||
protected override void OnMouseMove(MouseMoveEventArgs e)
|
||||
{
|
||||
base.OnMouseMove(e);
|
||||
Mouse.MouseMoveEvent(e, this);
|
||||
}
|
||||
|
||||
public void ChangeWindowFlag(WindowFlags newFlag)
|
||||
{
|
||||
|
|
@ -144,14 +156,14 @@ namespace SM.Base.Windows
|
|||
switch (newFlag)
|
||||
{
|
||||
case WindowFlags.Window:
|
||||
Width = (int)_flagWindowSize.X;
|
||||
Height = (int)_flagWindowSize.Y;
|
||||
Width = (int) _flagWindowSize.X;
|
||||
Height = (int) _flagWindowSize.Y;
|
||||
|
||||
WindowBorder = WindowBorder.Resizable;
|
||||
break;
|
||||
case WindowFlags.BorderlessWindow:
|
||||
WindowBorder = WindowBorder.Hidden;
|
||||
|
||||
|
||||
X = Screen.PrimaryScreen.Bounds.Left;
|
||||
Y = Screen.PrimaryScreen.Bounds.Top;
|
||||
Width = Screen.PrimaryScreen.Bounds.Width;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
using System;
|
||||
#region usings
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using OpenTK;
|
||||
using SM.Base.Controls;
|
||||
using SM.Base.Scene;
|
||||
using SM.OGL.Framebuffer;
|
||||
|
||||
namespace SM.Base.Windows
|
||||
#endregion
|
||||
|
||||
namespace SM.Base.Window
|
||||
{
|
||||
public interface IGenericWindow : IFramebufferWindow
|
||||
{
|
||||
|
|
@ -26,12 +29,12 @@ namespace SM.Base.Windows
|
|||
|
||||
ISetup AppliedSetup { get; }
|
||||
|
||||
event Action<IGenericWindow> Resize;
|
||||
event Action<IGenericWindow> Load;
|
||||
|
||||
GenericScene CurrentScene { get; }
|
||||
RenderPipeline CurrentRenderPipeline { get; }
|
||||
|
||||
event Action<IGenericWindow> Resize;
|
||||
event Action<IGenericWindow> Load;
|
||||
|
||||
void Update(UpdateContext context);
|
||||
|
||||
void ApplySetup(ISetup setup);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
namespace SM.Base.Windows
|
||||
namespace SM.Base.Window
|
||||
{
|
||||
public interface ISetup
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,11 +1,16 @@
|
|||
using System.Collections.Generic;
|
||||
#region usings
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using SM.Base.Drawing;
|
||||
using SM.Base.Shaders;
|
||||
using SM.Base.Utility;
|
||||
using SM.OGL.Framebuffer;
|
||||
using SM.OGL.Texture;
|
||||
using SM.Utility;
|
||||
|
||||
namespace SM.Base.Windows
|
||||
#endregion
|
||||
|
||||
namespace SM.Base.Window
|
||||
{
|
||||
public abstract class RenderPipeline : IInitializable
|
||||
{
|
||||
|
|
@ -20,25 +25,8 @@ namespace SM.Base.Windows
|
|||
|
||||
public bool IsInitialized { get; set; }
|
||||
|
||||
internal void Render(ref DrawContext context) => RenderProcess(ref context);
|
||||
|
||||
protected abstract void RenderProcess(ref DrawContext context);
|
||||
|
||||
public virtual void Resize()
|
||||
{
|
||||
if (Framebuffers == null) return;
|
||||
foreach(var framebuffer in Framebuffers)
|
||||
framebuffer.Dispose();
|
||||
|
||||
Thread.Sleep(50);
|
||||
|
||||
foreach(var framebuffer in Framebuffers)
|
||||
framebuffer.Compile();
|
||||
}
|
||||
|
||||
public virtual void Activate()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void Initialization()
|
||||
|
|
@ -47,13 +35,34 @@ namespace SM.Base.Windows
|
|||
DefaultShader ??= SMRenderer.DefaultMaterialShader;
|
||||
}
|
||||
|
||||
internal void Render(ref DrawContext context)
|
||||
{
|
||||
RenderProcess(ref context);
|
||||
}
|
||||
|
||||
protected abstract void RenderProcess(ref DrawContext context);
|
||||
|
||||
public virtual void Resize()
|
||||
{
|
||||
if (Framebuffers == null) return;
|
||||
foreach (var framebuffer in Framebuffers)
|
||||
framebuffer.Dispose();
|
||||
|
||||
Thread.Sleep(50);
|
||||
|
||||
foreach (var framebuffer in Framebuffers)
|
||||
framebuffer.Compile();
|
||||
}
|
||||
|
||||
public Framebuffer CreateWindowFramebuffer(int multisamples = 0)
|
||||
{
|
||||
Framebuffer framebuffer = new Framebuffer(window: ConnectedWindow);
|
||||
Framebuffer framebuffer = new Framebuffer(ConnectedWindow);
|
||||
framebuffer.Append("color", new ColorAttachment(0, PixelInformation.RGBA_LDR, multisamples));
|
||||
|
||||
RenderbufferAttachment depthAttach = RenderbufferAttachment.Depth;
|
||||
depthAttach.Multisample = multisamples;
|
||||
framebuffer.AppendRenderbuffer(depthAttach);
|
||||
|
||||
return framebuffer;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
#region usings
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
using OpenTK.Input;
|
||||
|
|
@ -9,13 +9,16 @@ using SM.Base.Drawing;
|
|||
using SM.Base.Objects.Static;
|
||||
using SM.Base.PostProcess;
|
||||
using SM.Base.Scene;
|
||||
using SM.Base.ShaderExtension;
|
||||
using SM.Base.Shaders.Extensions;
|
||||
using SM.Base.Time;
|
||||
using SM.Base.Utility;
|
||||
using SM.OGL;
|
||||
using SM.Utility;
|
||||
using Keyboard = SM.Base.Controls.Keyboard;
|
||||
using Mouse = SM.Base.Controls.Mouse;
|
||||
|
||||
namespace SM.Base.Windows
|
||||
#endregion
|
||||
|
||||
namespace SM.Base.Window
|
||||
{
|
||||
internal class WindowCode
|
||||
{
|
||||
|
|
@ -69,19 +72,16 @@ namespace SM.Base.Windows
|
|||
internal static void Update(IGenericWindow window, float deltatime)
|
||||
{
|
||||
Deltatime.UpdateDelta = deltatime;
|
||||
SM.Base.Controls.Mouse.SetState();
|
||||
Controls.Keyboard.SetStage();
|
||||
var context = new UpdateContext()
|
||||
Mouse.SetState();
|
||||
Keyboard.SetStage();
|
||||
var context = new UpdateContext
|
||||
{
|
||||
Window = window,
|
||||
|
||||
Scene = window.CurrentScene
|
||||
};
|
||||
|
||||
if (Keyboard.IsDown(Key.AltLeft) && Keyboard.IsDown(Key.F4))
|
||||
{
|
||||
window.Close();
|
||||
}
|
||||
if (Keyboard.IsDown(Key.AltLeft) && Keyboard.IsDown(Key.F4)) window.Close();
|
||||
|
||||
Stopwatch.PerformTicks(context);
|
||||
window.CurrentScene?.Update(context);
|
||||
|
|
@ -97,7 +97,7 @@ namespace SM.Base.Windows
|
|||
GLObject.DisposeMarkedObjects();
|
||||
|
||||
Deltatime.RenderDelta = deltatime;
|
||||
var drawContext = new DrawContext()
|
||||
var drawContext = new DrawContext
|
||||
{
|
||||
Window = window,
|
||||
Scene = window.CurrentScene,
|
||||
|
|
@ -110,7 +110,7 @@ namespace SM.Base.Windows
|
|||
TextureMatrix = Matrix3.Identity,
|
||||
Instances = new Instance[1]
|
||||
{
|
||||
new Instance() {ModelMatrix = Matrix4.Identity, TextureMatrix = Matrix3.Identity}
|
||||
new Instance {ModelMatrix = Matrix4.Identity, TextureMatrix = Matrix3.Identity}
|
||||
}
|
||||
};
|
||||
drawContext.SetCamera(window.ViewportCamera);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
namespace SM.Base.Windows
|
||||
namespace SM.Base.Window
|
||||
{
|
||||
public enum WindowFlags
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue