17.01.2021
+ WPF-Support + Game Controller System + GameKeybind System + SM_WPF_TEST
This commit is contained in:
parent
af90d617d3
commit
6f23a80f7f
60 changed files with 1536 additions and 143 deletions
|
|
@ -10,9 +10,9 @@ using SM2D.Types;
|
|||
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace SM2D.Pipelines
|
|||
|
||||
}
|
||||
|
||||
protected override void Initialization(GenericWindow window)
|
||||
protected override void Initialization(IGenericWindow window)
|
||||
{
|
||||
MainFramebuffer = CreateWindowFramebuffer();
|
||||
}
|
||||
|
|
@ -31,13 +31,10 @@ namespace SM2D.Pipelines
|
|||
{
|
||||
if (scene != null)
|
||||
{
|
||||
MainFramebuffer.Activate(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
|
||||
scene.DrawBackground(context);
|
||||
|
||||
scene.DrawMainObjects(context);
|
||||
|
||||
Framebuffer.Screen.Activate();
|
||||
|
||||
scene.DrawHUD(context);
|
||||
scene.DrawDebug(context);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,12 +31,13 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="OpenTK, Version=3.2.1.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\OpenTK.3.2.1\lib\net20\OpenTK.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Xaml" />
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Controls\Mouse2D.cs" />
|
||||
|
|
@ -44,7 +45,8 @@
|
|||
<Compile Include="Drawing\DrawObject2D.cs" />
|
||||
<Compile Include="Drawing\DrawParticles.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\PolygonVertex.cs" />
|
||||
<Compile Include="Pipelines\Adv2DPipeline.cs" />
|
||||
|
|
@ -58,6 +60,7 @@
|
|||
<Compile Include="Shader\Basic2DShader.cs" />
|
||||
<Compile Include="Shader\Default2DShader.cs" />
|
||||
<Compile Include="Types\Transformation.cs" />
|
||||
<Compile Include="Window\IGLWindow2D.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SM.Base\SM.Base.csproj">
|
||||
|
|
@ -74,11 +77,15 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="OpenTK">
|
||||
<Version>3.2.1</Version>
|
||||
<Version>3.3.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="OpenTK.GLWpfControl">
|
||||
<Version>3.2.3</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Shader\ShaderFiles\basic.glsl" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
|
|
@ -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">
|
||||
<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>
|
||||
|
|
@ -18,7 +18,6 @@ namespace SM2D.Shader
|
|||
|
||||
private Default2DShader() : base(AssemblyUtility.ReadAssemblyFile("SM2D.Shader.ShaderFiles.default.glsl"))
|
||||
{
|
||||
Load();
|
||||
}
|
||||
|
||||
protected override void DrawProcess(DrawContext context)
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ namespace SM2D.Types
|
|||
{
|
||||
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();
|
||||
return vec.Xy;
|
||||
}
|
||||
|
|
|
|||
48
SMCode/SM2D/Window/GLWPFWindow2D.cs
Normal file
48
SMCode/SM2D/Window/GLWPFWindow2D.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@ using SM2D.Shader;
|
|||
|
||||
namespace SM2D
|
||||
{
|
||||
public class GLWindow2D : GenericWindow<Scene.Scene, Camera>
|
||||
public class GLWindow2D : GenericWindow<Scene.Scene, Camera>, IGLWindow2D
|
||||
{
|
||||
public GLWindow2D()
|
||||
{
|
||||
|
|
@ -22,7 +22,6 @@ namespace SM2D
|
|||
}
|
||||
|
||||
public Vector2? Scaling { get; set; }
|
||||
public Vector2 WorldScale => _worldScale;
|
||||
|
||||
public Mouse2D Mouse { get; }
|
||||
|
||||
|
|
@ -47,13 +46,13 @@ namespace SM2D
|
|||
base.OnRenderFrame(e);
|
||||
}
|
||||
|
||||
protected override void SetWorldScale()
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
14
SMCode/SM2D/Window/IGLWindow2D.cs
Normal file
14
SMCode/SM2D/Window/IGLWindow2D.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue