17.01.2021

+ WPF-Support
+ Game Controller System
+ GameKeybind System

+ SM_WPF_TEST
This commit is contained in:
Michel Fedde 2021-01-17 21:13:37 +01:00
parent af90d617d3
commit 6f23a80f7f
60 changed files with 1536 additions and 143 deletions

View file

@ -12,7 +12,7 @@ namespace SM.Base.Controls
/// </summary> /// </summary>
/// <typeparam name="TWindow">The type of window this controller is connected to.</typeparam> /// <typeparam name="TWindow">The type of window this controller is connected to.</typeparam>
public class Mouse<TWindow> public class Mouse<TWindow>
where TWindow : GenericWindow where TWindow : IGenericWindow
{ {
/// <summary> /// <summary>
/// The window it is connected to. /// The window it is connected to.

View file

@ -34,8 +34,19 @@
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="OpenTK, Version=3.2.1.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL"> <Reference Include="GLWpfControl, Version=3.2.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\OpenTK.3.2.1\lib\net20\OpenTK.dll</HintPath> <HintPath>..\..\packages\OpenTK.GLWpfControl.3.2.3\lib\net452\GLWpfControl.dll</HintPath>
</Reference>
<Reference Include="OpenTK, Version=3.3.1.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<HintPath>..\..\packages\OpenTK.3.3.1\lib\net20\OpenTK.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="SharpDX, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\..\packages\SharpDX.4.2.0\lib\net45\SharpDX.dll</HintPath>
</Reference>
<Reference Include="SharpDX.XInput, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\..\packages\SharpDX.XInput.4.2.0\lib\net45\SharpDX.XInput.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
@ -43,6 +54,8 @@
<Reference Include="System.IO.Compression" /> <Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" /> <Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xaml" />
<Reference Include="WindowsBase" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Controls\Mouse.cs" /> <Compile Include="Controls\Mouse.cs" />
@ -92,6 +105,9 @@
<Compile Include="Scene\GenericCamera.cs" /> <Compile Include="Scene\GenericCamera.cs" />
<Compile Include="Scene\GenericScene.cs" /> <Compile Include="Scene\GenericScene.cs" />
<Compile Include="Objects\Static\Plate.cs" /> <Compile Include="Objects\Static\Plate.cs" />
<Compile Include="Window\GenericWindowCode.cs" />
<Compile Include="Window\GenericWPFWindow.cs" />
<Compile Include="Window\IGenericWindow.cs" />
<Compile Include="Window\RenderPipeline.cs" /> <Compile Include="Window\RenderPipeline.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -112,10 +128,12 @@
<EmbeddedResource Include="PostProcess\DefaultFiles\vertexWithExt.vert" /> <EmbeddedResource Include="PostProcess\DefaultFiles\vertexWithExt.vert" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="OpenTK.dll.config" />
<None Include="packages.config" />
<EmbeddedResource Include="PostEffects\Shaders\bloom_blur.glsl" /> <EmbeddedResource Include="PostEffects\Shaders\bloom_blur.glsl" />
<EmbeddedResource Include="PostEffects\Shaders\bloom_merge.glsl" /> <EmbeddedResource Include="PostEffects\Shaders\bloom_merge.glsl" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="OpenTK.dll.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>

View file

@ -55,6 +55,6 @@ namespace SM.Base
/// <summary> /// <summary>
/// Represents the current active window. /// Represents the current active window.
/// </summary> /// </summary>
public static GenericWindow CurrentWindow { get; internal set; } public static IGenericWindow CurrentWindow { get; internal set; }
} }
} }

View file

@ -178,7 +178,6 @@ namespace SM.Base.Scene
} }
} }
/// <inheritdoc /> /// <inheritdoc />
public override void Update(UpdateContext context) public override void Update(UpdateContext context)
{ {

View file

@ -52,6 +52,8 @@ namespace SM.Base.Time
/// </summary> /// </summary>
public TimeSpan ElapsedSpan { get; protected set; } public TimeSpan ElapsedSpan { get; protected set; }
public event Action<Stopwatch, UpdateContext> Tick;
/// <summary> /// <summary>
/// Starts the stopwatch. /// Starts the stopwatch.
/// </summary> /// </summary>
@ -69,10 +71,12 @@ namespace SM.Base.Time
/// Performs a tick. /// Performs a tick.
/// </summary> /// </summary>
/// <param name="context"></param> /// <param name="context"></param>
private protected virtual void Tick(UpdateContext context) private protected virtual void Ticking(UpdateContext context)
{ {
Elapsed += context.Deltatime; Elapsed += context.Deltatime;
ElapsedSpan = TimeSpan.FromSeconds(Elapsed); ElapsedSpan = TimeSpan.FromSeconds(Elapsed);
Tick?.Invoke(this, context);
} }
/// <summary> /// <summary>
@ -115,7 +119,7 @@ namespace SM.Base.Time
for (var i = 0; i < _activeStopwatches.Count; i++) for (var i = 0; i < _activeStopwatches.Count; i++)
{ {
if (_activeStopwatches[i].Paused) continue; if (_activeStopwatches[i].Paused) continue;
_activeStopwatches[i].Tick(context); _activeStopwatches[i].Ticking(context);
} }
} }
} }

View file

@ -1,6 +1,7 @@
#region usings #region usings
using System; using System;
using System.Diagnostics.Eventing.Reader;
using SM.Base.Contexts; using SM.Base.Contexts;
#endregion #endregion
@ -43,7 +44,7 @@ namespace SM.Base.Time
/// <summary> /// <summary>
/// The event, that is triggered when the timer stops. /// The event, that is triggered when the timer stops.
/// </summary> /// </summary>
public event Action<Timer, UpdateContext> EndAction; public event Action<Timer, UpdateContext> End;
/// <inheritdoc /> /// <inheritdoc />
public override void Start() public override void Start()
@ -52,9 +53,9 @@ namespace SM.Base.Time
Reset(); Reset();
} }
private protected override void Tick(UpdateContext context) private protected override void Ticking(UpdateContext context)
{ {
base.Tick(context); base.Ticking(context);
ElapsedNormalized = Elapsed / Target; ElapsedNormalized = Elapsed / Target;
if (ElapsedNormalized >= 1) Stopping(context); if (ElapsedNormalized >= 1) Stopping(context);
@ -70,12 +71,12 @@ namespace SM.Base.Time
} }
/// <summary> /// <summary>
/// This will trigger <see cref="EndAction" /> /// This will trigger <see cref="End" />
/// </summary> /// </summary>
/// <param name="context"></param> /// <param name="context"></param>
protected void TriggerEndAction(UpdateContext context) protected void TriggerEndAction(UpdateContext context)
{ {
EndAction?.Invoke(this, context); End?.Invoke(this, context);
} }
} }
} }

View file

@ -18,7 +18,7 @@ namespace SM.Utility
/// <returns></returns> /// <returns></returns>
public static float TurnTowards(Vector2 origin, Vector2 target) public static float TurnTowards(Vector2 origin, Vector2 target)
{ {
return MathHelper.RadiansToDegrees((float) Math.Atan2(target.Y - origin.Y, target.X - origin.X)); return MathHelper.RadiansToDegrees((float) Math.Atan2(origin.X - target.X, target.Y - origin.Y));
} }
} }
} }

View file

@ -27,11 +27,11 @@ namespace SM.Base.Contexts
public RenderPipeline ActivePipeline; public RenderPipeline ActivePipeline;
public GenericScene ActiveScene; public GenericScene ActiveScene;
public GenericWindow Window; public IGenericWindow Window;
public GenericCamera UsedCamera => public GenericCamera UsedCamera =>
ForceViewport || ActiveScene._camera == null ? Window._viewportCamera : ActiveScene._camera; ForceViewport || ActiveScene._camera == null ? Window.ViewportCamera : ActiveScene._camera;

