Skip to content

Commit

Permalink
Upgrade to .NET7
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyrdacor committed Oct 12, 2023
1 parent 96d17d6 commit e80f1b6
Show file tree
Hide file tree
Showing 18 changed files with 140 additions and 120 deletions.
6 changes: 5 additions & 1 deletion Freeserf.Audio/Freeserf.Audio.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<Configurations>Debug;Release;MacDebug;MacRelease;WindowsRelease;WindowsDebug;LinuxRelease;LinuxDebug</Configurations>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
Expand Down Expand Up @@ -77,6 +77,10 @@
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Silk.NET.Input.Desktop" Version="1.9.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Freeserf.Core\Freeserf.Core.csproj" />
</ItemGroup>
Expand Down
5 changes: 3 additions & 2 deletions Freeserf.Core/Freeserf.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<RootNamespace>Freeserf</RootNamespace>
<Configurations>Debug;Release;MacDebug;MacRelease;WindowsRelease;WindowsDebug;LinuxRelease;LinuxDebug</Configurations>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand Down Expand Up @@ -82,7 +82,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
<PackageReference Include="Silk.NET.Input.Desktop" Version="1.9.0" />
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.7.0" />
</ItemGroup>

Expand Down
6 changes: 5 additions & 1 deletion Freeserf.Network/Freeserf.Network.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<Configurations>Debug;Release;MacDebug;MacRelease;WindowsRelease;WindowsDebug;LinuxRelease;LinuxDebug</Configurations>
</PropertyGroup>

Expand Down Expand Up @@ -51,6 +51,10 @@
<Optimize>false</Optimize>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Silk.NET.Input.Desktop" Version="1.9.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Freeserf.Core\Freeserf.Core.csproj" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Freeserf.Renderer/BaseLineBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ internal class BaseLineBuffer : BufferObject<ushort>

public override int Size => size;

public override VertexAttribPointerType Type => VertexAttribPointerType.Short;
public override VertexAttribIType Type => VertexAttribIType.Short;

public override int Dimension => 1;

Expand Down
2 changes: 1 addition & 1 deletion Freeserf.Renderer/BufferObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal abstract class BufferObject<T> : IDisposable
public abstract int Dimension { get; }
public bool Normalized { get; protected set; } = false;
public abstract int Size { get; }
public abstract VertexAttribPointerType Type { get; }
public abstract VertexAttribIType Type { get; }

public abstract void Dispose();

Expand Down
2 changes: 1 addition & 1 deletion Freeserf.Renderer/ColorBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ internal class ColorBuffer : BufferObject<byte>

public override int Size => size;

public override VertexAttribPointerType Type => VertexAttribPointerType.UnsignedByte;
public override VertexAttribIType Type => VertexAttribIType.UnsignedByte;

public override int Dimension => 4;

Expand Down
5 changes: 3 additions & 2 deletions Freeserf.Renderer/Freeserf.Renderer.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<Configurations>Debug;Release;MacDebug;MacRelease;WindowsRelease;WindowsDebug;LinuxRelease;LinuxDebug</Configurations>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
Expand Down Expand Up @@ -68,7 +68,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Silk.NET.OpenGL" Version="1.7.0" />
<PackageReference Include="Silk.NET.Input.Desktop" Version="1.9.0" />
<PackageReference Include="Silk.NET.OpenGL" Version="2.17.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Freeserf.Renderer/IndexBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ internal class IndexBuffer : BufferObject<uint>

public override int Size => size;

public override VertexAttribPointerType Type => VertexAttribPointerType.UnsignedInt;
public override VertexAttribIType Type => VertexAttribIType.UnsignedInt;

public override int Dimension => 6;

Expand Down
2 changes: 1 addition & 1 deletion Freeserf.Renderer/LayerBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ internal class LayerBuffer : BufferObject<ushort>

public override int Size => size;

public override VertexAttribPointerType Type => VertexAttribPointerType.UnsignedByte;
public override VertexAttribIType Type => VertexAttribIType.UnsignedByte;

public override int Dimension => 1;

Expand Down
2 changes: 1 addition & 1 deletion Freeserf.Renderer/PositionBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ internal class PositionBuffer : BufferObject<short>

public override int Size => size;

public override VertexAttribPointerType Type => VertexAttribPointerType.Short;
public override VertexAttribIType Type => VertexAttribIType.Short;

public override int Dimension => 2;

Expand Down
2 changes: 1 addition & 1 deletion Freeserf.Renderer/Shader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void Create()
GLEnum.FragmentShader :
GLEnum.VertexShader);

State.Gl.ShaderSource(ShaderIndex, 1, new string[] { code }, new Int32[] { code.Length });
State.Gl.ShaderSource(ShaderIndex, 1, new string[] { code }, code.Length);
State.Gl.CompileShader(ShaderIndex);

