├── .github ├── funding.yml ├── linters │ └── .ecrc └── workflows │ ├── lint.yml │ ├── publish.yml │ └── test.yml ├── assets ├── logo-dark.png └── logo-light.png ├── Directory.Build.targets ├── samples ├── Directory.Build.props └── SampleGame │ ├── SampleGame.csproj │ └── Program.cs ├── .vscode ├── extensions.json ├── settings.json ├── launch.json └── tasks.json ├── source ├── Sekai.GLFW │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Sekai.GLFW.csproj │ ├── GLFWController.cs │ ├── GameOptionsExtensions.cs │ ├── GLFWMonitor.cs │ └── GLFWGamepad.cs ├── Sekai.OpenGL │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Sekai.OpenGL.csproj │ ├── GameOptionsExtensions.cs │ ├── GLInputLayout.cs │ ├── GLRasterizerState.cs │ ├── GLDepthStencilState.cs │ ├── GLFramebuffer.cs │ ├── GLBlendState.cs │ ├── GLShader.cs │ └── GLBuffer.cs ├── Sekai │ ├── Graphics │ │ ├── Framebuffer.cs │ │ ├── InputLayout.cs │ │ ├── DepthStencilState.cs │ │ ├── Shader.cs │ │ ├── FaceWinding.cs │ │ ├── FillMode.cs │ │ ├── InputType.cs │ │ ├── Swapchain.cs │ │ ├── FaceCulling.cs │ │ ├── ShaderLanguage.cs │ │ ├── MapMode.cs │ │ ├── TextureUsage.cs │ │ ├── IndexType.cs │ │ ├── TextureType.cs │ │ ├── ClearFlags.cs │ │ ├── TextureAddress.cs │ │ ├── BufferType.cs │ │ ├── RasterizerState.cs │ │ ├── BlendOperation.cs │ │ ├── ColorWriteMask.cs │ │ ├── ShaderStage.cs │ │ ├── GraphicsAPI.cs │ │ ├── ShaderConstantType.cs │ │ ├── StencilOperation.cs │ │ ├── Sampler.cs │ │ ├── PrimitiveType.cs │ │ ├── ComparisonKind.cs │ │ ├── TextureSampleCount.cs │ │ ├── BlendState.cs │ │ ├── TextureFilter.cs │ │ ├── FramebufferAttachment.cs │ │ ├── BlendType.cs │ │ ├── RasterizerStateDescription.cs │ │ ├── InputLayoutFormat.cs │ │ ├── GraphicsBufferView.cs │ │ ├── StencilBehaviorDescription.cs │ │ ├── ClearInfo.cs │ │ ├── ShaderConstant.cs │ │ ├── InputLayoutDescription.cs │ │ └── SamplerDescription.cs │ ├── Headless │ │ ├── DummyInputLayout.cs │ │ ├── HeadlessFramebuffer.cs │ │ ├── HeadlessDepthStencilState.cs │ │ ├── HeadlessRasterizerState.cs │ │ ├── HeadlessShader.cs │ │ ├── HeadlessAudioListener.cs │ │ ├── HeadlessAudioBuffer.cs │ │ ├── HeadlessBlendState.cs │ │ ├── HeadlessAudioDevice.cs │ │ ├── HeadlessSampler.cs │ │ ├── HeadlessAudioSource.cs │ │ ├── HeadlessGraphicsBuffer.cs │ │ ├── HeadlessView.cs │ │ └── HeadlessTexture.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Contexts │ │ ├── IGLContextSource.cs │ │ ├── INativeWindow.cs │ │ ├── NativeWindowKind.cs │ │ └── GLContext.cs │ ├── Windowing │ │ ├── IWindowHost.cs │ │ ├── VideoMode.cs │ │ ├── WindowBorder.cs │ │ ├── WindowState.cs │ │ ├── Monitor.cs │ │ ├── IView.cs │ │ ├── Icon.cs │ │ └── IWindow.cs │ ├── ExecutionMode.cs │ ├── Input │ │ ├── IInputDevice.cs │ │ ├── IPointer.cs │ │ ├── IKeyboard.cs │ │ ├── IMotor.cs │ │ ├── IInputSource.cs │ │ ├── IController.cs │ │ ├── IJoystick.cs │ │ ├── InputSource.cs │ │ ├── IGamepad.cs │ │ ├── IMouse.cs │ │ ├── HatPosition.cs │ │ ├── DeadzoneMethod.cs │ │ ├── ButtonName.cs │ │ ├── Hat.cs │ │ ├── Axis.cs │ │ ├── ScrollWheel.cs │ │ ├── Trigger.cs │ │ ├── MouseButton.cs │ │ ├── Thumbstick.cs │ │ ├── Deadzone.cs │ │ └── Button.cs │ ├── Sekai.csproj │ ├── Audio │ │ ├── AudioAPI.cs │ │ ├── AudioSourceState.cs │ │ ├── AudioListener.cs │ │ ├── ListenerOrientation.cs │ │ ├── AudioDevice.cs │ │ ├── AudioFormat.cs │ │ ├── AudioBuffer.cs │ │ └── AudioSource.cs │ ├── Mathematics │ │ ├── IColor.cs │ │ ├── Containment.cs │ │ ├── PlaneIntersection.cs │ │ ├── IMergeable.cs │ │ ├── IContainable.cs │ │ ├── IIntersectable.cs │ │ ├── IIntersectableWithRay.cs │ │ └── Corners.cs │ ├── TickMode.cs │ ├── Logging │ │ ├── LogWriterDebug.cs │ │ ├── LogWriterTrace.cs │ │ ├── LogWriter.cs │ │ ├── LogLevel.cs │ │ ├── LogWriterStream.cs │ │ ├── LogWriterJson.cs │ │ ├── LogWriterText.cs │ │ └── LogMessage.cs │ └── HotReload.cs ├── Sekai.OpenAL │ ├── GameOptionsExtensions.cs │ ├── Sekai.OpenAL.csproj │ ├── ALAudioListener.cs │ └── ALAudioBuffer.cs ├── README.md └── Directory.Build.props ├── tests ├── Sekai.Tests │ ├── Sekai.Tests.csproj │ └── Storages │ │ ├── MemoryStorageTest.cs │ │ └── NativeStorageTest.cs ├── Sekai.Graphics.Tests │ ├── GraphicsDeviceCreator.cs │ ├── Sekai.Graphics.Tests.csproj │ ├── GraphicsTest.cs │ ├── GraphicsBufferTest.cs │ └── TextureTest.cs ├── Sekai.OpenGL.Tests │ ├── Sekai.OpenGL.Tests.csproj │ ├── GLGraphicsTests.cs │ └── GLGraphicsDeviceCreator.cs └── Directory.Build.props ├── Directory.Build.props ├── analysis └── BannedSymbols.txt ├── .gitpod.dockerfile ├── .codespaces.dockerfile ├── LICENSE ├── .devcontainer └── devcontainer.json └── README.md /.github/funding.yml: -------------------------------------------------------------------------------- 1 | github: vignetteapp 2 | open_collective: vignette -------------------------------------------------------------------------------- /assets/logo-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LeNitrous/sekai/HEAD/assets/logo-dark.png -------------------------------------------------------------------------------- /assets/logo-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LeNitrous/sekai/HEAD/assets/logo-light.png -------------------------------------------------------------------------------- /Directory.Build.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | enable 4 | 5 | -------------------------------------------------------------------------------- /samples/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | false 4 | true 5 | true 6 | 7 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "ms-dotnettools.csharp", 4 | "editorconfig.editorconfig", 5 | "ryanluker.vscode-coverage-gutters", 6 | "formulahendry.dotnet-test-explorer" 7 | ] 8 | } -------------------------------------------------------------------------------- /source/Sekai.GLFW/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using System.Runtime.CompilerServices; 5 | 6 | [assembly: InternalsVisibleTo("Sekai.OpenGL.Tests")] 7 | -------------------------------------------------------------------------------- /source/Sekai.OpenGL/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using System.Runtime.CompilerServices; 5 | 6 | [assembly: InternalsVisibleTo("Sekai.OpenGL.Tests")] 7 | -------------------------------------------------------------------------------- /source/Sekai/Graphics/Framebuffer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using System; 5 | 6 | namespace Sekai.Graphics; 7 | 8 | public abstract class Framebuffer : IDisposable 9 | { 10 | public abstract void Dispose(); 11 | } 12 | -------------------------------------------------------------------------------- /source/Sekai/Graphics/InputLayout.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using System; 5 | 6 | namespace Sekai.Graphics; 7 | 8 | public abstract class InputLayout : IDisposable 9 | { 10 | public abstract void Dispose(); 11 | } 12 | -------------------------------------------------------------------------------- /source/Sekai/Graphics/DepthStencilState.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using System; 5 | 6 | namespace Sekai.Graphics; 7 | 8 | public abstract class DepthStencilState : IDisposable 9 | { 10 | public abstract void Dispose(); 11 | } 12 | -------------------------------------------------------------------------------- /tests/Sekai.Tests/Sekai.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /source/Sekai/Headless/DummyInputLayout.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using Sekai.Graphics; 5 | 6 | namespace Sekai.Headless; 7 | 8 | internal sealed class HeadlessInputLayout : InputLayout 9 | { 10 | public override void Dispose() 11 | { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /source/Sekai/Headless/HeadlessFramebuffer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using Sekai.Graphics; 5 | 6 | namespace Sekai.Headless; 7 | 8 | internal sealed class HeadlessFramebuffer : Framebuffer 9 | { 10 | public override void Dispose() 11 | { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /source/Sekai/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using System.Reflection.Metadata; 5 | using System.Runtime.CompilerServices; 6 | using Sekai; 7 | 8 | [assembly: InternalsVisibleTo("Sekai.Tests")] 9 | [assembly: MetadataUpdateHandler(typeof(HotReload))] 10 | -------------------------------------------------------------------------------- /source/Sekai/Headless/HeadlessDepthStencilState.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using Sekai.Graphics; 5 | 6 | namespace Sekai.Headless; 7 | 8 | internal sealed class HeadlessDepthStencilState : DepthStencilState 9 | { 10 | public override void Dispose() 11 | { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "coverage-gutters.coverageFileNames": [ 3 | "coverage.info", 4 | ], 5 | "dotnet-test-explorer.testProjectPath": "**/*Tests.@(csproj|vbproj|fsproj)", 6 | "dotnet-test-explorer.testArguments": "/p:IncludeTestAssembly=true /p:CollectCoverage=true /p:CoverletOutputFormat=lcov", 7 | "dotnet.defaultSolution": "Sekai.sln" 8 | } -------------------------------------------------------------------------------- /tests/Sekai.Graphics.Tests/GraphicsDeviceCreator.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using Sekai.Windowing; 5 | 6 | namespace Sekai.Graphics.Tests; 7 | 8 | public abstract class GraphicsDeviceCreator 9 | { 10 | public abstract IWindow CreateWindow(); 11 | public abstract GraphicsDevice CreateGraphics(IWindow window); 12 | } 13 | -------------------------------------------------------------------------------- /tests/Sekai.Graphics.Tests/Sekai.Graphics.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | true 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /tests/Sekai.Tests/Storages/MemoryStorageTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using Sekai.Storages; 5 | 6 | namespace Sekai.Tests.Storages; 7 | 8 | public class MemoryStorageTest : StorageTest 9 | { 10 | public MemoryStorageTest() 11 | { 12 | } 13 | 14 | protected override MemoryStorage CreateStorage() => new(); 15 | } 16 | -------------------------------------------------------------------------------- /source/Sekai/Contexts/IGLContextSource.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | namespace Sekai.Contexts; 5 | 6 | /// 7 | /// A context providing a . 8 | /// 9 | public interface IGLContextSource 10 | { 11 | /// 12 | /// The GL context. 13 | /// 14 | GLContext Context { get; } 15 | } 16 | -------------------------------------------------------------------------------- /source/Sekai/Contexts/INativeWindow.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | namespace Sekai.Contexts; 5 | 6 | /// 7 | /// A context providing a native window. 8 | /// 9 | public interface INativeWindow 10 | { 11 | /// 12 | /// The native window info. 13 | /// 14 | NativeWindowInfo Native { get; } 15 | } 16 | -------------------------------------------------------------------------------- /source/Sekai/Graphics/Shader.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using System; 5 | 6 | namespace Sekai.Graphics; 7 | 8 | public abstract class Shader : IDisposable 9 | { 10 | /// 11 | /// The stages this shader performs. 12 | /// 13 | public abstract ShaderStage Stages { get; } 14 | 15 | public abstract void Dispose(); 16 | } 17 | -------------------------------------------------------------------------------- /source/Sekai.GLFW/Sekai.GLFW.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /source/Sekai.OpenGL/Sekai.OpenGL.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | true 4 | true 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /source/Sekai/Windowing/IWindowHost.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | namespace Sekai.Windowing; 5 | 6 | /// 7 | /// An interface for objects capable of hosting other s. 8 | /// 9 | public interface IWindowHost 10 | { 11 | /// 12 | /// Creates a new window. 13 | /// 14 | IWindow CreateWindow(); 15 | } 16 | -------------------------------------------------------------------------------- /source/Sekai.OpenAL/GameOptionsExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | namespace Sekai.OpenAL; 5 | 6 | public static class GameOptionsExtensions 7 | { 8 | /// 9 | /// Use OpenAL as the audio provider. 10 | /// 11 | public static void UseOpenAL(this GameOptions options) 12 | { 13 | options.Audio.CreateDevice = static () => new ALAudioDevice(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /source/Sekai/Graphics/FaceWinding.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | namespace Sekai.Graphics; 5 | 6 | /// 7 | /// The winding order of vertices. 8 | /// 9 | public enum FaceWinding 10 | { 11 | /// 12 | /// Clockwise order. 13 | /// 14 | Clockwise, 15 | 16 | /// 17 | /// Counter clockwise order. 18 | /// 19 | CounterClockwise, 20 | } 21 | -------------------------------------------------------------------------------- /source/README.md: -------------------------------------------------------------------------------- 1 | # Project Structure 2 | 3 | Sekai is structured where abstractions and concrete implementations as separate projects. This allows development to be flexible and allows use of these projects to be used outside of Sekai itself. 4 | 5 | - **`Sekai`** 6 | - The main project. 7 | - **`Sekai.GLFW`** 8 | - The GLFW backed windowing subsystem. 9 | - **`Sekai.OpenAL`** 10 | - The OpenAL backed audio subsystem. 11 | - **`Sekai.OpenGL`** 12 | - The OpenGL backed graphics subsystem. -------------------------------------------------------------------------------- /source/Sekai/Graphics/FillMode.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | namespace Sekai.Graphics; 5 | 6 | /// 7 | /// Determines how primitives should be drawn. 8 | /// 9 | public enum FillMode 10 | { 11 | /// 12 | /// Primitives are completely filled. 13 | /// 14 | Solid, 15 | 16 | /// 17 | /// Primitives will be drawn in lines. 18 | /// 19 | Wireframe, 20 | } 21 | -------------------------------------------------------------------------------- /source/Sekai/Windowing/VideoMode.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using Sekai.Mathematics; 5 | 6 | namespace Sekai.Windowing; 7 | 8 | /// 9 | /// Information about a video mode for an . 10 | /// 11 | /// The video mode resolution. 12 | /// The video mode refresh rate. 13 | public readonly record struct VideoMode(Size Resolution, int RefreshRate); 14 | -------------------------------------------------------------------------------- /source/Sekai/ExecutionMode.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | namespace Sekai; 5 | 6 | /// 7 | /// An enumeration of execution modes. 8 | /// 9 | public enum ExecutionMode 10 | { 11 | /// 12 | /// Executes the game loop in a single thread. 13 | /// 14 | SingleThread, 15 | 16 | /// 17 | /// Executes the game loop in multiple threads. 18 | /// 19 | MultiThread, 20 | } 21 | -------------------------------------------------------------------------------- /source/Sekai/Input/IInputDevice.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | namespace Sekai.Input; 5 | 6 | /// 7 | /// Represents an input device. 8 | /// 9 | public interface IInputDevice 10 | { 11 | /// 12 | /// The device's name. 13 | /// 14 | string Name { get; } 15 | 16 | /// 17 | /// Whether this device is connected or not. 18 | /// 19 | bool IsConnected { get; } 20 | } 21 | -------------------------------------------------------------------------------- /source/Sekai/Sekai.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /.github/linters/.ecrc: -------------------------------------------------------------------------------- 1 | { 2 | "Verbose": false, 3 | "Debug": false, 4 | "IgnoreDefaults": false, 5 | "SpacesAftertabs": false, 6 | "NoColor": false, 7 | "Exclude": ["\\.exe$"], 8 | "AllowedContentTypes": [], 9 | "PassedFiles": [], 10 | "Disable": { 11 | "EndOfLine": false, 12 | "Indentation": false, 13 | "IndentSize": false, 14 | "InsertFinalNewline": false, 15 | "TrimTrailingWhitespace": false, 16 | "MaxLineLength": false 17 | } 18 | } -------------------------------------------------------------------------------- /tests/Sekai.OpenGL.Tests/Sekai.OpenGL.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /samples/SampleGame/SampleGame.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WinExe 5 | net7.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /source/Sekai/Graphics/InputType.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | namespace Sekai.Graphics; 5 | 6 | /// 7 | /// The type of an input layout element. 8 | /// 9 | public enum InputType 10 | { 11 | /// 12 | /// This input layout element is read per vertex. 13 | /// 14 | PerVertex, 15 | 16 | /// 17 | /// This input layout element is read per instance. 18 | /// 19 | PerInstance, 20 | } 21 | -------------------------------------------------------------------------------- /source/Sekai/Audio/AudioAPI.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | namespace Sekai.Audio; 5 | 6 | /// 7 | /// An enumeration of Audio APIs. 8 | /// 9 | public enum AudioAPI 10 | { 11 | /// 12 | /// Unknown. 13 | /// 14 | Unknown = 0, 15 | 16 | /// 17 | /// OpenAL. 18 | /// 19 | OpenAL, 20 | 21 | /// 22 | /// Dummy. 23 | /// 24 | Dummy = int.MaxValue, 25 | } 26 | -------------------------------------------------------------------------------- /source/Sekai/Graphics/Swapchain.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using System; 5 | using Sekai.Mathematics; 6 | 7 | namespace Sekai.Graphics; 8 | 9 | /// 10 | /// Contains a collection of buffers used for presentation. 11 | /// 12 | public abstract class Swapchain : IDisposable 13 | { 14 | /// 15 | /// The swapchain's size. 16 | /// 17 | public abstract Size Size { get; set; } 18 | 19 | public abstract void Dispose(); 20 | } 21 | -------------------------------------------------------------------------------- /source/Sekai/Headless/HeadlessRasterizerState.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using Sekai.Graphics; 5 | 6 | namespace Sekai.Headless; 7 | 8 | internal sealed class HeadlessRasterizerState : RasterizerState 9 | { 10 | public override FaceCulling Culling { get; } 11 | public override FaceWinding Winding { get; } 12 | public override FillMode Mode { get; } 13 | public override bool Scissor { get; } 14 | 15 | public override void Dispose() 16 | { 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /source/Sekai/Graphics/FaceCulling.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | namespace Sekai.Graphics; 5 | 6 | /// 7 | /// The face to cull. 8 | /// 9 | public enum FaceCulling 10 | { 11 | /// 12 | /// Disable face culling. 13 | /// 14 | None, 15 | 16 | /// 17 | /// Cull front faces. 18 | /// 19 | Front, 20 | 21 | /// 22 | /// Cull back faces. 23 | /// 24 | Back, 25 | } 26 | -------------------------------------------------------------------------------- /source/Sekai/Headless/HeadlessShader.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using Sekai.Graphics; 5 | 6 | namespace Sekai.Headless; 7 | 8 | internal sealed class HeadlessShader : Shader 9 | { 10 | public override ShaderStage Stages { get; } 11 | 12 | public HeadlessShader(ShaderCode[] attachments) 13 | { 14 | for (int i = 0; i < attachments.Length; i++) 15 | { 16 | Stages |= attachments[i].Stage; 17 | } 18 | } 19 | 20 | public override void Dispose() 21 | { 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /source/Sekai/Headless/HeadlessAudioListener.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using System.Numerics; 5 | using Sekai.Audio; 6 | 7 | namespace Sekai.Headless; 8 | 9 | internal sealed class HeadlessAudioListener : AudioListener 10 | { 11 | public override float Volume { get; set; } 12 | public override Vector3 Position { get; set; } 13 | public override Vector3 Velocity { get; set; } 14 | public override ListenerOrientation Orientation { get; set; } 15 | 16 | public override void Dispose() 17 | { 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /source/Sekai/Headless/HeadlessAudioBuffer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using Sekai.Audio; 5 | 6 | namespace Sekai.Headless; 7 | 8 | internal sealed class HeadlessAudioBuffer : AudioBuffer 9 | { 10 | public override int Capacity { get; } 11 | public override int SampleRate { get; } 12 | public override AudioFormat Format { get; } 13 | 14 | public override void Dispose() 15 | { 16 | } 17 | 18 | public override void SetData(nint data, uint size, AudioFormat format, int sampleRate) 19 | { 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /source/Sekai/Audio/AudioSourceState.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | namespace Sekai.Audio; 5 | 6 | /// 7 | /// The possible states of an . 8 | /// 9 | public enum AudioSourceState 10 | { 11 | /// 12 | /// The source is stopped. 13 | /// 14 | Stopped, 15 | 16 | /// 17 | /// The source is playing. 18 | /// 19 | Playing, 20 | 21 | /// 22 | /// The source is paused. 23 | /// 24 | Paused, 25 | } 26 | -------------------------------------------------------------------------------- /source/Sekai/Graphics/ShaderLanguage.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | namespace Sekai.Graphics; 5 | 6 | /// 7 | /// An enumeration of shader languages. 8 | /// 9 | public enum ShaderLanguage 10 | { 11 | /// 12 | /// OpenGL Shading Language. 13 | /// 14 | GLSL, 15 | 16 | /// 17 | /// High-Level Shading Language. 18 | /// 19 | HLSL, 20 | 21 | /// 22 | /// Standard Portable Immediate Representation. 23 | /// 24 | SPIR, 25 | } 26 | -------------------------------------------------------------------------------- /source/Sekai/Input/IPointer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using System; 5 | using System.Numerics; 6 | 7 | namespace Sekai.Input; 8 | 9 | /// 10 | /// Represents a pointing device. 11 | /// 12 | public interface IPointer : IInputDevice 13 | { 14 | /// 15 | /// The position of the pointer. 16 | /// 17 | Vector2 Position { get; } 18 | 19 | /// 20 | /// Called when the pointer has changed position. 21 | /// 22 | event Action? OnMove; 23 | } 24 | -------------------------------------------------------------------------------- /source/Sekai/Mathematics/IColor.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using System; 5 | using System.Numerics; 6 | 7 | namespace Sekai.Mathematics; 8 | 9 | /// 10 | /// Defines a mechanism for performing various color operations. 11 | /// 12 | /// The type that implements the interface. 13 | public interface IColor : IFormattable, IEquatable, IEqualityOperators 14 | where TSelf : struct, IColor, IEquatable, IEqualityOperators 15 | { 16 | } 17 | -------------------------------------------------------------------------------- /source/Sekai/Windowing/WindowBorder.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | namespace Sekai.Windowing; 5 | 6 | /// 7 | /// An enumeration of window border states. 8 | /// 9 | public enum WindowBorder 10 | { 11 | /// 12 | /// The window cannot be resized. 13 | /// 14 | Fixed, 15 | 16 | /// 17 | /// The window is resizable. 18 | /// 19 | Resizable, 20 | 21 | /// 22 | /// The window border decoration is hidden. 23 | /// 24 | Hidden, 25 | } 26 | -------------------------------------------------------------------------------- /source/Sekai/Graphics/MapMode.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | namespace Sekai.Graphics; 5 | 6 | /// 7 | /// The mode of how a resource will be mapped. 8 | /// 9 | public enum MapMode 10 | { 11 | /// 12 | /// The resource is mapped as read-only. 13 | /// 14 | Read, 15 | 16 | /// 17 | /// The resource is mapped as write-only. 18 | /// 19 | Write, 20 | 21 | /// 22 | /// The resource is mapped as read/write. 23 | /// 24 | ReadWrite, 25 | } 26 | -------------------------------------------------------------------------------- /source/Sekai/Input/IKeyboard.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | namespace Sekai.Input; 8 | 9 | /// 10 | /// Represents a keyboard. 11 | /// 12 | public interface IKeyboard : IInputDevice 13 | { 14 | /// 15 | /// The available keys the keyboard has. 16 | /// 17 | IReadOnlyList Keys { get; } 18 | 19 | /// 20 | /// Called when a key event has occured. 21 | /// 22 | event Action? OnKey; 23 | } 24 | -------------------------------------------------------------------------------- /source/Sekai/Mathematics/Containment.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | namespace Sekai.Mathematics; 5 | 6 | /// 7 | /// The containment types. 8 | /// 9 | public enum Containment 10 | { 11 | /// 12 | /// Both primitives are disjointed. 13 | /// 14 | Disjoint, 15 | 16 | /// 17 | /// The left primitive contains the right primitive. 18 | /// 19 | Contains, 20 | 21 | /// 22 | /// Both primitives intersect each other. 23 | /// 24 | Intersects, 25 | } 26 | -------------------------------------------------------------------------------- /source/Sekai/Mathematics/PlaneIntersection.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | namespace Sekai.Mathematics; 5 | 6 | /// 7 | /// The plane interseciton types. 8 | /// 9 | public enum PlaneIntersection 10 | { 11 | /// 12 | /// The primitive is behind the plane. 13 | /// 14 | Back, 15 | 16 | /// 17 | /// The primitive is in front of the plane. 18 | /// 19 | Front, 20 | 21 | /// 22 | /// The primitive intersects the plane. 23 | /// 24 | Intersects, 25 | } 26 | -------------------------------------------------------------------------------- /source/Sekai/Windowing/WindowState.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | namespace Sekai.Windowing; 5 | 6 | /// 7 | /// An enumeration of window states. 8 | /// 9 | public enum WindowState 10 | { 11 | /// 12 | /// Normal. 13 | /// 14 | Normal, 15 | 16 | /// 17 | /// Minimized. 18 | /// 19 | Minimized, 20 | 21 | /// 22 | /// Maximized. 23 | /// 24 | Maximized, 25 | 26 | /// 27 | /// Fullscreen. 28 | /// 29 | Fullscreen, 30 | } 31 | -------------------------------------------------------------------------------- /source/Sekai/TickMode.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | namespace Sekai; 5 | 6 | /// 7 | /// An enumeration of game loop processing modes. 8 | /// 9 | public enum TickMode 10 | { 11 | /// 12 | /// Fixed time step. 13 | /// 14 | /// 15 | /// A tick occurs at a fixed time interval. 16 | /// 17 | Fixed, 18 | 19 | /// 20 | /// Variable time step. 21 | /// 22 | /// 23 | /// A tick occurs at a variable time interval. 24 | /// 25 | Variable, 26 | } 27 | -------------------------------------------------------------------------------- /analysis/BannedSymbols.txt: -------------------------------------------------------------------------------- 1 | M:System.Object.Equals(System.Object,System.Object)~System.Boolean;Don't use object.Equals. Use IEquatable or EqualityComparer.Default instead. 2 | M:System.Object.Equals(System.Object)~System.Boolean;Don't use object.Equals. Use IEquatable or EqualityComparer.Default instead. 3 | M:System.ValueType.Equals(System.Object)~System.Boolean;Don't use object.Equals(Fallbacks to ValueType). Use IEquatable or EqualityComparer.Default instead. 4 | T:System.IComparable;Don't use non-generic IComparable. Use generic version instead. 5 | M:System.Guid.#ctor;You probably meant to use Guid.NewGuid() instead. If you actually want empty, use Guid.Empty. -------------------------------------------------------------------------------- /source/Sekai/Input/IMotor.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | namespace Sekai.Input; 5 | 6 | /// 7 | /// Represents a rumble motor inside a gamepad. 8 | /// 9 | public interface IMotor 10 | { 11 | /// 12 | /// The index of this motor. 13 | /// 14 | int Index { get; } 15 | 16 | /// 17 | /// The motor's vibration intensitiy, between 0f and 1f. 18 | /// 19 | /// 20 | /// Some backends may truncate this value if variable intensity is not supported. 21 | /// 22 | float Speed { get; set; } 23 | } 24 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | on: 3 | push: 4 | paths: 5 | - 'tests/**/*.cs' 6 | - 'source/**/*.cs' 7 | - 'samples/**/*.cs' 8 | 9 | jobs: 10 | check: 11 | name: Check 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Checkout 15 | uses: actions/checkout@v2 16 | with: 17 | fetch-depth: 0 18 | 19 | - name: Lint 20 | uses: github/super-linter@v4 21 | env: 22 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 23 | SUPPRESS_POSSUM: true 24 | VALIDATE_CSHARP: true 25 | VALIDATE_EDITORCONFIG: true 26 | VALIDATE_ALL_CODEBASE: false 27 | -------------------------------------------------------------------------------- /source/Sekai/Graphics/TextureUsage.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using System; 5 | 6 | namespace Sekai.Graphics; 7 | 8 | /// 9 | /// Flags to describe how a texture is used. 10 | /// 11 | [Flags] 12 | public enum TextureUsage 13 | { 14 | /// 15 | /// This texture is unused. 16 | /// 17 | None, 18 | 19 | /// 20 | /// This texture is used as a shader resource. 21 | /// 22 | Resource, 23 | 24 | /// 25 | /// This texture is used as a framebuffer render target. 26 | /// 27 | RenderTarget 28 | } 29 | -------------------------------------------------------------------------------- /source/Sekai/Input/IInputSource.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | namespace Sekai.Input; 8 | 9 | /// 10 | /// The input source hosting all available devices. 11 | /// 12 | public interface IInputSource 13 | { 14 | /// 15 | /// Gets all connected devices from this source. 16 | /// 17 | IEnumerable Devices { get; } 18 | 19 | /// 20 | /// Called when a device's connection has been changed. 21 | /// 22 | event Action? ConnectionChanged; 23 | } 24 | -------------------------------------------------------------------------------- /source/Sekai.GLFW/GLFWController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using Sekai.Input; 5 | 6 | namespace Sekai.GLFW; 7 | 8 | internal abstract class GLFWController : IInputDevice 9 | { 10 | public int Index { get; } 11 | public Deadzone Deadzone { get; set; } 12 | public string Name => Glfw.GetGamepadName(Index); 13 | public abstract bool IsConnected { get; } 14 | protected Silk.NET.GLFW.Glfw Glfw { get; private set; } 15 | 16 | protected GLFWController(Silk.NET.GLFW.Glfw glfw, int index) 17 | { 18 | Glfw = glfw; 19 | Index = index; 20 | } 21 | 22 | public abstract void Update(); 23 | } 24 | -------------------------------------------------------------------------------- /source/Sekai.GLFW/GameOptionsExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using System.Runtime.Versioning; 5 | 6 | namespace Sekai.GLFW; 7 | 8 | public static class GameOptionsExtensions 9 | { 10 | /// 11 | /// Use GLFW as the window and input provider. 12 | /// 13 | [SupportedOSPlatform("windows")] 14 | [SupportedOSPlatform("linux")] 15 | [SupportedOSPlatform("osx")] 16 | public static void UseGLFW(this GameOptions options) 17 | { 18 | options.View = new GameOptions.WindowOptions 19 | { 20 | Create = () => new GLFWWindow() 21 | }; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /source/Sekai/Graphics/IndexType.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | namespace Sekai.Graphics; 5 | 6 | /// 7 | /// An enumeration of index data types. 8 | /// 9 | public enum IndexType 10 | { 11 | /// 12 | /// Unsigned 16-bit integer. 13 | /// 14 | UnsignedShort, 15 | 16 | /// 17 | /// Unsigned 32-bit integer. 18 | /// 19 | UnsignedInt, 20 | 21 | /// 22 | /// Signed 16-bit integer. 23 | /// 24 | Short, 25 | 26 | /// 27 | /// Signed 32-bit integer. 28 | /// 29 | Int 30 | } 31 | -------------------------------------------------------------------------------- /source/Sekai/Graphics/TextureType.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | namespace Sekai.Graphics; 5 | 6 | /// 7 | /// An enumeration of texture types. 8 | /// 9 | public enum TextureType 10 | { 11 | /// 12 | /// One dimensional texture. 13 | /// 14 | Texture1D, 15 | 16 | /// 17 | /// Two dimensional texture. 18 | /// 19 | Texture2D, 20 | 21 | /// 22 | /// Three dimensional texture. 23 | /// 24 | Texture3D, 25 | 26 | /// 27 | /// A cubemap texture. 28 | /// 29 | Cubemap, 30 | } 31 | -------------------------------------------------------------------------------- /source/Sekai/Logging/LogWriterDebug.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using System.Diagnostics; 5 | 6 | namespace Sekai.Logging; 7 | 8 | internal sealed class LogWriterDebug : LogWriter 9 | { 10 | public LogWriterDebug() 11 | { 12 | Debug.AutoFlush = false; 13 | } 14 | 15 | public override void Flush() 16 | { 17 | Debug.Flush(); 18 | } 19 | 20 | public override void Write(LogMessage message) 21 | { 22 | if (message.Level == LogLevel.Debug) 23 | { 24 | Debug.WriteLine(message); 25 | } 26 | } 27 | 28 | public override void Dispose() 29 | { 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /source/Sekai/Logging/LogWriterTrace.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using System.Diagnostics; 5 | 6 | namespace Sekai.Logging; 7 | 8 | internal sealed class LogWriterTrace : LogWriter 9 | { 10 | public LogWriterTrace() 11 | { 12 | Trace.AutoFlush = false; 13 | } 14 | 15 | public override void Flush() 16 | { 17 | Trace.Flush(); 18 | } 19 | 20 | public override void Write(LogMessage message) 21 | { 22 | if (message.Level == LogLevel.Trace) 23 | { 24 | Trace.WriteLine(message); 25 | } 26 | } 27 | 28 | public override void Dispose() 29 | { 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /tests/Sekai.OpenGL.Tests/GLGraphicsTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using NUnit.Framework; 5 | using Sekai.Graphics.Tests; 6 | 7 | namespace Sekai.OpenGL.Tests; 8 | 9 | [TestFixture] 10 | public class GLGraphicsDeviceTest : GraphicsDeviceTest 11 | { 12 | public GLGraphicsDeviceTest() 13 | { 14 | } 15 | } 16 | 17 | [TestFixture] 18 | public class GLBufferTest : GraphicsBufferTest 19 | { 20 | public GLBufferTest() 21 | { 22 | } 23 | } 24 | 25 | [TestFixture] 26 | public class GLTextureTest : TextureTest 27 | { 28 | public GLTextureTest() 29 | { 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /source/Sekai/Graphics/ClearFlags.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using System; 5 | 6 | namespace Sekai.Graphics; 7 | 8 | /// 9 | /// The flags used to clear the target framebuffer. 10 | /// 11 | [Flags] 12 | public enum ClearFlags 13 | { 14 | /// 15 | /// Clear nothing. 16 | /// 17 | None, 18 | 19 | /// 20 | /// Clear the color buffer. 21 | /// 22 | Color = 1 << 0, 23 | 24 | /// 25 | /// Clear the depth buffer. 26 | /// 27 | Depth = 1 << 1, 28 | 29 | /// 30 | /// Clear the stencil buffer. 31 | /// 32 | Stencil = 1 << 2, 33 | } 34 | -------------------------------------------------------------------------------- /source/Sekai/Graphics/TextureAddress.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | namespace Sekai.Graphics; 5 | 6 | /// 7 | /// Determines what is sampled when texture coordinates go outside the boundary. 8 | /// 9 | public enum TextureAddress 10 | { 11 | /// 12 | /// The texture will repeat. 13 | /// 14 | Repeat, 15 | 16 | /// 17 | /// The texture will mirror. 18 | /// 19 | Mirror, 20 | 21 | /// 22 | /// The texture will clamp to the edge. 23 | /// 24 | ClampToEdge, 25 | 26 | /// 27 | /// The texture will clamp to a predefined border color. 28 | /// 29 | ClampToBorder, 30 | } 31 | -------------------------------------------------------------------------------- /source/Sekai/Headless/HeadlessBlendState.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using Sekai.Graphics; 5 | 6 | namespace Sekai.Headless; 7 | 8 | internal sealed class HeadlessBlendState : BlendState 9 | { 10 | public override bool Enabled { get; } 11 | public override BlendType SourceColor { get; } 12 | public override BlendType DestinationColor { get; } 13 | public override BlendOperation ColorOperation { get; } 14 | public override BlendType SourceAlpha { get; } 15 | public override BlendType DestinationAlpha { get; } 16 | public override BlendOperation AlphaOperation { get; } 17 | public override ColorWriteMask WriteMask { get; } 18 | 19 | public override void Dispose() 20 | { 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /source/Sekai.OpenAL/Sekai.OpenAL.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /source/Sekai.OpenGL/GameOptionsExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using System; 5 | using Sekai.Contexts; 6 | 7 | namespace Sekai.OpenGL; 8 | 9 | public static class GameOptionsExtensions 10 | { 11 | /// 12 | /// Use OpenGL as the graphics provider. 13 | /// 14 | public static void UseOpenGL(this GameOptions options) 15 | { 16 | options.Graphics.CreateDevice = static (view) => 17 | { 18 | if (view is not IGLContextSource source) 19 | { 20 | throw new NotSupportedException("The view does not provide a GL context."); 21 | } 22 | 23 | return new GLGraphicsDevice(source.Context); 24 | }; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /tests/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | false 4 | true 5 | 6 | 7 | 8 | runtime; build; native; contentfiles; analyzers; buildtransitive 9 | all 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /tests/Sekai.Graphics.Tests/GraphicsTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using NUnit.Framework; 5 | using Sekai.Windowing; 6 | 7 | namespace Sekai.Graphics.Tests; 8 | 9 | [SingleThreaded] 10 | [NonParallelizable] 11 | public abstract class GraphicsTest 12 | where T : GraphicsDeviceCreator, new() 13 | { 14 | protected IWindow Window = null!; 15 | protected GraphicsDevice Device = null!; 16 | 17 | [OneTimeSetUp] 18 | public void OneTimeSetUp() 19 | { 20 | var creator = new T(); 21 | Window = creator.CreateWindow(); 22 | Device = creator.CreateGraphics(Window); 23 | } 24 | 25 | [OneTimeTearDown] 26 | public void OneTimeTearDown() 27 | { 28 | Device.Dispose(); 29 | Window.Dispose(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /.gitpod.dockerfile: -------------------------------------------------------------------------------- 1 | FROM docker.io/gitpod/workspace-full:latest 2 | 3 | USER gitpod 4 | 5 | # Install Xvfb 6 | RUN sudo apt-get update && export DEBIAN_FRONTEND=noninteractive \ 7 | && sudo apt-get -y install --no-install-recommends \ 8 | xvfb xauth \ 9 | && sudo apt-get autoremove -y \ 10 | && sudo apt-get clean -y \ 11 | && sudo rm -rf /var/lib/apt/lists/* 12 | 13 | # Install .NET SDK (LTS channel) 14 | # Source: https://docs.microsoft.com/dotnet/core/install/linux-scripted-manual#scripted-install 15 | RUN mkdir -p /home/gitpod/dotnet && \ 16 | curl -fsSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --install-dir /home/gitpod/dotnet -c STS && \ 17 | curl -fsSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --install-dir /home/gitpod/dotnet -c LTS 18 | 19 | ENV DOTNET_ROOT=/home/gitpod/dotnet 20 | ENV PATH=$PATH:/home/gitpod/dotnet -------------------------------------------------------------------------------- /source/Sekai/Graphics/BufferType.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | namespace Sekai.Graphics; 5 | 6 | /// 7 | /// Determines the type of buffer. 8 | /// 9 | public enum BufferType 10 | { 11 | /// 12 | /// This buffer is used as a vertex buffer. 13 | /// 14 | Vertex, 15 | 16 | /// 17 | /// This buffer is used as an index buffer. 18 | /// 19 | Index, 20 | 21 | /// 22 | /// This buffer is used as a uniform buffer. 23 | /// 24 | Uniform, 25 | 26 | /// 27 | /// This buffer is used as a storage buffer. 28 | /// 29 | Storage, 30 | 31 | /// 32 | /// This buffer is used as an indirect buffer. 33 | /// 34 | Indirect, 35 | } 36 | -------------------------------------------------------------------------------- /source/Sekai/Logging/LogWriter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using System; 5 | 6 | namespace Sekai.Logging; 7 | 8 | /// 9 | /// Writes s to output sources. 10 | /// 11 | public abstract class LogWriter : IDisposable 12 | { 13 | /// 14 | /// The number of times this writer has logged. 15 | /// 16 | public int LogCount { get; internal set; } 17 | 18 | public abstract void Dispose(); 19 | 20 | /// 21 | /// Flushes the contents of this . 22 | /// 23 | public abstract void Flush(); 24 | 25 | /// 26 | /// Writes a to this writer. 27 | /// 28 | /// 29 | public abstract void Write(LogMessage message); 30 | } 31 | -------------------------------------------------------------------------------- /source/Sekai/Input/IController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Cosyne 2 | // Licensed under MIT. See LICENSE for details. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | namespace Sekai.Input; 8 | 9 | /// 10 | /// Represents a controller. 11 | /// 12 | public interface IController : IInputDevice 13 | { 14 | /// 15 | /// Gets the controller index. 16 | /// 17 | int Index { get; } 18 | 19 | /// 20 | /// The controller's deadzone method. 21 | /// 22 | Deadzone Deadzone { get; set; } 23 | 24 | /// 25 | /// The available buttons the controller has. 26 | /// 27 | IReadOnlyList