View file

@ -1,6 +1,7 @@
#region usings #region usings
using OpenTK.Input; using OpenTK.Input;
using SM.Base.Scene;
#endregion #endregion
@ -25,5 +26,7 @@ namespace SM.Base.Contexts
/// The current mouse state. /// The current mouse state.
/// </summary> /// </summary>
public MouseState MouseState; public MouseState MouseState;
public GenericScene CurrentScene;
} }
} }

View file

@ -0,0 +1,109 @@
using System;
using System.Drawing;
using System.Windows;
using System.Windows.Media;
using OpenTK;
using OpenTK.Wpf;
using SM.Base.Scene;
using SM.OGL;
namespace SM.Base
{
public class GenericWPFWindow : OpenTK.Wpf.GLWpfControl, IGenericWindow
{
private bool _renderContinuesly;
protected GenericCamera _viewportCamera;
public bool Loading => !base.IsInitialized;
public float Aspect { get; set; }
public GenericCamera ViewportCamera => _viewportCamera;
public bool ForceViewportCamera { get; set; }
public int Width => (int) base.ActualWidth;
public int Height => (int) base.ActualHeight;
public Rectangle ClientRectangle => new Rectangle((int)base.RenderTransformOrigin.X, (int)RenderTransformOrigin.Y, Width, Height);
public Vector2 WorldScale { get; set; }
public GenericWPFWindow(bool renderContinuesly = false)
{
_renderContinuesly = renderContinuesly;
Ready += Init;
Render += Rendering;
}
protected virtual void Init()
{
GenericWindowCode.Load(this);
}
protected virtual void Rendering(TimeSpan delta)
{
}
protected override void OnRenderSizeChanged(SizeChangedInfo info)
{
base.OnRenderSizeChanged(info);
GenericWindowCode.Resize(this);
}
public void Start()
{
GLWpfControlSettings settings = new GLWpfControlSettings()
{
MajorVersion = GLSettings.ForcedVersion.MajorVersion,
MinorVersion = GLSettings.ForcedVersion.MinorVersion,
RenderContinuously = _renderContinuesly
};
base.Start(settings);
}
public virtual void SetWorldScale()
{ }
}
public class GenericWPFWindow<TScene, TCamera> : GenericWPFWindow, IGenericWindow<TScene, TCamera>
where TScene : GenericScene, new()
where TCamera : GenericCamera, new()
{
private TScene _scene;
private RenderPipeline<TScene> _renderPipeline;
public TScene CurrentScene => _scene;
public RenderPipeline<TScene> RenderPipeline => _renderPipeline;
public GenericWPFWindow(bool renderContinuesly = false) : base(renderContinuesly)
{
_viewportCamera = new TCamera();
}
protected override void Rendering(TimeSpan delta)
{
base.Rendering(delta);
GenericWindowCode.Render(this, (float)delta.TotalSeconds);
}
protected override void OnRenderSizeChanged(SizeChangedInfo info)
{
base.OnRenderSizeChanged(info);
GenericWindowCode.Resize(this);
}
public void SetScene(TScene scene)
{
_scene = scene;
scene.Activate();
RenderPipeline.SceneChanged(scene);
}
public void SetRenderPipeline(RenderPipeline<TScene> renderPipeline)
{
_renderPipeline = renderPipeline;
renderPipeline.Activate(this);
}
}
}

View file

