15.09.2020

Everything currently don't work / can't be tested.

+ Generic Shader-Implermentation
+ Mesh-System + Plate-Mesh
This commit is contained in:
Michel Fedde 2020-09-15 22:16:18 +02:00
parent 551d393ac2
commit 421d03f91d
24 changed files with 726 additions and 4 deletions

38
SM.Base/GenericWindow.cs Normal file
View file

@ -0,0 +1,38 @@
using System;
using System.IO;
using OpenTK;
using OpenTK.Graphics.OpenGL4;
using SM.OGL.Shaders;
namespace SM.Base
{
public class GenericWindow : GameWindow
{
private TestShader shader;
private Matrix4 _viewMatrix;
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
shader = new TestShader(new ShaderFileCollection(File.ReadAllText("test/vert.glsl"), File.ReadAllText("test/frag.glsl")));
shader.Compile();
}
protected override void OnRenderFrame(FrameEventArgs e)
{
base.OnRenderFrame(e);
shader.Draw();
}
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
GL.Viewport(ClientRectangle);
_viewMatrix = Matrix4.CreatePerspectiveFieldOfView(90, Width / Height, 0.1f, 100) *
Matrix4.LookAt(new Vector3(2f, 1f, -5f), Vector3.Zero, Vector3.UnitY);
}
}
}

25
SM.Base/OpenTK.dll.config Normal file
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,8 +31,12 @@
<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.Drawing" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@ -41,7 +45,21 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="GenericWindow.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StaticObjects\Plate.cs" />
<Compile Include="TestShader.cs" />
</ItemGroup>
<ItemGroup>
<None Include="OpenTK.dll.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SM.Core\SM.OGL.csproj">
<Project>{f604d684-bc1d-4819-88b5-8b5d03a17be0}</Project>
<Name>SM.OGL</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View file

@ -0,0 +1,22 @@
using OpenTK.Graphics.OpenGL4;
using SM.OGL.Mesh;
namespace SM.Base.StaticObjects
{
public class Plate : Mesh
{
public static Plate Object = new Plate();
public override VBO Vertex { get; } = new VBO()
{
{-.5f, -.5f, 0},
{-.5f, .5f, 0},
{.5f, .5f, 0},
{.5f, -.5f, 0},
};
public override PrimitiveType PrimitiveType { get; } = PrimitiveType.Quads;
private Plate() {}
}
}

24
SM.Base/TestShader.cs Normal file
View file

@ -0,0 +1,24 @@
using OpenTK.Graphics.OpenGL4;
using SM.Base.StaticObjects;
using SM.OGL.Shaders;
namespace SM.Base
{
public class TestShader : GenericShader
{
public TestShader(ShaderFileCollection shaderFileFiles) : base(shaderFileFiles)
{
}
public void Draw()
{
GL.UseProgram(this);
DrawObject(Plate.Object, true);
GL.UseProgram(0);
}
}
}

4
SM.Base/packages.config Normal file
View file

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