16.09.2020

~ Fixed shading import
~ Fixed "Plate" mesh
~ Move the dll files into "SMCode"
This commit is contained in:
Michel Fedde 2020-09-16 19:12:53 +02:00
parent 421d03f91d
commit 9889366317
27 changed files with 30 additions and 17 deletions

View file

@ -1,6 +1,7 @@
using System;
using System.IO;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL4;
using SM.OGL.Shaders;
@ -11,10 +12,15 @@ namespace SM.Base
private TestShader shader;
private Matrix4 _viewMatrix;
public GenericWindow() : base(1280, 720, GraphicsMode.Default, "Testing", GameWindowFlags.Default, DisplayDevice.Default, 0, 0, GraphicsContextFlags.Default, null, true)
{
}
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 = new TestShader(new ShaderFileCollection(File.ReadAllText("test/test.vert"), File.ReadAllText("test/test.frag")));
shader.Compile();
}
@ -22,8 +28,11 @@ namespace SM.Base
{
base.OnRenderFrame(e);
shader.Draw();
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
shader.Draw(_viewMatrix);
SwapBuffers();
}
protected override void OnResize(EventArgs e)
@ -31,8 +40,8 @@ namespace SM.Base
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);
_viewMatrix = Matrix4.LookAt(Vector3.UnitZ, Vector3.Zero, Vector3.UnitY) *
Matrix4.CreatePerspectiveFieldOfView(MathHelper.DegreesToRadians(90), Width / Height, 0.1f, 100);
}
}
}

View file

@ -55,7 +55,7 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SM.Core\SM.OGL.csproj">
<ProjectReference Include="..\SM.OGL\SM.OGL.csproj">
<Project>{f604d684-bc1d-4819-88b5-8b5d03a17be0}</Project>
<Name>SM.OGL</Name>
</ProjectReference>

View file

@ -13,6 +13,8 @@ namespace SM.Base.StaticObjects
{-.5f, .5f, 0},
{.5f, .5f, 0},
{.5f, -.5f, 0},
{0,0,0},
{0,0,0},
};
public override PrimitiveType PrimitiveType { get; } = PrimitiveType.Quads;

View file

@ -1,4 +1,5 @@
using OpenTK.Graphics.OpenGL4;
using OpenTK;
using OpenTK.Graphics.OpenGL4;
using SM.Base.StaticObjects;
using SM.OGL.Shaders;
@ -10,11 +11,11 @@ namespace SM.Base
{
}
public void Draw()
public void Draw(Matrix4 mvp)
{
GL.UseProgram(this);
Uniforms["MVP"].SetMatrix4(mvp);
DrawObject(Plate.Object, true);

View file

@ -41,7 +41,7 @@ namespace SM.OGL.Shaders
}
public void DrawObject(Mesh.Mesh mesh, bool bindVAO)
public void DrawObject(Mesh.Mesh mesh, bool bindVAO = false)
{
if (bindVAO) GL.BindVertexArray(mesh);
GL.DrawArrays(mesh.PrimitiveType, 0, mesh.Vertex.Count);

View file

@ -34,7 +34,7 @@ namespace SM.OGL.Shaders
GL.ShaderSource(_id, _data);
GL.CompileShader(_id);
}
GL.AttachShader(_id, shader);
GL.AttachShader(shader, _id);
}
}
}

View file

@ -1,4 +1,5 @@
using OpenTK.Graphics.OpenGL4;
using System.Collections.Generic;
using OpenTK.Graphics.OpenGL4;
namespace SM.OGL.Shaders
{

View file

@ -5,13 +5,13 @@ VisualStudioVersion = 16.0.30413.136
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SMRenderer", "SMRenderer", "{47EA2879-1D40-4683-BA6C-AB51F286EBDE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM.OGL", "SM.Core\SM.OGL.csproj", "{F604D684-BC1D-4819-88B5-8B5D03A17BE0}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM.OGL", "SMCode\SM.OGL\SM.OGL.csproj", "{F604D684-BC1D-4819-88B5-8B5D03A17BE0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM.Base", "SM.Base\SM.Base.csproj", "{8E733844-4204-43E7-B3DC-3913CDDABB0D}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM.Base", "SMCode\SM.Base\SM.Base.csproj", "{8E733844-4204-43E7-B3DC-3913CDDABB0D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM3D", "SM3D\SM3D.csproj", "{9BECA849-E6E9-4E15-83A6-ADD8C18065CB}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM3D", "SMCode\SM3D\SM3D.csproj", "{9BECA849-E6E9-4E15-83A6-ADD8C18065CB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM2D", "SM2D\SM2D.csproj", "{A4565538-625A-42C6-A330-DD4F1ABB3986}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM2D", "SMCode\SM2D\SM2D.csproj", "{A4565538-625A-42C6-A330-DD4F1ABB3986}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM_TEST", "SM_TEST\SM_TEST.csproj", "{6D4FB8E6-4D0B-4928-8F9E-EF5C2FBF44E8}"
EndProject

View file

@ -55,11 +55,11 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SM.Base\SM.Base.csproj">
<ProjectReference Include="..\SMCode\SM.Base\SM.Base.csproj">
<Project>{8e733844-4204-43e7-b3dc-3913cddabb0d}</Project>
<Name>SM.Base</Name>
</ProjectReference>
<ProjectReference Include="..\SM.Core\SM.OGL.csproj">
<ProjectReference Include="..\SMCode\SM.OGL\SM.OGL.csproj">
<Project>{f604d684-bc1d-4819-88b5-8b5d03a17be0}</Project>
<Name>SM.OGL</Name>
</ProjectReference>