17.09.2020

+ Generic Scene
+ Generic Camera
+ Generic Window
+ Contexts for drawing and updateing

+ very basic 2D-implermention
This commit is contained in:
Michel Fedde 2020-09-17 21:28:16 +02:00
parent 9889366317
commit 589d131246
25 changed files with 383 additions and 78 deletions

View file

@ -0,0 +1,24 @@
using OpenTK;
using SM.Base.Contexts;
using SM.Base.Scene;
using SM.Base.Shader;
using SM.Base.StaticObjects;
using SM.OGL.Mesh;
namespace SM2D.Drawing
{
public class DrawEmpty : IShowItem
{
public void Update(UpdateContext context)
{
throw new System.NotImplementedException();
}
public void Draw(DrawContext context)
{
context.ModelMatrix = Matrix4.CreateScale(100, 100, 1);
Shaders.Default.Draw(context);
}
}
}

10
SMCode/SM2D/GLWindow2D.cs Normal file
View file

@ -0,0 +1,10 @@
using SM.Base;
using SM2D.Scene;
namespace SM2D
{
public class GLWindow2D : GenericWindow<Scene.Scene, Camera>
{
}
}

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

@ -31,6 +31,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="OpenTK, Version=3.2.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<HintPath>..\..\packages\OpenTK.3.2\lib\net20\OpenTK.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
@ -41,7 +44,26 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Drawing\DrawEmpty.cs" />
<Compile Include="GLWindow2D.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Scene\Camera.cs" />
<Compile Include="Scene\Scene.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SM.Base\SM.Base.csproj">
<Project>{8e733844-4204-43e7-b3dc-3913cddabb0d}</Project>
<Name>SM.Base</Name>
</ProjectReference>
<ProjectReference Include="..\SM.OGL\SM.OGL.csproj">
<Project>{f604d684-bc1d-4819-88b5-8b5d03a17be0}</Project>
<Name>SM.OGL</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="OpenTK.dll.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View file

@ -0,0 +1,22 @@
using OpenTK;
using SM.Base.Scene;
namespace SM2D.Scene
{
public class Camera : GenericCamera
{
public override bool Orthographic { get; } = true;
public Vector2 Position;
public override Matrix4 ViewCalculation()
{
return Matrix4.LookAt(Position.X, Position.Y, -1, Position.X, Position.Y, 0, 0, 1, 0);
}
public override void RecalculateWorld(float width, float height)
{
OrthographicWorld = Matrix4.CreateOrthographic(width, height, 0.1f, 100);
}
}
}

View file

@ -0,0 +1,9 @@
using SM.Base.Scene;
namespace SM2D.Scene
{
public class Scene : GenericScene<Camera>
{
}
}

View file

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