Skip to content

Commit

Permalink
refactor game initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
LeNitrous committed Jul 27, 2023
1 parent cc466fe commit fc98797
Show file tree
Hide file tree
Showing 91 changed files with 2,246 additions and 2,739 deletions.
21 changes: 7 additions & 14 deletions Sekai.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleGame", "samples\Sampl
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sekai", "source\Sekai\Sekai.csproj", "{160AE02F-F9F2-461E-9F7F-EDE78D56ECCB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sekai.Desktop", "source\Sekai.Desktop\Sekai.Desktop.csproj", "{D992F8BC-ECD9-4BAA-9861-1A908FB85D2B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sekai.Headless", "source\Sekai.Headless\Sekai.Headless.csproj", "{39EF8073-809F-46D3-B14D-422880E5440F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sekai.OpenAL", "source\Sekai.OpenAL\Sekai.OpenAL.csproj", "{1C2DC723-C5DD-4AD8-BED8-AB0DE2360C75}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sekai.OpenGL", "source\Sekai.OpenGL\Sekai.OpenGL.csproj", "{F47079E6-4606-4991-81B7-D91FB0FDDD51}"
Expand All @@ -27,6 +23,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sekai.Graphics.Tests", "tes
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sekai.OpenGL.Tests", "tests\Sekai.OpenGL.Tests\Sekai.OpenGL.Tests.csproj", "{E7DBB11D-0308-4AF9-B83A-2E5822B28158}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sekai.GLFW", "source\Sekai.GLFW\Sekai.GLFW.csproj", "{FD32A2FE-75D3-4351-A22F-51342300C5BF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -57,14 +55,6 @@ Global
{4E665233-0AE5-4A70-A1A3-73330EA4D3A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E665233-0AE5-4A70-A1A3-73330EA4D3A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4E665233-0AE5-4A70-A1A3-73330EA4D3A7}.Release|Any CPU.Build.0 = Release|Any CPU
{D992F8BC-ECD9-4BAA-9861-1A908FB85D2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D992F8BC-ECD9-4BAA-9861-1A908FB85D2B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D992F8BC-ECD9-4BAA-9861-1A908FB85D2B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D992F8BC-ECD9-4BAA-9861-1A908FB85D2B}.Release|Any CPU.Build.0 = Release|Any CPU
{39EF8073-809F-46D3-B14D-422880E5440F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{39EF8073-809F-46D3-B14D-422880E5440F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{39EF8073-809F-46D3-B14D-422880E5440F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{39EF8073-809F-46D3-B14D-422880E5440F}.Release|Any CPU.Build.0 = Release|Any CPU
{1C2DC723-C5DD-4AD8-BED8-AB0DE2360C75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1C2DC723-C5DD-4AD8-BED8-AB0DE2360C75}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1C2DC723-C5DD-4AD8-BED8-AB0DE2360C75}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -85,20 +75,23 @@ Global
{E7DBB11D-0308-4AF9-B83A-2E5822B28158}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E7DBB11D-0308-4AF9-B83A-2E5822B28158}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E7DBB11D-0308-4AF9-B83A-2E5822B28158}.Release|Any CPU.Build.0 = Release|Any CPU
{FD32A2FE-75D3-4351-A22F-51342300C5BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FD32A2FE-75D3-4351-A22F-51342300C5BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FD32A2FE-75D3-4351-A22F-51342300C5BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FD32A2FE-75D3-4351-A22F-51342300C5BF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{630A50FA-9900-4066-BF8F-9A788690B96B} = {931CD6DD-07D5-47F9-9D1A-4321FFD5E900}
{160AE02F-F9F2-461E-9F7F-EDE78D56ECCB} = {11EBA343-73D5-4FC5-ADB9-2921D759C406}
{D992F8BC-ECD9-4BAA-9861-1A908FB85D2B} = {11EBA343-73D5-4FC5-ADB9-2921D759C406}
{39EF8073-809F-46D3-B14D-422880E5440F} = {11EBA343-73D5-4FC5-ADB9-2921D759C406}
{1C2DC723-C5DD-4AD8-BED8-AB0DE2360C75} = {11EBA343-73D5-4FC5-ADB9-2921D759C406}
{F47079E6-4606-4991-81B7-D91FB0FDDD51} = {11EBA343-73D5-4FC5-ADB9-2921D759C406}
{16938759-E0A6-48CF-8148-A696175B4186} = {AA2A0BAF-1A4D-4D5F-99E6-950849C75EAB}
{FBB0C86C-78AA-420F-A6B7-D4AB7A6D8201} = {AA2A0BAF-1A4D-4D5F-99E6-950849C75EAB}
{E7DBB11D-0308-4AF9-B83A-2E5822B28158} = {AA2A0BAF-1A4D-4D5F-99E6-950849C75EAB}
{FD32A2FE-75D3-4351-A22F-51342300C5BF} = {11EBA343-73D5-4FC5-ADB9-2921D759C406}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B6237647-4791-4690-81D9-284B3F1F63D2}
Expand Down
43 changes: 31 additions & 12 deletions samples/SampleGame/Program.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
// Copyright (c) Cosyne
// Licensed under MIT. See LICENSE for details.

using System;
using System.Numerics;
using Sekai;
using Sekai.GLFW;
using Sekai.Graphics;
using Sekai.Mathematics;
using Sekai.OpenAL;
using Sekai.OpenGL;

namespace SampleGame;

internal static class Program
{
private static void Main()
{
Host.Run<Sample>(new HostOptions { Name = "Sample" });
var options = new GameOptions();
options.UseOpenAL();
options.UseOpenGL();
options.Logger.AddConsole();

if (RuntimeInfo.IsDesktop)
{
options.UseGLFW();
options.Window.Title = "Sample";
}

var game = new Sample(options);
game.Run();
}
}

Expand All @@ -23,21 +37,19 @@ internal sealed class Sample : Game
private InputLayout? layout;
private GraphicsBuffer? vbo;

public override void Load()
public Sample(GameOptions options)
: base(options)
{
}

protected override void Load()
{
shd = Graphics.CreateShader
(
ShaderCode.From(shader_v_code, ShaderStage.Vertex),
ShaderCode.From(shader_f_code, ShaderStage.Fragment)
);

ReadOnlySpan<Vector2> vertices = stackalloc Vector2[]
{
new(-0.5f, -0.5f),
new(0.5f, -0.5f),
new(0.0f, 0.5f),
};

vbo = Graphics.CreateBuffer<Vector2>(BufferType.Vertex, (uint)vertices.Length);
vbo.SetData(vertices);

Expand All @@ -50,20 +62,27 @@ public override void Load()
);
}

public override void Draw()
protected override void Draw()
{
Graphics.Clear(Color.CornflowerBlue);
Graphics.SetShader(shd!);
Graphics.SetVertexBuffer(vbo!, layout!);
Graphics.Draw(PrimitiveType.TriangleList, 3);
}

public override void Unload()
protected override void Unload()
{
shd?.Dispose();
vbo?.Dispose();
}

private static readonly Vector2[] vertices = new Vector2[]
{
new(-0.5f, -0.5f),
new(0.5f, -0.5f),
new(0.0f, 0.5f),
};

private const string shader_v_code =
@"
#version 450
Expand Down
6 changes: 1 addition & 5 deletions samples/SampleGame/SampleGame.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
</PropertyGroup>

<ItemGroup>
<TrimmerRootDescriptor Include="TrimmerRoots.xml" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="../../source/Sekai.Desktop/Sekai.Desktop.csproj" />
<ProjectReference Include="../../source/Sekai.GLFW/Sekai.GLFW.csproj" />
<ProjectReference Include="../../source/Sekai.OpenAL/Sekai.OpenAL.csproj" />
<ProjectReference Include="../../source/Sekai.OpenGL/Sekai.OpenGL.csproj" />
</ItemGroup>
Expand Down
5 changes: 0 additions & 5 deletions samples/SampleGame/TrimmerRoots.xml

This file was deleted.

4 changes: 2 additions & 2 deletions source/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
<Title>Sekai</Title>
<Description>The rendering framework that powers Vignette.</Description>
<Authors>Cosyne</Authors>
<RepositoryUrl>https://github.com/vignetteapp/sekai.git</RepositoryUrl>
<RepositoryUrl>https://github.com/cosyneco/sekai.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<RepositoryBranch>main</RepositoryBranch>
<Copyright>Copyright (c) 2023 Cosyne</Copyright>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageProjectUrl>https://github.com/vignetteapp/sekai</PackageProjectUrl>
<PackageProjectUrl>https://github.com/cosyneco/sekai</PackageProjectUrl>
</PropertyGroup>
<ItemGroup>
<None Include="$(SolutionDir)LICENSE" Pack="True" PackagePath=""/>
Expand Down
6 changes: 2 additions & 4 deletions source/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ Sekai is structured where abstractions and concrete implementations as separate

- **`Sekai`**
- The main project.
- **`Sekai.Desktop`**
- The desktop platform implementation.
- **`Sekai.Headless`**
- The headless platform implementation.
- **`Sekai.GLFW`**
- The GLFW backed windowing subsystem.
- **`Sekai.OpenAL`**
- The OpenAL backed audio subsystem.
- **`Sekai.OpenGL`**
Expand Down
142 changes: 0 additions & 142 deletions source/Sekai.Desktop/DesktopPlatform.cs

This file was deleted.

20 changes: 0 additions & 20 deletions source/Sekai.Desktop/DesktopProvider.cs

This file was deleted.

12 changes: 0 additions & 12 deletions source/Sekai.Desktop/Input/IGLFWController.cs

This file was deleted.

Loading

0 comments on commit fc98797

Please sign in to comment.