@ -26,20 +26,24 @@ namespace SM.Base
/// <summary> /// <summary>
/// The base window. /// The base window.
/// </summary> /// </summary>
public abstract class GenericWindow : GameWindow public abstract class GenericWindow : GameWindow, IGenericWindow
{ {
protected GenericCamera _viewportCamera;
internal bool _loading = true; internal bool _loading = true;
internal List<Action> _actionsAfterLoading = new List<Action>(); internal List<Action> _actionsAfterLoading = new List<Action>();
public bool Loading => _loading;
/// <summary> /// <summary>
/// This tells you the current world scale. /// This tells you the current world scale.
/// </summary> /// </summary>
protected Vector2 _worldScale = Vector2.Zero; public Vector2 WorldScale { get; set; } = Vector2.Zero;
/// <summary> /// <summary>
/// This tells you the current aspect ratio of this window. /// This tells you the current aspect ratio of this window.
/// </summary> /// </summary>
public float Aspect { get; private set; } public float Aspect { get; set; }
/// <summary> /// <summary>
/// If false, the window will not react on updates and will not render something. /// If false, the window will not react on updates and will not render something.
@ -49,7 +53,8 @@ namespace SM.Base
/// </summary> /// </summary>
public bool ReactWhileUnfocused = false; public bool ReactWhileUnfocused = false;
internal GenericCamera _viewportCamera; public GenericCamera ViewportCamera => _viewportCamera;
public bool ForceViewportCamera { get; set; }
/// <inheritdoc /> /// <inheritdoc />
protected GenericWindow() : this(1280, 720, "Generic OGL Title", GameWindowFlags.Default) protected GenericWindow() : this(1280, 720, "Generic OGL Title", GameWindowFlags.Default)
@ -70,33 +75,7 @@ namespace SM.Base
/// <inheritdoc /> /// <inheritdoc />
protected override void OnLoad(EventArgs e) protected override void OnLoad(EventArgs e)
{ {
SMRenderer.CurrentWindow = this; GenericWindowCode.Load(this);
GLSystem.INIT_SYSTEM();
GLSettings.ShaderPreProcessing = true;
var args = Environment.GetCommandLineArgs();
if (args.Contains("--advDebugging"))
{
SMRenderer.AdvancedDebugging = true;
GLSettings.InfoEveryUniform = true;
}
Log.Init();
Log.Write("#", ConsoleColor.Cyan, "----------------------",
"--- OpenGL Loading ---",
"----------------------------------",
$"--- {"DeviceVersion",14}: {GLSystem.DeviceVersion,-10} ---",
$"--- {"ForcedVersion",14}: {GLSettings.ForcedVersion,-10} ---",
$"--- {"ShadingVersion",14}: {GLSystem.ShadingVersion,-10} ---",
$"--- {"Debugging",14}: {GLSystem.Debugging,-10} ---",
$"--- {"AdvDebugging",14}: {SMRenderer.AdvancedDebugging,-10} ---",
"----------------------------------");
if (SMRenderer.AdvancedDebugging) Log.Write("Extension", ConsoleColor.DarkCyan, GLSystem.Extensions);
ExtensionManager.InitExtensions();
base.OnLoad(e); base.OnLoad(e);
} }
@ -106,10 +85,7 @@ namespace SM.Base
{ {
base.OnResize(e); base.OnResize(e);
Aspect = (float) Width / Height; GenericWindowCode.Resize(this);
_worldScale = new Vector2(Width, Height);
SetWorldScale();
GL.Viewport(ClientRectangle);
if (_loading) if (_loading)
{ {
@ -132,7 +108,7 @@ namespace SM.Base
/// <summary> /// <summary>
/// Sets the world scale. /// Sets the world scale.
/// </summary> /// </summary>
protected virtual void SetWorldScale() public virtual void SetWorldScale()
{ {
} }
@ -218,10 +194,13 @@ namespace SM.Base
/// </summary> /// </summary>
/// <typeparam name="TScene">The scene type</typeparam> /// <typeparam name="TScene">The scene type</typeparam>
/// <typeparam name="TCamera">The camera type</typeparam> /// <typeparam name="TCamera">The camera type</typeparam>
public abstract class GenericWindow<TScene, TCamera> : GenericWindow public abstract class GenericWindow<TScene, TCamera> : GenericWindow, IGenericWindow<TScene, TCamera>
where TScene : GenericScene, new() where TScene : GenericScene, new()
where TCamera : GenericCamera, new() where TCamera : GenericCamera, new()
{ {
private RenderPipeline<TScene> _renderPipeline;
private TScene _scene;
/// <inheritdoc /> /// <inheritdoc />
protected GenericWindow() protected GenericWindow()
{ {
@ -244,17 +223,18 @@ namespace SM.Base
/// <summary> /// <summary>
/// The current scene. /// The current scene.
/// </summary> /// </summary>
public TScene CurrentScene { get; private set; } public TScene CurrentScene => _scene;
/// <summary> /// <summary>
/// Controls how a scene is rendered. /// Controls how a scene is rendered.
/// </summary> /// </summary>
public RenderPipeline<TScene> RenderPipeline { get; private set; } public RenderPipeline<TScene> RenderPipeline => _renderPipeline;
/// <inheritdoc /> /// <inheritdoc />
protected override void Update(FrameEventArgs e, ref UpdateContext context) protected override void Update(FrameEventArgs e, ref UpdateContext context)
{ {
base.Update(e, ref context); base.Update(e, ref context);
context.CurrentScene = CurrentScene;
CurrentScene?.Update(context); CurrentScene?.Update(context);
} }
@ -263,37 +243,9 @@ namespace SM.Base
{ {
if (!ReactWhileUnfocused && !Focused) return; if (!ReactWhileUnfocused && !Focused) return;
if (CurrentScene == null) return;
SMRenderer.CurrentFrame++;
Deltatime.RenderDelta = (float) e.Time;
var drawContext = new DrawContext
{
ForceViewport = ForceViewportCamera,
ActiveScene = CurrentScene,
Window = this,
Instances = new[]
{
new Instance
{ModelMatrix = Matrix4.Identity, TexturePosition = Vector2.Zero, TextureScale = Vector2.One}
},
Mesh = Plate.Object,
WorldScale = _worldScale,
LastPassthough = this,
ShaderArguments = new Dictionary<string, object>(),
World = ViewportCamera.World,
View = ViewportCamera.CalculateViewMatrix(),
ModelMaster = Matrix4.Identity
};
base.OnRenderFrame(e); base.OnRenderFrame(e);
RenderPipeline.Render(ref drawContext); GenericWindowCode.Render(this, (float)e.Time);
SwapBuffers(); SwapBuffers();
@ -305,13 +257,7 @@ namespace SM.Base
{ {
base.OnResize(e); base.OnResize(e);
ViewportCamera.RecalculateWorld(_worldScale, Aspect); GenericWindowCode.Resize(this);
RenderPipeline.Resize();
PostProcessEffect.Model = Matrix4.CreateScale(_worldScale.X, -_worldScale.Y, 1);
PostProcessEffect.Mvp = PostProcessEffect.Model *
Matrix4.LookAt(0, 0, 1, 0, 0, 0, 0, 1, 0) *
GenericCamera.OrthographicWorld;
} }
/// <summary> /// <summary>
@ -326,7 +272,7 @@ namespace SM.Base
return; return;
} }
CurrentScene = scene; _scene = scene;
scene.Activate(); scene.Activate();
RenderPipeline.SceneChanged(scene); RenderPipeline.SceneChanged(scene);
} }
@ -343,7 +289,7 @@ namespace SM.Base
return; return;
} }
RenderPipeline = pipeline; _renderPipeline = pipeline;
pipeline.Activate(this); pipeline.Activate(this);
} }
} }

View file

@ -0,0 +1,107 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OpenTK;
using OpenTK.Graphics.OpenGL4;
using SM.Base.Contexts;
using SM.Base.Drawing;
using SM.Base.Objects.Static;
using SM.Base.PostProcess;
using SM.Base.Scene;
using SM.Base.ShaderExtension;
using SM.OGL;
using SM.Utility;
namespace SM.Base
{
public class GenericWindowCode
{
internal static void Load(IGenericWindow window)
{
SMRenderer.CurrentWindow = window;
GLSystem.INIT_SYSTEM();
GLSettings.ShaderPreProcessing = true;
var args = Environment.GetCommandLineArgs();
if (args.Contains("--advDebugging"))
{
SMRenderer.AdvancedDebugging = true;
GLSettings.InfoEveryUniform = true;
}
Log.Init();
Log.Write("#", ConsoleColor.Cyan, "----------------------",
"--- OpenGL Loading ---",
"----------------------------------",
$"--- {"DeviceVersion",14}: {GLSystem.DeviceVersion,-10} ---",
$"--- {"ForcedVersion",14}: {GLSettings.ForcedVersion,-10} ---",
$"--- {"ShadingVersion",14}: {GLSystem.ShadingVersion,-10} ---",
$"--- {"Debugging",14}: {GLSystem.Debugging,-10} ---",
$"--- {"AdvDebugging",14}: {SMRenderer.AdvancedDebugging,-10} ---",
"----------------------------------");
if (SMRenderer.AdvancedDebugging) Log.Write("Extension", ConsoleColor.DarkCyan, GLSystem.Extensions);
ExtensionManager.InitExtensions();
}
internal static void Resize(IGenericWindow window)
{
window.Aspect = (float) window.Width / window.Height;
window.WorldScale = new Vector2(window.Width, window.Height);
window.SetWorldScale();
GL.Viewport(window.ClientRectangle);
}
internal static void Resize<TScene, TCamera>(IGenericWindow<TScene, TCamera> window)
where TScene : GenericScene, new()
where TCamera : GenericCamera, new()
{
window.ViewportCamera.RecalculateWorld(window.WorldScale, window.Aspect);
window.RenderPipeline.Resize();
PostProcessEffect.Model = Matrix4.CreateScale(window.WorldScale.X, -window.WorldScale.Y, 1);
PostProcessEffect.Mvp = PostProcessEffect.Model *
Matrix4.LookAt(0, 0, 1, 0, 0, 0, 0, 1, 0) *
GenericCamera.OrthographicWorld;
}
internal static void Render<TScene, TCamera>(IGenericWindow<TScene, TCamera> window, float deltatime)
where TScene : GenericScene, new()
where TCamera : GenericCamera, new()
{
if (window.CurrentScene == null) return;
SMRenderer.CurrentFrame++;
Deltatime.RenderDelta = deltatime;
var drawContext = new DrawContext
{
ForceViewport = window.ForceViewportCamera,
ActiveScene = window.CurrentScene,
Window = window,
Instances = new[]
{
new Instance
{ModelMatrix = Matrix4.Identity, TexturePosition = Vector2.Zero, TextureScale = Vector2.One}
},
Mesh = Plate.Object,
WorldScale = window.WorldScale,
LastPassthough = window,
ShaderArguments = new Dictionary<string, object>(),
World = window.ViewportCamera.World,
View = window.ViewportCamera.CalculateViewMatrix(),
ModelMaster = Matrix4.Identity
};
window.RenderPipeline?.Render(ref drawContext);
}
}
}

View file

@ -0,0 +1,37 @@
using System.Drawing;
using System.Windows;
using OpenTK;
using SM.Base.Scene;
using SM.OGL.Framebuffer;
namespace SM.Base
{
public interface IGenericWindow : IFramebufferWindow
{
bool Loading { get; }
float Aspect { get; set; }
GenericCamera ViewportCamera { get; }
bool ForceViewportCamera { get; set; }
int Width { get; }
int Height { get; }
Rectangle ClientRectangle { get; }
Vector2 WorldScale { get; set; }
void SetWorldScale();
}
public interface IGenericWindow<TScene, TCamera> : IGenericWindow
where TScene : GenericScene, new()
where TCamera : GenericCamera, new()
{
TScene CurrentScene { get; }
RenderPipeline<TScene> RenderPipeline { get; }
void SetScene(TScene scene);
void SetRenderPipeline(RenderPipeline<TScene> renderPipeline);
}
}

View file

@ -24,7 +24,7 @@ namespace SM.Base
/// <summary> /// <summary>
/// The window the pipeline is connected to. /// The window the pipeline is connected to.
/// </summary> /// </summary>
protected GenericWindow _window { get; private set; } protected IGenericWindow _window { get; private set; }
/// <summary> /// <summary>
/// The framebuffers, that are used in this Pipeline. /// The framebuffers, that are used in this Pipeline.
@ -63,7 +63,7 @@ namespace SM.Base
} }
} }
internal void Activate(GenericWindow window) internal void Activate(IGenericWindow window)
{ {
_window = window; _window = window;
@ -85,7 +85,7 @@ namespace SM.Base
/// <summary> /// <summary>
/// Occurs, when the pipeline was connected to a window. /// Occurs, when the pipeline was connected to a window.
/// </summary> /// </summary>
protected internal virtual void Activation(GenericWindow window) protected internal virtual void Activation(IGenericWindow window)
{ {
} }
@ -94,7 +94,7 @@ namespace SM.Base
/// Occurs, when the pipeline was connected to a window the first time. /// Occurs, when the pipeline was connected to a window the first time.
/// </summary> /// </summary>
/// <param name="window"></param> /// <param name="window"></param>
protected internal virtual void Initialization(GenericWindow window) protected internal virtual void Initialization(IGenericWindow window)
{ {
} }
@ -131,6 +131,7 @@ namespace SM.Base
internal void Render(ref DrawContext context) internal void Render(ref DrawContext context)
{ {
context.ActivePipeline = this; context.ActivePipeline = this;
if (context.ActiveScene == null) return;
RenderProcess(ref context, (TScene)context.ActiveScene); RenderProcess(ref context, (TScene)context.ActiveScene);
} }

View file

@ -1,4 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="OpenTK" version="3.2.1" targetFramework="net452" /> <package id="OpenTK" version="3.3.1" targetFramework="net452" />
<package id="OpenTK.GLWpfControl" version="3.2.3" targetFramework="net452" />
<package id="SharpDX" version="4.2.0" targetFramework="net452" />
<package id="SharpDX.XInput" version="4.2.0" targetFramework="net452" />
</packages> </packages>

View file

@ -25,7 +25,7 @@ namespace SM.OGL.Framebuffer
private bool _canBeCompiled = true; private bool _canBeCompiled = true;
private INativeWindow _window; private IFramebufferWindow _window;
private float _windowScale; private float _windowScale;
/// <summary> /// <summary>
@ -40,7 +40,7 @@ namespace SM.OGL.Framebuffer
/// </summary> /// </summary>
/// <param name="window"></param> /// <param name="window"></param>
/// <param name="scale"></param> /// <param name="scale"></param>
public Framebuffer(INativeWindow window, float scale = 1) : this(new Vector2(window.Width * scale, public Framebuffer(IFramebufferWindow window, float scale = 1) : this(new Vector2(window.Width * scale,
window.Height * scale)) window.Height * scale))
{ {
_window = window; _window = window;

View file

@ -0,0 +1,8 @@
namespace SM.OGL.Framebuffer
{
public interface IFramebufferWindow
{
int Width { get; }
int Height { get; }
}
}

View file

@ -34,8 +34,8 @@
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="OpenTK, Version=3.2.1.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL"> <Reference Include="OpenTK, Version=3.3.1.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<HintPath>..\..\packages\OpenTK.3.2.1\lib\net20\OpenTK.dll</HintPath> <HintPath>..\..\packages\OpenTK.3.3.1\lib\net20\OpenTK.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
@ -43,6 +43,7 @@
<ItemGroup> <ItemGroup>
<Compile Include="Framebuffer\ColorAttachment.cs" /> <Compile Include="Framebuffer\ColorAttachment.cs" />
<Compile Include="Framebuffer\Framebuffer.cs" /> <Compile Include="Framebuffer\Framebuffer.cs" />
<Compile Include="Framebuffer\IFramebufferWindow.cs" />
<Compile Include="GLCustomActions.cs" /> <Compile Include="GLCustomActions.cs" />
<Compile Include="GLDebugging.cs" /> <Compile Include="GLDebugging.cs" />
<Compile Include="GLObject.cs" /> <Compile Include="GLObject.cs" />
@ -71,5 +72,8 @@
<None Include="OpenTK.dll.config" /> <None Include="OpenTK.dll.config" />
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="GL\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="OpenTK" version="3.2.1" targetFramework="net452" /> <package id="OpenTK" version="3.3.1" targetFramework="net452" />
</packages> </packages>

View file

@ -10,9 +10,9 @@ using SM2D.Types;
namespace SM2D.Controls namespace SM2D.Controls
{ {
public class Mouse2D : Mouse<GLWindow2D> public class Mouse2D : Mouse<IGLWindow2D>
{ {
protected internal Mouse2D(GLWindow2D window) : base(window) protected internal Mouse2D(IGLWindow2D window) : base(window)
{ {
} }

View file

@ -22,7 +22,7 @@ namespace SM2D.Pipelines
} }
protected override void Initialization(GenericWindow window) protected override void Initialization(IGenericWindow window)
{ {
MainFramebuffer = CreateWindowFramebuffer(); MainFramebuffer = CreateWindowFramebuffer();
} }
@ -31,13 +31,10 @@ namespace SM2D.Pipelines
{ {
if (scene != null) if (scene != null)
{ {
MainFramebuffer.Activate(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
scene.DrawBackground(context); scene.DrawBackground(context);
scene.DrawMainObjects(context); scene.DrawMainObjects(context);
Framebuffer.Screen.Activate();
scene.DrawHUD(context); scene.DrawHUD(context);
scene.DrawDebug(context); scene.DrawDebug(context);
} }

View file

@ -31,12 +31,13 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="OpenTK, Version=3.2.1.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL"> <Reference Include="PresentationCore" />
<HintPath>..\..\packages\OpenTK.3.2.1\lib\net20\OpenTK.dll</HintPath> <Reference Include="PresentationFramework" />
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Xaml" />
<Reference Include="WindowsBase" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Controls\Mouse2D.cs" /> <Compile Include="Controls\Mouse2D.cs" />
@ -44,7 +45,8 @@
<Compile Include="Drawing\DrawObject2D.cs" /> <Compile Include="Drawing\DrawObject2D.cs" />
<Compile Include="Drawing\DrawParticles.cs" /> <Compile Include="Drawing\DrawParticles.cs" />
<Compile Include="Drawing\DrawText.cs" /> <Compile Include="Drawing\DrawText.cs" />
<Compile Include="GLWindow2D.cs" /> <Compile Include="Window\GLWindow2D.cs" />
<Compile Include="Window\GLWPFWindow2D.cs" />
<Compile Include="Object\Polygon.cs" /> <Compile Include="Object\Polygon.cs" />
<Compile Include="Object\PolygonVertex.cs" /> <Compile Include="Object\PolygonVertex.cs" />
<Compile Include="Pipelines\Adv2DPipeline.cs" /> <Compile Include="Pipelines\Adv2DPipeline.cs" />
@ -58,6 +60,7 @@
<Compile Include="Shader\Basic2DShader.cs" /> <Compile Include="Shader\Basic2DShader.cs" />
<Compile Include="Shader\Default2DShader.cs" /> <Compile Include="Shader\Default2DShader.cs" />
<Compile Include="Types\Transformation.cs" /> <Compile Include="Types\Transformation.cs" />
<Compile Include="Window\IGLWindow2D.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\SM.Base\SM.Base.csproj"> <ProjectReference Include="..\SM.Base\SM.Base.csproj">
@ -74,11 +77,15 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="OpenTK"> <PackageReference Include="OpenTK">
<Version>3.2.1</Version> <Version>3.3.1</Version>
</PackageReference>
<PackageReference Include="OpenTK.GLWpfControl">
<Version>3.2.3</Version>
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Shader\ShaderFiles\basic.glsl" /> <EmbeddedResource Include="Shader\ShaderFiles\basic.glsl" />
</ItemGroup> </ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>

View file

@ -1,2 +1,3 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> <wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=light_005Clightobjects/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=light_005Clightobjects/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=window/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View file

@ -18,7 +18,6 @@ namespace SM2D.Shader
private Default2DShader() : base(AssemblyUtility.ReadAssemblyFile("SM2D.Shader.ShaderFiles.default.glsl")) private Default2DShader() : base(AssemblyUtility.ReadAssemblyFile("SM2D.Shader.ShaderFiles.default.glsl"))
{ {
Load();
} }
protected override void DrawProcess(DrawContext context) protected override void DrawProcess(DrawContext context)

View file

@ -36,7 +36,7 @@ namespace SM2D.Types
{ {
if (_modelMatrix.Determinant < 0.0001) return new Vector2(0); if (_modelMatrix.Determinant < 0.0001) return new Vector2(0);
var vec = Vector3.TransformNormal(Vector3.UnitX, _modelMatrix); var vec = Vector3.TransformNormal(Vector3.UnitY, _modelMatrix);
vec.Normalize(); vec.Normalize();
return vec.Xy; return vec.Xy;
} }

View file

@ -0,0 +1,48 @@
using System;
using System.Windows.Media;
using OpenTK;
using OpenTK.Graphics.ES11;
using SM.Base;
using SM2D.Controls;
using SM2D.Pipelines;
using SM2D.Scene;
using SM2D.Shader;
namespace SM2D
{
public class GLWPFWindow2D : GenericWPFWindow<Scene.Scene, Camera>, IGLWindow2D
{
public GLWPFWindow2D()
{
Mouse = new Mouse2D(this);
}
public Vector2? Scaling { get; set; }
public Mouse2D Mouse { get; }
protected override void Init()
{
base.Init();
SMRenderer.DefaultMaterialShader = Default2DShader.MaterialShader;
SetRenderPipeline(Default2DPipeline.Pipeline);
}
protected override void Rendering(TimeSpan delta)
{
GL.Disable(EnableCap.DepthTest);
base.Rendering(delta);
}
public override void SetWorldScale()
{
if (Scaling.HasValue)
{
if (Scaling.Value.X > 0 && Scaling.Value.Y > 0) WorldScale = Scaling.Value;
else if (Scaling.Value.X > 0) WorldScale = new Vector2(Scaling.Value.X, Scaling.Value.X / Aspect);
else if (Scaling.Value.Y > 0) WorldScale = new Vector2(Aspect * Scaling.Value.Y, Scaling.Value.Y);
}
}
}
}

View file

@ -14,7 +14,7 @@ using SM2D.Shader;
namespace SM2D namespace SM2D
{ {
public class GLWindow2D : GenericWindow<Scene.Scene, Camera> public class GLWindow2D : GenericWindow<Scene.Scene, Camera>, IGLWindow2D
{ {
public GLWindow2D() public GLWindow2D()
{ {
@ -22,7 +22,6 @@ namespace SM2D
} }
public Vector2? Scaling { get; set; } public Vector2? Scaling { get; set; }
public Vector2 WorldScale => _worldScale;
public Mouse2D Mouse { get; } public Mouse2D Mouse { get; }
@ -47,13 +46,13 @@ namespace SM2D
base.OnRenderFrame(e); base.OnRenderFrame(e);
} }
protected override void SetWorldScale() public override void SetWorldScale()
{ {
if (Scaling.HasValue) if (Scaling.HasValue)
{ {
if (Scaling.Value.X > 0 && Scaling.Value.Y > 0) _worldScale = Scaling.Value; if (Scaling.Value.X > 0 && Scaling.Value.Y > 0) WorldScale = Scaling.Value;
else if (Scaling.Value.X > 0) _worldScale = new Vector2(Scaling.Value.X, Scaling.Value.X / Aspect); else if (Scaling.Value.X > 0) WorldScale = new Vector2(Scaling.Value.X, Scaling.Value.X / Aspect);
else if (Scaling.Value.Y > 0) _worldScale = new Vector2(Aspect * Scaling.Value.Y, Scaling.Value.Y); else if (Scaling.Value.Y > 0) WorldScale = new Vector2(Aspect * Scaling.Value.Y, Scaling.Value.Y);
} }
} }

View file

@ -0,0 +1,14 @@
using OpenTK;
using SM.Base;
using SM2D.Controls;
using SM2D.Scene;
namespace SM2D
{
public interface IGLWindow2D : IGenericWindow<Scene.Scene, Camera>
{
Vector2? Scaling { get; set; }
Mouse2D Mouse { get; }
}
}

View file

@ -0,0 +1,39 @@
using SharpDX.XInput;
namespace SM.Game.Controls
{
public struct GameController
{
public static float GlobalDeadband = 2500;
private Controller _controller;
public float Deadband { get; set; }
public bool IsConnected => _controller.IsConnected;
public UserIndex Index { get; private set; }
public GameController(int id) : this((UserIndex)id)
{}
public GameController(UserIndex index = UserIndex.Any)
{
_controller = new Controller(index);
Index = index;
Deadband = GlobalDeadband;
}
public GameControllerState GetState()
{
if (!IsConnected)
{
return new GameControllerState(true);
}
Gamepad state = _controller.GetState().Gamepad;
return new GameControllerState(state, ref this);
}
}
}

View file

@ -0,0 +1,57 @@
using System;
using OpenTK;
using SharpDX.XInput;
namespace SM.Game.Controls
{
public struct GameControllerState
{
public GameControllerStateThumbs Thumbs;
public GameControllerStateTriggers Triggers;
public GameControllerStateDPad DPad;
public GameControllerStateButtons Buttons;
public bool FromConnected { get; }
internal GameControllerState(bool empty)
{
FromConnected = false;
Thumbs = GameControllerStateThumbs.Default;
Triggers = GameControllerStateTriggers.Default;
DPad = GameControllerStateDPad.Default;
Buttons = GameControllerStateButtons.Default;
}
internal GameControllerState(Gamepad state, ref GameController controller)
{
FromConnected = true;
Thumbs = new GameControllerStateThumbs
{
Left = new Vector2(
Math.Abs((float)state.LeftThumbX) < controller.Deadband ? 0 : (float)state.LeftThumbX / short.MaxValue,
Math.Abs((float)state.LeftThumbY) < controller.Deadband ? 0 : (float)state.LeftThumbY / short.MaxValue),
Right = new Vector2(
Math.Abs((float)state.RightThumbX) < controller.Deadband ? 0 : (float)state.RightThumbX / short.MaxValue,
Math.Abs((float)state.RightThumbY) < controller.Deadband ? 0 : (float)state.RightThumbY / short.MaxValue),
PressedLeft = state.Buttons.HasFlag(GamepadButtonFlags.LeftThumb),
PressedRight = state.Buttons.HasFlag(GamepadButtonFlags.RightThumb)
};
Triggers = new GameControllerStateTriggers()
{
Left = (float)state.LeftTrigger / byte.MaxValue,
Right = (float)state.RightTrigger / byte.MaxValue
};
DPad = new GameControllerStateDPad(state.Buttons);
Buttons = new GameControllerStateButtons(state.Buttons);
}
public override string ToString()
{
return !FromConnected ? "[From a disconnected controller]" : $"Thumbs: [{Thumbs}]; Trigger: [{Triggers}]; DPad: [{DPad}]; Buttons: [{Buttons}]";
}
}
}

View file

@ -0,0 +1,45 @@
using SharpDX.XInput;
namespace SM.Game.Controls
{
public struct GameControllerStateButtons
{
public static GameControllerStateButtons Default = new GameControllerStateButtons(GamepadButtonFlags.None);
private GamepadButtonFlags _buttonFlags;
public bool X;
public bool Y;
public bool A;
public bool B;
public bool LB;
public bool RB;
public bool LeftThumb;
public bool RightThumb;
public bool this[GamepadButtonFlags flags] => _buttonFlags.HasFlag(flags);
internal GameControllerStateButtons(GamepadButtonFlags flags)
{
_buttonFlags = flags;
X = flags.HasFlag(GamepadButtonFlags.X);
Y = flags.HasFlag(GamepadButtonFlags.Y);
A = flags.HasFlag(GamepadButtonFlags.A);
B = flags.HasFlag(GamepadButtonFlags.B);
LB = flags.HasFlag(GamepadButtonFlags.LeftShoulder);
RB = flags.HasFlag(GamepadButtonFlags.RightShoulder);
LeftThumb = flags.HasFlag(GamepadButtonFlags.LeftThumb);
RightThumb = flags.HasFlag(GamepadButtonFlags.RightThumb);
}
public override string ToString()
{
return $"X: {(X ? "1" : "0")}; Y: {(Y ? "1" : "0")}; A: {(A ? "1" : "0")}; B: {(B ? "1" : "0")}; LB: {(LB ? "1" : "0")}; RB: {(RB ? "1" : "0")}; LT: {(LeftThumb ? "1" : "0")}; RT: {(RightThumb ? "1" : "0")}";
}
}
}

View file

@ -0,0 +1,28 @@
using SharpDX.XInput;
namespace SM.Game.Controls
{
public struct GameControllerStateDPad
{
public static GameControllerStateDPad Default = new GameControllerStateDPad(GamepadButtonFlags.None);
public bool Up;
public bool Down;
public bool Left;
public bool Right;
internal GameControllerStateDPad(GamepadButtonFlags flags)
{
Up = flags.HasFlag(GamepadButtonFlags.DPadUp);
Down = flags.HasFlag(GamepadButtonFlags.DPadDown);
Left = flags.HasFlag(GamepadButtonFlags.DPadLeft);
Right = flags.HasFlag(GamepadButtonFlags.DPadRight);
}
public override string ToString()
{
return
$"Up: {(Up ? "1" : "0")}; Down: {(Down ? "1" : "0")}; Left: {(Left ? "1" : "0")}; Right: {(Right ? "1" : "0")};";
}
}
}

View file

@ -0,0 +1,21 @@
using OpenTK;
namespace SM.Game.Controls
{
public struct GameControllerStateThumbs
{
public static GameControllerStateThumbs Default = new GameControllerStateThumbs()
{Left = Vector2.Zero, Right = Vector2.Zero};
public Vector2 Left;
public Vector2 Right;
public bool PressedLeft;
public bool PressedRight;
public override string ToString()
{
return $"Left: ({Left.X}; {Left.Y}){(PressedLeft ? " Pressed" : "")}; Right: ({Right.X}; {Right.Y}){(PressedRight ? " Pressed" : "")}";
}
}
}

View file

@ -0,0 +1,14 @@
namespace SM.Game.Controls
{
public struct GameControllerStateTriggers
{
public static GameControllerStateTriggers Default = new GameControllerStateTriggers {Left = 0f, Right = 0f};
public float Left;
public float Right;
public override string ToString()
{
return $"Left: {Left}; Right: {Right}";
}
}
}

View file

@ -0,0 +1,32 @@
using System;
using OpenTK.Input;
namespace SM.Game.Controls
{
public class GameKeybind
{
public Func<GameKeybindContext, object> Keyboard;
public Func<GameKeybindContext, object> Controller;
public Func<GameKeybindContext, object> AI;
public Func<GameKeybindContext, object> this[GameKeybindActorType type]
{
get
{
switch (type)
{
case GameKeybindActorType.AI:
return AI;
case GameKeybindActorType.Keyboard:
return Keyboard;
break;
case GameKeybindActorType.Controller:
return Controller;
break;
default:
throw new ArgumentOutOfRangeException(nameof(type), type, null);
}
}
}
}
}

View file

@ -0,0 +1,90 @@
using System;
using System.Collections.Generic;
using OpenTK.Input;
namespace SM.Game.Controls
{
public enum GameKeybindActorType
{
AI,
Keyboard,
Controller
}
public struct GameKeybindActor
{
private GameKeybindActorType _type;
private GameController? _controller;
private GameKeybindHost _keybindHost;
public GameKeybindActorType Type => _type;
public GameController? Controller => _controller;
public object[] Parameter;
private GameKeybindActor(GameKeybindActorType type, GameController? controller)
{
_type = type;
_controller = controller;
_keybindHost = null;
Parameter = new object[0];
}
public void ConnectHost(GameKeybindHost host)
{
_keybindHost = host;
}
public ReturnType Get<ReturnType>(string name, params object[] param)
{
return (ReturnType) Get(name, param);
}
public object Get(string name, params object[] objects)
{
if (_keybindHost == null) return null;
if (!_keybindHost._actions.ContainsKey(name)) return null;
GameKeybind keybind = _keybindHost._actions[name];
GameKeybindContext context = new GameKeybindContext()
{
Actor = this,
Host = _keybindHost,
ActorParameter = Parameter,
InstanceParameter = objects,
KeyboardState = Keyboard.GetState(),
MouseState = Mouse.GetState(),
ControllerState = Controller?.GetState(),
};
return keybind[Type].Invoke(context);
}
public static GameKeybindActor CreateAIActor()
{
return new GameKeybindActor(GameKeybindActorType.AI, null);
}
public static GameKeybindActor CreateKeyboardActor()
{
return new GameKeybindActor(GameKeybindActorType.Keyboard, null);
}
public static GameKeybindActor CreateControllerActor(int id)
{
return CreateControllerActor(new GameController(id));
}
public static GameKeybindActor CreateControllerActor(GameController controller)
{
return new GameKeybindActor(GameKeybindActorType.Controller, controller);
}
}
}

View file

@ -0,0 +1,17 @@
using OpenTK.Input;
namespace SM.Game.Controls
{
public struct GameKeybindContext
{
public KeyboardState KeyboardState;
public MouseState MouseState;
public GameControllerState? ControllerState;
public GameKeybindActor Actor;
public GameKeybindHost Host;
public object[] InstanceParameter;
public object[] ActorParameter;
}
}

View file

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using OpenTK.Input;
namespace SM.Game.Controls
{
public class GameKeybindHost
{
internal Dictionary<string, GameKeybind> _actions = new Dictionary<string, GameKeybind>();
public GameKeybindHost()
{ }
public GameKeybindHost(GameKeybindList setup)
{
for (int i = 0; i < setup.Count; i++)
{
_actions[setup[i].Key] = setup[i].Value;
}
}
public void Setup(string name, Func<GameKeybindContext, object> keyboard = null, Func<GameKeybindContext, object> gameController = null, Func<GameKeybindContext, object> ai = null)
{
GameKeybind bind;
if (_actions.ContainsKey(name))
{
bind = _actions[name];
}
else
{
bind = new GameKeybind();
_actions.Add(name, bind);
}
bind.Keyboard = keyboard;
bind.Controller = gameController;
bind.AI = ai;
}
}
}

View file

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using OpenTK.Input;
namespace SM.Game.Controls
{
public class GameKeybindList : List<KeyValuePair<string, GameKeybind>>
{
public void Add(string name, GameKeybind keybind)
{
Add(new KeyValuePair<string, GameKeybind>(name, keybind));
}
public void Add(string name, Func<GameKeybindContext, object> keyboard = null,
Func<GameKeybindContext, object> controller = null)
{
Add(new KeyValuePair<string, GameKeybind>(name, new GameKeybind()
{
AI = null,
Controller = controller,
Keyboard = keyboard
}));
}
}
}

View file

@ -0,0 +1,25 @@
<configuration>
<dllmap os="linux" dll="opengl32.dll" target="libGL.so.1"/>
<dllmap os="linux" dll="glu32.dll" target="libGLU.so.1"/>
<dllmap os="linux" dll="openal32.dll" target="libopenal.so.1"/>
<dllmap os="linux" dll="alut.dll" target="libalut.so.0"/>
<dllmap os="linux" dll="opencl.dll" target="libOpenCL.so"/>
<dllmap os="linux" dll="libX11" target="libX11.so.6"/>
<dllmap os="linux" dll="libXi" target="libXi.so.6"/>
<dllmap os="linux" dll="SDL2.dll" target="libSDL2-2.0.so.0"/>
<dllmap os="osx" dll="opengl32.dll" target="/System/Library/Frameworks/OpenGL.framework/OpenGL"/>
<dllmap os="osx" dll="openal32.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
<dllmap os="osx" dll="alut.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
<dllmap os="osx" dll="libGLES.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
<dllmap os="osx" dll="libGLESv1_CM.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
<dllmap os="osx" dll="libGLESv2.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
<dllmap os="osx" dll="opencl.dll" target="/System/Library/Frameworks/OpenCL.framework/OpenCL"/>
<dllmap os="osx" dll="SDL2.dll" target="libSDL2.dylib"/>
<!-- XQuartz compatibility (X11 on Mac) -->
<dllmap os="osx" dll="libGL.so.1" target="/usr/X11/lib/libGL.dylib"/>
<dllmap os="osx" dll="libX11" target="/usr/X11/lib/libX11.dylib"/>
<dllmap os="osx" dll="libXcursor.so.1" target="/usr/X11/lib/libXcursor.dylib"/>
<dllmap os="osx" dll="libXi" target="/usr/X11/lib/libXi.dylib"/>
<dllmap os="osx" dll="libXinerama" target="/usr/X11/lib/libXinerama.dylib"/>
<dllmap os="osx" dll="libXrandr.so.2" target="/usr/X11/lib/libXrandr.dylib"/>
</configuration>

View file

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SM.Game")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SM.Game")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("079bab31-3dc4-40da-90c7-efaa8517c647")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{079BAB31-3DC4-40DA-90C7-EFAA8517C647}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SM.Game</RootNamespace>
<AssemblyName>SM.Game</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="OpenTK, Version=3.3.1.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<HintPath>..\..\packages\OpenTK.3.3.1\lib\net20\OpenTK.dll</HintPath>
</Reference>
<Reference Include="SharpDX, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\..\packages\SharpDX.4.2.0\lib\net45\SharpDX.dll</HintPath>
</Reference>
<Reference Include="SharpDX.XInput, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\..\packages\SharpDX.XInput.4.2.0\lib\net45\SharpDX.XInput.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Controls\GameController.cs" />
<Compile Include="Controls\GameControllerState.cs" />
<Compile Include="Controls\GameControllerStateButtons.cs" />
<Compile Include="Controls\GameControllerStateDPad.cs" />
<Compile Include="Controls\GameControllerStateThumbs.cs" />
<Compile Include="Controls\GameControllerStateTriggers.cs" />
<Compile Include="Controls\GameKeybind.cs" />
<Compile Include="Controls\GameKeybindActor.cs" />
<Compile Include="Controls\GameKeybindContext.cs" />
<Compile Include="Controls\GameKeybindHost.cs" />
<Compile Include="Controls\GameKeybindList.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="OpenTK.dll.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="OpenTK" version="3.3.1" targetFramework="net452" />
<package id="SharpDX" version="4.2.0" targetFramework="net452" />
<package id="SharpDX.XInput" version="4.2.0" targetFramework="net452" />
</packages>

View file

@ -15,6 +15,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM2D", "SMCode\SM2D\SM2D.cs
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM_TEST", "SM_TEST\SM_TEST.csproj", "{6D4FB8E6-4D0B-4928-8F9E-EF5C2FBF44E8}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM_TEST", "SM_TEST\SM_TEST.csproj", "{6D4FB8E6-4D0B-4928-8F9E-EF5C2FBF44E8}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Optionals", "Optionals", "{AE5B181B-BD8F-4F36-A64E-32C4FF7B6FD6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM.Game", "SMOptionals\SM.Game\SM.Game.csproj", "{079BAB31-3DC4-40DA-90C7-EFAA8517C647}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM_WPF_TEST", "SM_WPF_TEST\SM_WPF_TEST.csproj", "{6F5367D3-B7E9-40CE-A692-29F9892B6F2A}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -41,6 +47,14 @@ Global
{6D4FB8E6-4D0B-4928-8F9E-EF5C2FBF44E8}.Debug|Any CPU.Build.0 = Debug|Any CPU {6D4FB8E6-4D0B-4928-8F9E-EF5C2FBF44E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D4FB8E6-4D0B-4928-8F9E-EF5C2FBF44E8}.Release|Any CPU.ActiveCfg = Release|Any CPU {6D4FB8E6-4D0B-4928-8F9E-EF5C2FBF44E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D4FB8E6-4D0B-4928-8F9E-EF5C2FBF44E8}.Release|Any CPU.Build.0 = Release|Any CPU {6D4FB8E6-4D0B-4928-8F9E-EF5C2FBF44E8}.Release|Any CPU.Build.0 = Release|Any CPU
{079BAB31-3DC4-40DA-90C7-EFAA8517C647}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{079BAB31-3DC4-40DA-90C7-EFAA8517C647}.Debug|Any CPU.Build.0 = Debug|Any CPU
{079BAB31-3DC4-40DA-90C7-EFAA8517C647}.Release|Any CPU.ActiveCfg = Release|Any CPU
{079BAB31-3DC4-40DA-90C7-EFAA8517C647}.Release|Any CPU.Build.0 = Release|Any CPU
{6F5367D3-B7E9-40CE-A692-29F9892B6F2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6F5367D3-B7E9-40CE-A692-29F9892B6F2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6F5367D3-B7E9-40CE-A692-29F9892B6F2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6F5367D3-B7E9-40CE-A692-29F9892B6F2A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -50,6 +64,7 @@ Global
{8E733844-4204-43E7-B3DC-3913CDDABB0D} = {47EA2879-1D40-4683-BA6C-AB51F286EBDE} {8E733844-4204-43E7-B3DC-3913CDDABB0D} = {47EA2879-1D40-4683-BA6C-AB51F286EBDE}
{9BECA849-E6E9-4E15-83A6-ADD8C18065CB} = {47EA2879-1D40-4683-BA6C-AB51F286EBDE} {9BECA849-E6E9-4E15-83A6-ADD8C18065CB} = {47EA2879-1D40-4683-BA6C-AB51F286EBDE}
{A4565538-625A-42C6-A330-DD4F1ABB3986} = {47EA2879-1D40-4683-BA6C-AB51F286EBDE} {A4565538-625A-42C6-A330-DD4F1ABB3986} = {47EA2879-1D40-4683-BA6C-AB51F286EBDE}
{079BAB31-3DC4-40DA-90C7-EFAA8517C647} = {AE5B181B-BD8F-4F36-A64E-32C4FF7B6FD6}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {51C827AB-3306-4EE6-9E60-B7BF84854469} SolutionGuid = {51C827AB-3306-4EE6-9E60-B7BF84854469}

View file

@ -1,21 +1,10 @@
using System; using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Security.Authentication.ExtendedProtection.Configuration;
using OpenTK; using OpenTK;
using OpenTK.Graphics;
using OpenTK.Input; using OpenTK.Input;
using SM.Base; using SM.Base;
using SM.Base.Scene; using SM.Game.Controls;
using SM.Base.Textures;
using SM.Base.Time;
using SM.Utility;
using SM2D; using SM2D;
using SM2D.Drawing; using SM2D.Drawing;
using SM2D.Object;
using SM2D.Pipelines;
using SM2D.Scene; using SM2D.Scene;
using Font = SM.Base.Drawing.Text.Font; using Font = SM.Base.Drawing.Text.Font;
using Vector2 = OpenTK.Vector2; using Vector2 = OpenTK.Vector2;
@ -36,7 +25,7 @@ namespace SM_TEST
Log.SetLogFile(compressionFolder:"logs"); Log.SetLogFile(compressionFolder:"logs");
window = new GLWindow2D {Scaling = new Vector2(0, 1000)}; window = new GLWindow2D {Scaling = new Vector2(0, 1000), VSync = VSyncMode.Off};
//window.GrabCursor(); //window.GrabCursor();
window.SetRenderPipeline(new TestRenderPipeline()); window.SetRenderPipeline(new TestRenderPipeline());
window.SetScene(scene = new Scene()); window.SetScene(scene = new Scene());
@ -51,6 +40,9 @@ namespace SM_TEST
if (Keyboard.GetState()[Key.R]) if (Keyboard.GetState()[Key.R])
particles.Trigger(); particles.Trigger();
//particles.Paused = Keyboard.GetState()[Key.P]; //particles.Paused = Keyboard.GetState()[Key.P];
GameControllerState s1 = new GameController(0).GetState();
GameControllerState s2 = new GameController(1).GetState();
} }
private static void WindowOnLoad(object sender, EventArgs e) private static void WindowOnLoad(object sender, EventArgs e)

View file

@ -33,8 +33,14 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="OpenTK, Version=3.2.1.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL"> <Reference Include="OpenTK, Version=3.3.1.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<HintPath>..\packages\OpenTK.3.2.1\lib\net20\OpenTK.dll</HintPath> <HintPath>..\packages\OpenTK.3.3.1\lib\net20\OpenTK.dll</HintPath>
</Reference>
<Reference Include="SharpDX, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\packages\SharpDX.4.2.0\lib\net45\SharpDX.dll</HintPath>
</Reference>
<Reference Include="SharpDX.XInput, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\packages\SharpDX.XInput.4.2.0\lib\net45\SharpDX.XInput.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
@ -69,6 +75,10 @@
<Project>{a4565538-625a-42c6-a330-dd4f1abb3986}</Project> <Project>{a4565538-625a-42c6-a330-dd4f1abb3986}</Project>
<Name>SM2D</Name> <Name>SM2D</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\SMOptionals\SM.Game\SM.Game.csproj">
<Project>{079bab31-3dc4-40da-90c7-efaa8517c647}</Project>
<Name>SM.Game</Name>
</ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>

View file

@ -1,4 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="OpenTK" version="3.2.1" targetFramework="net452" /> <package id="OpenTK" version="3.3.1" targetFramework="net452" />
<package id="SharpDX" version="4.2.0" targetFramework="net452" />
<package id="SharpDX.XInput" version="4.2.0" targetFramework="net452" />
</packages> </packages>

6
SM_WPF_TEST/App.config Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>

9
SM_WPF_TEST/App.xaml Normal file
View file

@ -0,0 +1,9 @@
<Application x:Class="SM_WPF_TEST.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:SM_WPF_TEST"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

17
SM_WPF_TEST/App.xaml.cs Normal file
View file

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace SM_WPF_TEST
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

View file

@ -0,0 +1,16 @@
<Window x:Class="SM_WPF_TEST.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SM_WPF_TEST"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid Name="grid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Label Content="WPF WITH SM-RENDERER" />
</Grid>
</Window>

View file

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using OpenTK.Graphics;
using SM2D;
using SM2D.Drawing;
using SM2D.Scene;
namespace SM_WPF_TEST
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
GLWPFWindow2D gl;
Scene scene;
gl = new GLWPFWindow2D();
Grid.SetColumn(gl, 1);
grid.Children.Add(gl);
gl.Start();
gl.SetScene(scene = new Scene());
DrawObject2D cube = new DrawObject2D();
cube.Color = Color4.Blue;
scene.Objects.Add(cube);
}
}
}

View file

@ -0,0 +1,25 @@
<configuration>
<dllmap os="linux" dll="opengl32.dll" target="libGL.so.1"/>
<dllmap os="linux" dll="glu32.dll" target="libGLU.so.1"/>
<dllmap os="linux" dll="openal32.dll" target="libopenal.so.1"/>
<dllmap os="linux" dll="alut.dll" target="libalut.so.0"/>
<dllmap os="linux" dll="opencl.dll" target="libOpenCL.so"/>
<dllmap os="linux" dll="libX11" target="libX11.so.6"/>
<dllmap os="linux" dll="libXi" target="libXi.so.6"/>
<dllmap os="linux" dll="SDL2.dll" target="libSDL2-2.0.so.0"/>
<dllmap os="osx" dll="opengl32.dll" target="/System/Library/Frameworks/OpenGL.framework/OpenGL"/>
<dllmap os="osx" dll="openal32.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
<dllmap os="osx" dll="alut.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
<dllmap os="osx" dll="libGLES.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
<dllmap os="osx" dll="libGLESv1_CM.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
<dllmap os="osx" dll="libGLESv2.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
<dllmap os="osx" dll="opencl.dll" target="/System/Library/Frameworks/OpenCL.framework/OpenCL"/>
<dllmap os="osx" dll="SDL2.dll" target="libSDL2.dylib"/>
<!-- XQuartz compatibility (X11 on Mac) -->
<dllmap os="osx" dll="libGL.so.1" target="/usr/X11/lib/libGL.dylib"/>
<dllmap os="osx" dll="libX11" target="/usr/X11/lib/libX11.dylib"/>
<dllmap os="osx" dll="libXcursor.so.1" target="/usr/X11/lib/libXcursor.dylib"/>
<dllmap os="osx" dll="libXi" target="/usr/X11/lib/libXi.dylib"/>
<dllmap os="osx" dll="libXinerama" target="/usr/X11/lib/libXinerama.dylib"/>
<dllmap os="osx" dll="libXrandr.so.2" target="/usr/X11/lib/libXrandr.dylib"/>
</configuration>

View file

@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SM_WPF_TEST")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SM_WPF_TEST")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,70 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace SM_WPF_TEST.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SM_WPF_TEST.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

View file

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -0,0 +1,29 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace SM_WPF_TEST.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View file

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View file

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{6F5367D3-B7E9-40CE-A692-29F9892B6F2A}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>SM_WPF_TEST</RootNamespace>
<AssemblyName>SM_WPF_TEST</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="GLWpfControl, Version=3.2.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OpenTK.GLWpfControl.3.2.3\lib\net452\GLWpfControl.dll</HintPath>
</Reference>
<Reference Include="OpenTK, Version=3.3.1.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<HintPath>..\packages\OpenTK.3.3.1\lib\net20\OpenTK.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="OpenTK.dll.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SMCode\SM.Base\SM.Base.csproj">
<Project>{8e733844-4204-43e7-b3dc-3913cddabb0d}</Project>
<Name>SM.Base</Name>
</ProjectReference>
<ProjectReference Include="..\SMCode\SM.OGL\SM.OGL.csproj">
<Project>{f604d684-bc1d-4819-88b5-8b5d03a17be0}</Project>
<Name>SM.OGL</Name>
</ProjectReference>
<ProjectReference Include="..\SMCode\SM2D\SM2D.csproj">
<Project>{a4565538-625a-42c6-a330-dd4f1abb3986}</Project>
<Name>SM2D</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="OpenTK" version="3.3.1" targetFramework="net452" />
<package id="OpenTK.GLWpfControl" version="3.2.3" targetFramework="net452" />
</packages>