// Auf Fehler pr�fen
Expand Down
6 changes: 3 additions & 3 deletions Freeserf.Renderer/ShaderProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,13 @@ public void SetInputMatrix(string name, float[] matrix, bool transpose)
switch (matrix.Length)
{
case 4: // 2x2
State.Gl.ProgramUniformMatrix2(ProgramIndex, (int)location, 1, transpose, matrix);
State.Gl.ProgramUniformMatrix2(ProgramIndex, (int)location, transpose, matrix);
break;
case 9: // 3x3
State.Gl.ProgramUniformMatrix3(ProgramIndex, (int)location, 1, transpose, matrix);
State.Gl.ProgramUniformMatrix3(ProgramIndex, (int)location, transpose, matrix);
break;
case 16: // 4x4
State.Gl.ProgramUniformMatrix4(ProgramIndex, (int)location, 1, transpose, matrix);
State.Gl.ProgramUniformMatrix4(ProgramIndex, (int)location, transpose, matrix);
break;
default:
throw new InvalidOperationException("ShaderProgram.SetInputMatrix: Unsupported matrix dimensions. Valid are 2x2, 3x3 or 4x4.");
Expand Down
23 changes: 12 additions & 11 deletions Freeserf.Renderer/State.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* State.cs - OpenGL state
*
* Copyright (C) 2018-2019 Robert Schneckenhaus <[email protected]>
* Copyright (C) 2018-2023 Robert Schneckenhaus <[email protected]>
*
* This file is part of freeserf.net. freeserf.net is based on freeserf.
*
Expand All @@ -19,6 +19,7 @@
* along with freeserf.net. If not, see <http://www.gnu.org/licenses/>.
*/

using Silk.NET.Core.Contexts;
using Silk.NET.OpenGL;
using System;
using System.Collections.Generic;
Expand All @@ -28,19 +29,19 @@ namespace Freeserf.Renderer
{
public static class State
{
public static readonly int OpenGLVersionMajor = 0;
public static readonly int OpenGLVersionMinor = 0;
public static readonly int GLSLVersionMajor = 0;
public static readonly int GLSLVersionMinor = 0;
public static readonly GL Gl = null;
public static int OpenGLVersionMajor { get; private set; } = 0;
public static int OpenGLVersionMinor { get; private set; } = 0;
public static int GLSLVersionMajor { get; private set; } = 0;
public static int GLSLVersionMinor { get; private set; } = 0;
public static GL Gl { get; private set; } = null;

static State()
public static void Init(IGLContextSource contextSource)
{
Gl = GL.GetApi();
Gl = GL.GetApi(contextSource);

var openGLVersion = Gl.GetString(StringName.Version).TrimStart();
var openGLVersion = Gl.GetStringS(StringName.Version).TrimStart();

Regex versionRegex = new Regex(@"([0-9]+)\.([0-9]+)", RegexOptions.Compiled);
Regex versionRegex = new(@"([0-9]+)\.([0-9]+)", RegexOptions.Compiled);

var match = versionRegex.Match(openGLVersion);

Expand All @@ -54,7 +55,7 @@ static State()

if (OpenGLVersionMajor >= 2) // glsl is supported since OpenGL 2.0
{
var glslVersion = Gl.GetString(StringName.ShadingLanguageVersion);
var glslVersion = Gl.GetStringS(StringName.ShadingLanguageVersion);

match = versionRegex.Match(glslVersion);

Expand Down
14 changes: 9 additions & 5 deletions Freeserf.Test/Freeserf.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net7.0</TargetFramework>

<IsPackable>false</IsPackable>
<Configurations>Debug;Release;MacDebug;MacRelease;WindowsRelease;WindowsDebug;LinuxRelease;LinuxDebug</Configurations>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
<PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
<PackageReference Include="coverlet.collector" Version="1.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Silk.NET.Input.Desktop" Version="1.9.0" />
</ItemGroup>

<ItemGroup>
Expand Down
22 changes: 11 additions & 11 deletions FreeserfNet/FreeserfNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<Configurations>Debug;Release;MacDebug;MacRelease;WindowsRelease;WindowsDebug;LinuxRelease;LinuxDebug</Configurations>
</PropertyGroup>
Expand Down Expand Up @@ -74,18 +74,18 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="glfw" Version="3.3.2">
<PackageReference Include="glfw" Version="3.3.8">
<CopyToOutputDirectory>build\native\bin\dynamic\v142\x64\*</CopyToOutputDirectory>
</PackageReference>
<PackageReference Include="Silk.NET.Core" Version="1.7.0" />
<PackageReference Include="Silk.NET.GLFW" Version="1.7.0" />
<PackageReference Include="Silk.NET.Input" Version="1.7.0" />
<PackageReference Include="Silk.NET.Input.Common" Version="1.7.0" />
<PackageReference Include="Silk.NET.Input.Desktop" Version="1.7.0" />
<PackageReference Include="Silk.NET.OpenGL" Version="1.7.0" />
<PackageReference Include="Silk.NET.Windowing" Version="1.7.0" />
<PackageReference Include="Silk.NET.Windowing.Common" Version="1.7.0" />
<PackageReference Include="Silk.NET.Windowing.Desktop" Version="1.7.0" />
<PackageReference Include="Silk.NET.Core" Version="2.17.1" />
<PackageReference Include="Silk.NET.GLFW" Version="2.17.1" />
<PackageReference Include="Silk.NET.Input" Version="2.17.1" />
<PackageReference Include="Silk.NET.Input.Common" Version="2.17.1" />
<PackageReference Include="Silk.NET.Input.Desktop" Version="1.9.0" />
<PackageReference Include="Silk.NET.OpenGL" Version="2.17.1" />
<PackageReference Include="Silk.NET.Windowing" Version="2.17.1" />
<PackageReference Include="Silk.NET.Windowing.Common" Version="2.17.1" />
<PackageReference Include="Silk.NET.Windowing.Desktop" Version="1.9.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit e80f1b6

Please sign in to comment.