├── bindgen ├── header.cs ├── config-build-c-library.json ├── config-extract-macos.json ├── config-extract-windows.json ├── config-extract-linux.json ├── generate.sh ├── merge.sh ├── appsettings.json ├── config-generate-cs.json └── extract.sh ├── src ├── cs │ ├── Directory.Build.targets │ ├── production │ │ ├── Directory.Build.props │ │ ├── Directory.Build.targets │ │ ├── Interop.Sokol │ │ │ ├── _README_PACKAGE.md │ │ │ ├── Generated │ │ │ │ └── AssemblyAttributes.gen.cs │ │ │ ├── Properties │ │ │ │ └── StyleCop.json │ │ │ ├── Interop.Sokol.csproj │ │ │ ├── Rgb8U.cs │ │ │ ├── Rgba8U.cs │ │ │ ├── Rgb32F.cs │ │ │ ├── Rgba32F.cs │ │ │ ├── Rgb8U.Colors.cs │ │ │ ├── Rgb32F.Colors.cs │ │ │ └── Rgba8U.Colors.cs │ │ ├── Interop.Sokol.runtime.osx │ │ │ ├── _README_PACKAGE.md │ │ │ └── Interop.Sokol.runtime.osx.csproj │ │ ├── Interop.Sokol.runtime.win-x64 │ │ │ ├── _README_PACKAGE.md │ │ │ └── Interop.Sokol.runtime.win-x64.csproj │ │ └── Interop.Sokol.runtime.linux-x64 │ │ │ ├── _README_PACKAGE.md │ │ │ └── Interop.Sokol.runtime.linux-x64.csproj │ ├── samples │ │ ├── Directory.Build.props │ │ ├── Directory.Build.targets │ │ ├── Cube │ │ │ ├── assets │ │ │ │ └── shaders │ │ │ │ │ ├── d3d11 │ │ │ │ │ ├── mainFrag.hlsl │ │ │ │ │ └── mainVert.hlsl │ │ │ │ │ ├── opengl │ │ │ │ │ ├── mainFrag.glsl │ │ │ │ │ └── mainVert.glsl │ │ │ │ │ └── metal │ │ │ │ │ ├── mainFrag.metal │ │ │ │ │ └── mainVert.metal │ │ │ ├── Samples.Cube.csproj │ │ │ └── Program.cs │ │ ├── Samples.Triangle │ │ │ ├── assets │ │ │ │ └── shaders │ │ │ │ │ ├── d3d11 │ │ │ │ │ ├── mainFrag.hlsl │ │ │ │ │ └── mainVert.hlsl │ │ │ │ │ ├── opengl │ │ │ │ │ ├── mainFrag.glsl │ │ │ │ │ └── mainVert.glsl │ │ │ │ │ └── metal │ │ │ │ │ ├── mainFrag.metal │ │ │ │ │ └── mainVert.metal │ │ │ ├── Samples.Triangle.csproj │ │ │ └── Program.cs │ │ └── Samples.ImGui │ │ │ ├── Samples.ImGui.csproj │ │ │ └── Program.cs │ ├── .globalconfig │ ├── Sokol.sln.DotSettings │ ├── Directory.Build.props │ ├── StyleCop.json │ ├── Sokol.sln │ └── StyleCop.globalconfig └── c │ └── production │ └── sokol │ ├── sokol.h │ ├── sokol.c │ └── CMakeLists.txt ├── docs └── images │ └── 1-triangle.png ├── .github ├── dependabot.yml └── workflows │ ├── pull-request.yml │ ├── commit.yml │ ├── release.yml │ ├── bindgen.yml │ └── build.yml ├── .gitmodules ├── .gitignore ├── library.sh ├── LICENSE ├── .editorconfig └── README.md /bindgen/header.cs: -------------------------------------------------------------------------------- 1 | using Rgba32F = bottlenoselabs.Sokol.Rgba32F; -------------------------------------------------------------------------------- /src/cs/Directory.Build.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /docs/images/1-triangle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bottlenoselabs/sokol-cs/HEAD/docs/images/1-triangle.png -------------------------------------------------------------------------------- /src/cs/production/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/cs/samples/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/cs/samples/Directory.Build.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/cs/production/Directory.Build.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/cs/samples/Cube/assets/shaders/d3d11/mainFrag.hlsl: -------------------------------------------------------------------------------- 1 | float4 main(float4 color: COLOR0): SV_Target0 2 | { 3 | return color; 4 | }; -------------------------------------------------------------------------------- /src/cs/samples/Samples.Triangle/assets/shaders/d3d11/mainFrag.hlsl: -------------------------------------------------------------------------------- 1 | float4 main(float4 color: COLOR0): SV_Target0 2 | { 3 | return color; 4 | } -------------------------------------------------------------------------------- /src/cs/production/Interop.Sokol/_README_PACKAGE.md: -------------------------------------------------------------------------------- 1 | 2 | # bottlenoselabs.Interop.Sokol 3 | 4 | Automatically updated C# bindings for https://github.com/floooh/sokol. -------------------------------------------------------------------------------- /src/cs/samples/Cube/assets/shaders/opengl/mainFrag.glsl: -------------------------------------------------------------------------------- 1 | #version 330 2 | in vec4 color; 3 | out vec4 frag_color; 4 | void main() 5 | { 6 | frag_color = color; 7 | } -------------------------------------------------------------------------------- /src/cs/samples/Samples.Triangle/assets/shaders/opengl/mainFrag.glsl: -------------------------------------------------------------------------------- 1 | #version 330 2 | in vec4 color; 3 | out vec4 frag_color; 4 | void main() { 5 | frag_color = color; 6 | } -------------------------------------------------------------------------------- /src/cs/samples/Cube/assets/shaders/metal/mainFrag.metal: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace metal; 3 | fragment float4 _main(float4 color [[stage_in]]) { 4 | return color; 5 | } -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "gitsubmodule" 4 | directory: "/" 5 | schedule: 6 | interval: "daily" 7 | time: "00:15" # 8:15pm EDT -------------------------------------------------------------------------------- /src/cs/production/Interop.Sokol.runtime.osx/_README_PACKAGE.md: -------------------------------------------------------------------------------- 1 | 2 | # bottlenoselabs.Interop.Sokol.runtime.osx 3 | 4 | Automatically updated C# bindings for https://github.com/floooh/sokol. -------------------------------------------------------------------------------- /src/cs/production/Interop.Sokol.runtime.win-x64/_README_PACKAGE.md: -------------------------------------------------------------------------------- 1 | 2 | # bottlenoselabs.Interop.Sokol.runtime.win-x64 3 | 4 | Automatically updated C# bindings for https://github.com/floooh/sokol. -------------------------------------------------------------------------------- /src/cs/production/Interop.Sokol.runtime.linux-x64/_README_PACKAGE.md: -------------------------------------------------------------------------------- 1 | 2 | # bottlenoselabs.Interop.Sokol.runtime.linux-x64 3 | 4 | Automatically updated C# bindings for https://github.com/floooh/sokol. -------------------------------------------------------------------------------- /src/cs/samples/Samples.Triangle/assets/shaders/metal/mainFrag.metal: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace metal; 3 | fragment float4 _main(float4 color [[stage_in]]) { 4 | return color; 5 | }; -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "ext/sokol"] 2 | path = ext/sokol 3 | url = https://github.com/floooh/sokol 4 | [submodule "ext/imgui-cs"] 5 | path = ext/imgui-cs 6 | url = https://github.com/bottlenoselabs/imgui-cs 7 | -------------------------------------------------------------------------------- /bindgen/config-build-c-library.json: -------------------------------------------------------------------------------- 1 | { 2 | "cMakeDirectoryPath": "../src/c/production/sokol", 3 | "outputDirectoryPath": "../lib", 4 | "deleteBuildFiles": true, 5 | "cMakeArguments": [ 6 | "-DCMAKE_OSX_ARCHITECTURES=\"x86_64;arm64\"" 7 | ] 8 | } -------------------------------------------------------------------------------- /src/cs/samples/Samples.Triangle/assets/shaders/opengl/mainVert.glsl: -------------------------------------------------------------------------------- 1 | #version 330 2 | layout(location=0) in vec4 position; 3 | layout(location=1) in vec4 color0; 4 | out vec4 color; 5 | void main() { 6 | gl_Position = position; 7 | color = color0; 8 | } -------------------------------------------------------------------------------- /bindgen/config-extract-macos.json: -------------------------------------------------------------------------------- 1 | { 2 | "inputFilePath": "./../src/c/production/sokol/sokol.h", 3 | "userIncludeDirectories": [ 4 | "./../ext/sokol" 5 | ], 6 | "platforms": { 7 | "aarch64-apple-darwin": {}, 8 | "x86_64-apple-darwin": {} 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /bindgen/config-extract-windows.json: -------------------------------------------------------------------------------- 1 | { 2 | "inputFilePath": "./../src/c/production/sokol/sokol.h", 3 | "userIncludeDirectories": [ 4 | "./../ext/sokol" 5 | ], 6 | "platforms": { 7 | "x86_64-pc-windows-msvc": {}, 8 | "aarch64-pc-windows-msvc": {} 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/cs/samples/Cube/assets/shaders/opengl/mainVert.glsl: -------------------------------------------------------------------------------- 1 | #version 330 2 | uniform mat4 mvp; 3 | layout(location=0) in vec4 position; 4 | layout(location=1) in vec4 color0; 5 | out vec4 color; 6 | void main() 7 | { 8 | gl_Position = mvp * position; 9 | color = color0; 10 | } -------------------------------------------------------------------------------- /bindgen/config-extract-linux.json: -------------------------------------------------------------------------------- 1 | { 2 | "inputFilePath": "./../src/c/production/sokol/sokol.h", 3 | "userIncludeDirectories": [ 4 | "./../ext/sokol" 5 | ], 6 | "platforms": { 7 | "x86_64-unknown-linux-gnu": {}, 8 | "aarch64-unknown-linux-gnu": {} 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # JetBrains 2 | .idea/ 3 | 4 | # Build artifacts 5 | bin/ 6 | obj/ 7 | /artifacts/ 8 | 9 | # C# packages 10 | /nupkg/ 11 | 12 | # C build artifacts 13 | cmake-build-release/ 14 | 15 | # Native libraries 16 | /lib/ 17 | 18 | # Bindgen 19 | /bindgen/ast/ 20 | /bindgen/x-ast/ 21 | 22 | # macOS 23 | .DS_store -------------------------------------------------------------------------------- /src/cs/.globalconfig: -------------------------------------------------------------------------------- 1 | # NOTE: Requires .NET 5 SDK (VS2019 16.8 or later) 2 | # https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/configuration-files#global-analyzerconfig 3 | is_global = true 4 | 5 | # StyleCop Rules 6 | ## Description: StyleCop code analysis rules for C# projects. 7 | dotnet_diagnostic.SA1300.severity = none -------------------------------------------------------------------------------- /src/c/production/sokol/sokol.h: -------------------------------------------------------------------------------- 1 | #include "sokol_app.h" 2 | #include "sokol_gfx.h" 3 | #include "sokol_glue.h" 4 | #include "sokol_audio.h" 5 | #include "sokol_fetch.h" 6 | #include "sokol_time.h" 7 | #include "sokol_args.h" 8 | 9 | // Include ImGui 10 | #define CIMGUI_DEFINE_ENUMS_AND_STRUCTS 11 | #include "cimgui.h" 12 | #include "util/sokol_imgui.h" -------------------------------------------------------------------------------- /bindgen/generate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" 3 | 4 | if ! [[ -x "$(command -v c2cs)" ]]; then 5 | echo "Error: 'c2cs' is not installed. Please visit https://github.com/bottlenoselabs/C2CS for instructions to install the C2CS tool." >&2 6 | exit 1 7 | fi 8 | 9 | c2cs generate --config "$DIRECTORY/config-generate-cs.json" -------------------------------------------------------------------------------- /src/cs/samples/Samples.Triangle/assets/shaders/d3d11/mainVert.hlsl: -------------------------------------------------------------------------------- 1 | struct vs_in 2 | { 3 | float4 pos: POS; 4 | float4 color: COLOR; 5 | }; 6 | 7 | struct vs_out 8 | { 9 | float4 color: COLOR0; 10 | float4 pos: SV_Position; 11 | }; 12 | 13 | vs_out main(vs_in inp) 14 | { 15 | vs_out outp; 16 | outp.pos = inp.pos; 17 | outp.color = inp.color; 18 | return outp; 19 | } -------------------------------------------------------------------------------- /bindgen/merge.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" 3 | 4 | if ! [[ -x "$(command -v castffi)" ]]; then 5 | echo "Error: 'castffi' is not installed. Please visit https://github.com/bottlenoselabs/CAstFfi for instructions to install the CAstFfi tool." >&2 6 | exit 1 7 | fi 8 | 9 | castffi merge --inputDirectoryPath "$DIRECTORY/ast" --outputFilePath "$DIRECTORY/x-ast/ast-cross-platform.json" -------------------------------------------------------------------------------- /src/cs/samples/Cube/assets/shaders/d3d11/mainVert.hlsl: -------------------------------------------------------------------------------- 1 | cbuffer params: register(b0) 2 | { 3 | float4x4 mvp; 4 | }; 5 | struct vs_in 6 | { 7 | float4 pos: POSITION; 8 | float4 color: COLOR1; 9 | }; 10 | struct vs_out 11 | { 12 | float4 color: COLOR0; 13 | float4 pos: SV_Position; 14 | }; 15 | vs_out main(vs_in inp) 16 | { 17 | vs_out outp; 18 | outp.pos = mul(mvp, inp.pos); 19 | outp.color = inp.color; 20 | return outp; 21 | }; -------------------------------------------------------------------------------- /src/cs/samples/Samples.Triangle/assets/shaders/metal/mainVert.metal: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace metal; 3 | struct vs_in { 4 | float4 position [[attribute(0)]]; 5 | float4 color [[attribute(1)]]; 6 | }; 7 | struct vs_out { 8 | float4 position [[position]]; 9 | float4 color; 10 | }; 11 | vertex vs_out _main(vs_in inp [[stage_in]]) { 12 | vs_out outp; 13 | outp.position = inp.position; 14 | outp.color = inp.color; 15 | return outp; 16 | } -------------------------------------------------------------------------------- /bindgen/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "Console": { 4 | "LogLevel": { 5 | "Default": "Warning", 6 | "CAstFfi": "Debug", 7 | "C2CS": "Debug" 8 | }, 9 | "FormatterOptions": { 10 | "ColorBehavior": "Enabled", 11 | "SingleLine": true, 12 | "IncludeScopes": true, 13 | "TimestampFormat": "yyyy-dd-MM HH:mm:ss ", 14 | "UseUtcTimestamp": true 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/cs/Sokol.sln.DotSettings: -------------------------------------------------------------------------------- 1 | 2 | True 3 | True -------------------------------------------------------------------------------- /library.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" 3 | 4 | if ! [[ -x "$(command -v c2cs)" ]]; then 5 | echo "Error: 'c2cs' is not installed. The C2CS tool is used to generate a C shared library for the purposes of P/Invoke with C#. Please visit https://github.com/bottlenoselabs/C2CS for instructions to install the C2CS tool." >&2 6 | exit 1 7 | fi 8 | 9 | c2cs library --config "$DIRECTORY/bindgen/config-build-c-library.json" 10 | 11 | if [[ -z "$1" ]]; then 12 | read 13 | fi -------------------------------------------------------------------------------- /src/cs/samples/Cube/assets/shaders/metal/mainVert.metal: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace metal; 3 | struct params_t { 4 | float4x4 mvp; 5 | }; 6 | struct vs_in { 7 | float4 position [[attribute(0)]]; 8 | float4 color [[attribute(1)]]; 9 | }; 10 | struct vs_out { 11 | float4 pos [[position]]; 12 | float4 color; 13 | }; 14 | vertex vs_out _main(vs_in in [[stage_in]], constant params_t& params [[buffer(0)]]) { 15 | vs_out out; 16 | out.pos = params.mvp * in.position; 17 | out.color = in.color; 18 | return out; 19 | } -------------------------------------------------------------------------------- /.github/workflows/pull-request.yml: -------------------------------------------------------------------------------- 1 | name: "Pull request" 2 | 3 | on: 4 | pull_request: 5 | types: [assigned, opened, synchronize, reopened] 6 | paths-ignore: 7 | - '**.md' 8 | 9 | jobs: 10 | 11 | bindgen-job: 12 | name: "Bindgen" 13 | uses: "./.github/workflows/bindgen.yml" 14 | 15 | build-job: 16 | name: "Build" 17 | needs: [bindgen-job] 18 | uses: "./.github/workflows/build.yml" 19 | 20 | commit-job: 21 | name: "Commit" 22 | needs: [bindgen-job, build-job] 23 | if: github.actor == 'dependabot[bot]' 24 | uses: "./.github/workflows/commit.yml" 25 | -------------------------------------------------------------------------------- /src/c/production/sokol/sokol.c: -------------------------------------------------------------------------------- 1 | #define SOKOL_IMPL 2 | #define SOKOL_DLL 3 | #define SOKOL_NO_ENTRY 4 | #define SOKOL_NO_DEPRECATED 5 | #define SOKOL_TRACE_HOOKS 6 | 7 | #if _WIN32 8 | #pragma warning(disable : 5105) 9 | #ifndef _WIN64 10 | #error "Compiling for Windows 32-bit ARM or x86 is not supported." 11 | #endif 12 | #define WIN32_LEAN_AND_MEAN 13 | #define NOCOMM 14 | #ifndef WINAPI 15 | #define WINAPI __stdcall 16 | #endif 17 | #define APIENTRY WINAPI 18 | #define SOKOL_LOG(s) OutputDebugStringA(s) 19 | #include 20 | #endif 21 | 22 | #include "sokol.h" -------------------------------------------------------------------------------- /src/cs/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), .gitignore))/artifacts 6 | 7 | 8 | 9 | 10 | all 11 | 12 | 13 | 14 | all 15 | runtime; build; native; contentfiles; analyzers; buildtransitive 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /.github/workflows/commit.yml: -------------------------------------------------------------------------------- 1 | name: "Commit generated code" 2 | 3 | on: 4 | workflow_call: 5 | 6 | permissions: write-all 7 | 8 | jobs: 9 | 10 | commit-job: 11 | name: "Commit generated C# code" 12 | runs-on: ubuntu-latest 13 | if: github.actor == 'dependabot[bot]' 14 | 15 | steps: 16 | - name: "Clone Git repository" 17 | uses: actions/checkout@v2 18 | with: 19 | submodules: 'true' 20 | 21 | - name: "Download changes to commit" 22 | uses: actions/download-artifact@v1 23 | with: 24 | name: "bindgen-cs" 25 | path: "./src/cs/production/Interop.Sokol/Generated" 26 | 27 | - name: "Add + commit + push (if necessary)" 28 | uses: EndBug/add-and-commit@v7 29 | with: 30 | author_name: 'lithiumtoast' 31 | author_email: '519592+lithiumtoast@users.noreply.github.com' 32 | message: "Update C# bindings" 33 | -------------------------------------------------------------------------------- /src/cs/production/Interop.Sokol/Generated/AssemblyAttributes.gen.cs: -------------------------------------------------------------------------------- 1 | // To disable generating this file set `isEnabledGenerateAssemblyAttributes` to `false` in the config file for generating C# code. 2 | // 3 | // This code was generated by the following tool on 2023-08-07 00:19:31 GMT+00:00: 4 | // https://github.com/bottlenoselabs/c2cs (v6.1.3.0) 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. 7 | // 8 | // ReSharper disable All 9 | 10 | #region Template 11 | #nullable enable 12 | #pragma warning disable CS1591 13 | #pragma warning disable CS8981 14 | using bottlenoselabs.C2CS.Runtime; 15 | using System; 16 | using System.Collections.Generic; 17 | using System.Globalization; 18 | using System.Runtime.InteropServices; 19 | using System.Runtime.CompilerServices; 20 | #endregion 21 | 22 | #if NET7_0_OR_GREATER 23 | [assembly: DisableRuntimeMarshalling] 24 | #endif 25 | 26 | [assembly: DefaultDllImportSearchPathsAttribute(DllImportSearchPath.SafeDirectories)] 27 | -------------------------------------------------------------------------------- /src/cs/samples/Samples.ImGui/Samples.ImGui.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | WinExe 6 | net7.0 7 | true 8 | Samples 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | PreserveNewest 21 | 22 | 23 | 24 | 25 | 26 | 27 | %(Filename)%(Extension) 28 | PreserveNewest 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/cs/production/Interop.Sokol/Properties/StyleCop.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json", 3 | "settings": { 4 | "indentation": { 5 | "useTabs": false 6 | }, 7 | "documentationRules": { 8 | "companyName": "Bottlenose Labs Inc. (https://github.com/bottlenoselabs)", 9 | "copyrightText": "Copyright (c) {companyName}. All rights reserved.\nLicensed under the {licenseName} license. See {licenseFile} file in the Git repository root directory for full license information.", 10 | "variables": { 11 | "licenseName": "MIT", 12 | "licenseFile": "LICENSE" 13 | }, 14 | "xmlHeader": false, 15 | "documentInternalElements": false 16 | }, 17 | "orderingRules": { 18 | "usingDirectivesPlacement": "outsideNamespace", 19 | "elementOrder": [ 20 | "kind", 21 | "accessibility", 22 | "constant", 23 | "readonly" 24 | ] 25 | }, 26 | "layoutRules": { 27 | "newlineAtEndOfFile": "require" 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Lucas Girouard-Stranks 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/cs/StyleCop.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json", 3 | "settings": { 4 | "indentation": { 5 | "useTabs": false 6 | }, 7 | "documentationRules": { 8 | "companyName": "Bottlenose Labs Inc. (https://github.com/bottlenoselabs)", 9 | "copyrightText": "Copyright (c) {companyName}. All rights reserved.\nLicensed under the {licenseName} license. See {licenseFile} file in the Git repository root directory for full license information.", 10 | "variables": { 11 | "licenseName": "MIT", 12 | "licenseFile": "LICENSE" 13 | }, 14 | "xmlHeader": false, 15 | "documentInternalElements": false 16 | }, 17 | "orderingRules": { 18 | "usingDirectivesPlacement": "outsideNamespace", 19 | "elementOrder": [ 20 | "kind", 21 | "accessibility", 22 | "constant", 23 | "readonly" 24 | ] 25 | }, 26 | "layoutRules": { 27 | "newlineAtEndOfFile": "require" 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /src/cs/samples/Cube/Samples.Cube.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | WinExe 6 | net7.0 7 | true 8 | Samples 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | PreserveNewest 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | %(Filename)%(Extension) 30 | PreserveNewest 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /bindgen/config-generate-cs.json: -------------------------------------------------------------------------------- 1 | { 2 | "inputFilePath": "./x-ast/ast-cross-platform.json", 3 | "outputFileDirectory": "./../src/cs/production/Interop.Sokol/Generated", 4 | "namespaceName": "bottlenoselabs.Interop.Sokol", 5 | "className": "PInvoke", 6 | "libraryName": "sokol", 7 | "mappedNames": [ 8 | { "source": "sg_color", "target": "Rgba32F" } 9 | ], 10 | "ignoredNames": [ 11 | "Rgba32F", 12 | "sokol_main", 13 | "SOKOL_APP_INCLUDED", 14 | "SOKOL_ARGS_INCLUDED", 15 | "SOKOL_AUDIO_INCLUDED", 16 | "SOKOL_FETCH_INCLUDED", 17 | "SOKOL_GFX_INCLUDED", 18 | "SOKOL_TIME_INCLUDED", 19 | "SOKOL_IMGUI_INCLUDED", 20 | "SOKOL_IMGUI_IMPL_INCLUDED" 21 | ], 22 | "isEnabledVerifyCSharpCodeCompiles": false, 23 | "mappedCNamespaces": [ 24 | { "source": "sg_", "target": "Graphics" }, 25 | { "source": "sapp_", "target": "App" }, 26 | { "source": "sargs_", "target": "Args" }, 27 | { "source": "saudio_", "target": "Audio" }, 28 | { "source": "sfetch_", "target": "Fetch" }, 29 | { "source": "stm_", "target": "Time" }, 30 | { "source": "simgui_", "target": "SImGui" } 31 | ], 32 | "isEnabledAssemblyAttributes": true, 33 | "isEnabledLibraryImport": true, 34 | "isEnabledIdiomaticCSharp": true, 35 | "isEnabledGeneratingRuntimeCode": false 36 | } 37 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Is this file the top-most EditorConfig file? 2 | root = true 3 | 4 | # Any and all files 5 | [*] 6 | charset = utf-8 7 | indent_style = space 8 | indent_size = 4 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true 11 | 12 | # C# files 13 | [*.cs] 14 | indent_style = space 15 | 16 | # Visual Studio Solution files 17 | [*.sln] 18 | indent_style = tab 19 | 20 | # Visual Studio XML project files 21 | [*.{csproj,vbproj,vcxproj.filters,proj,projitems,shproj}] 22 | indent_style = tab 23 | indent_size = 2 24 | 25 | # XML configuration files 26 | [*.{xml,config,props,targets,nuspec,resx,ruleset,vsixmanifest,vsct}] 27 | indent_style = tab 28 | indent_size = 2 29 | 30 | # JSON files 31 | [*.{json,json5,webmanifest}] 32 | indent_style = space 33 | indent_size = 2 34 | 35 | # YAML files 36 | [*.{yml,yaml}] 37 | indent_style = space 38 | indent_size = 2 39 | 40 | # Markdown files 41 | [*.md] 42 | indent_style = space 43 | trim_trailing_whitespace = false 44 | indent_size = 4 45 | 46 | # Web files 47 | [*.{htm,html,js,jsm,ts,tsx,css,sass,scss,less,svg,vue}] 48 | indent_style = space 49 | indent_size = 2 50 | 51 | # Batch files 52 | [*.{cmd,bat}] 53 | indent_style = tab 54 | end_of_line = crlf 55 | 56 | # Bash files 57 | [*.sh] 58 | indent_style = tab 59 | end_of_line = lf 60 | 61 | # Makefiles 62 | [Makefile] 63 | indent_style = tab -------------------------------------------------------------------------------- /src/cs/samples/Samples.Triangle/Samples.Triangle.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | WinExe 6 | net7.0 7 | true 8 | Samples 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | PreserveNewest 26 | 27 | 28 | 29 | 30 | 31 | 32 | %(Filename)%(Extension) 33 | PreserveNewest 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /bindgen/extract.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" 3 | 4 | function get_host_operating_system() { 5 | local UNAME_STRING="$(uname -a)" 6 | case "${UNAME_STRING}" in 7 | *Microsoft*) local HOST_OS="windows";; 8 | *microsoft*) local HOST_OS="windows";; 9 | Linux*) local HOST_OS="linux";; 10 | Darwin*) local HOST_OS="macos";; 11 | CYGWIN*) local HOST_OS="linux";; 12 | MINGW*) local HOST_OS="windows";; 13 | *Msys) local HOST_OS="windows";; 14 | *) local HOST_OS="UNKNOWN:${UNAME_STRING}" 15 | esac 16 | echo "$HOST_OS" 17 | return 0 18 | } 19 | 20 | OS="$(get_host_operating_system)" 21 | 22 | if [[ "$OS" == "windows" ]]; then 23 | CASTFFI_CONFIG_FILE_PATH="$DIRECTORY/config-extract-windows.json" 24 | elif [[ "$OS" == "macos" ]]; then 25 | CASTFFI_CONFIG_FILE_PATH="$DIRECTORY/config-extract-macos.json" 26 | elif [[ "$OS" == "linux" ]]; then 27 | CASTFFI_CONFIG_FILE_PATH="$DIRECTORY/config-extract-linux.json" 28 | else 29 | echo "Error: Unknown operating system '$OS'" >&2 30 | exit 1 31 | fi 32 | 33 | if ! [[ -x "$(command -v castffi)" ]]; then 34 | echo "Error: 'castffi' is not installed. Please visit https://github.com/bottlenoselabs/CAstFfi for instructions to install the CAstFfi tool." >&2 35 | exit 1 36 | fi 37 | 38 | castffi extract --config "$CASTFFI_CONFIG_FILE_PATH" 39 | -------------------------------------------------------------------------------- /src/cs/production/Interop.Sokol/Interop.Sokol.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Interop.Sokol 6 | net7.0 7 | true 8 | bottlenoselabs.Interop.Sokol 9 | false 10 | enable 11 | en 12 | CA1051;CA1707;CA1815;CS9080;CS8981 13 | true 14 | 15 | 16 | 17 | 18 | true 19 | bottlenoselabs.Interop.Sokol 20 | C# interop bindings for https://github.com/floooh/sokol. 21 | https://github.com/bottlenoselabs/sokol-cs 22 | MIT 23 | _README_PACKAGE.md 24 | 25 | 26 | 27 | true 28 | / 29 | PreserveNewest 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/cs/production/Interop.Sokol.runtime.osx/Interop.Sokol.runtime.osx.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | netstandard1.0 6 | false 7 | disable 8 | true 9 | 10 | 11 | 12 | 13 | true 14 | bottlenoselabs.Interop.Sokol.runtime.osx 15 | 16 | macOS x64/arm64 native libraries for the `bottlenoselabs.Interop.Sokol` package. Includes `cimgui` native library. 17 | 18 | https://github.com/bottlenoselabs/sokol-cs 19 | MIT 20 | _README_PACKAGE.md 21 | true 22 | true 23 | false 24 | false 25 | 26 | 27 | 28 | true 29 | / 30 | PreserveNewest 31 | 32 | 33 | 34 | 35 | 36 | 37 | %(Filename)%(Extension) 38 | runtimes/osx/native/%(Filename)%(Extension) 39 | true 40 | PreserveNewest 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/cs/production/Interop.Sokol.runtime.win-x64/Interop.Sokol.runtime.win-x64.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | netstandard1.0 6 | false 7 | disable 8 | true 9 | 10 | 11 | 12 | 13 | true 14 | bottlenoselabs.Interop.Sokol.runtime.win-x64 15 | 16 | Linux x64 native libraries for the `bottlenoselabs.Interop.Sokol` package. Includes `cimgui` native library. 17 | 18 | https://github.com/bottlenoselabs/sokol-cs 19 | MIT 20 | _README_PACKAGE.md 21 | true 22 | true 23 | false 24 | false 25 | 26 | 27 | 28 | true 29 | / 30 | PreserveNewest 31 | 32 | 33 | 34 | 35 | 36 | 37 | %(Filename)%(Extension) 38 | runtimes/win-x64/native/%(Filename)%(Extension) 39 | true 40 | PreserveNewest 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/cs/production/Interop.Sokol.runtime.linux-x64/Interop.Sokol.runtime.linux-x64.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | netstandard1.0 6 | false 7 | disable 8 | true 9 | 10 | 11 | 12 | 13 | true 14 | bottlenoselabs.Interop.Sokol.runtime.linux-x64 15 | 16 | Linux x64 native libraries for the `bottlenoselabs.Interop.Sokol` package. Includes `cimgui` native library. 17 | 18 | https://github.com/bottlenoselabs/sokol-cs 19 | MIT 20 | _README_PACKAGE.md 21 | true 22 | true 23 | false 24 | false 25 | 26 | 27 | 28 | true 29 | / 30 | PreserveNewest 31 | 32 | 33 | 34 | 35 | 36 | 37 | %(Filename)%(Extension) 38 | runtimes/linux-x64/native/%(Filename)%(Extension) 39 | true 40 | PreserveNewest 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/c/production/sokol/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | 3 | project(sokol) 4 | 5 | set(CMAKE_C_STANDARD 11) 6 | set(CMAKE_CXX_STANDARD 11) 7 | 8 | if (CMAKE_SYSTEM_NAME STREQUAL Linux) 9 | set(THREADS_PREFER_PTHREAD_FLAG ON) 10 | find_package(Threads REQUIRED) 11 | endif() 12 | 13 | get_filename_component(SOKOL_DIRECTORY_PATH "../../../../ext/sokol" REALPATH BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") 14 | get_filename_component(CIMGUI_DIRECTORY_PATH "../../../../ext/imgui-cs/ext/cimgui" REALPATH BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") 15 | include_directories(${SOKOL_DIRECTORY_PATH} ${CIMGUI_DIRECTORY_PATH}) 16 | 17 | if (WIN32) 18 | add_definitions(-DSOKOL_D3D11) 19 | set(CMAKE_SHARED_LIBRARY_PREFIX "") 20 | elseif (APPLE) 21 | add_definitions(-DSOKOL_METAL) 22 | else() 23 | add_definitions(-DSOKOL_GLCORE33) 24 | endif() 25 | 26 | add_definitions(-DSOKOL_IMGUI_IMPL) 27 | add_library(cimgui SHARED 28 | ${CIMGUI_DIRECTORY_PATH}/cimgui.h 29 | ${CIMGUI_DIRECTORY_PATH}/cimgui.cpp 30 | ${CIMGUI_DIRECTORY_PATH}/imgui/imgui.h 31 | ${CIMGUI_DIRECTORY_PATH}/imgui/imgui.cpp 32 | ${CIMGUI_DIRECTORY_PATH}/imgui/imgui_widgets.cpp 33 | ${CIMGUI_DIRECTORY_PATH}/imgui/imgui_draw.cpp 34 | ${CIMGUI_DIRECTORY_PATH}/imgui/imgui_tables.cpp 35 | ${CIMGUI_DIRECTORY_PATH}/imgui/imgui_demo.cpp) 36 | 37 | add_library(sokol SHARED "sokol.c") 38 | target_link_libraries(sokol cimgui) 39 | 40 | if (APPLE) 41 | target_compile_options(sokol PRIVATE -x objective-c) 42 | target_link_libraries(sokol "-framework Cocoa") 43 | target_link_libraries(sokol "-framework QuartzCore") 44 | target_link_libraries(sokol "-framework Metal") 45 | target_link_libraries(sokol "-framework MetalKit") 46 | target_link_libraries(sokol "-framework AudioToolbox") 47 | set_target_properties(sokol PROPERTIES LINK_FLAGS "-Wl,-F/Library/Frameworks") 48 | elseif (LINUX) 49 | target_link_libraries(sokol X11 Xi Xcursor GL dl m) 50 | target_link_libraries(sokol Threads::Threads) 51 | endif() -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # sokol-cs 2 | 3 | **Discontinued. If you wish to create your own bindings, message me.** 4 | 5 | Automatically updated C# bindings for sokol https://github.com/floooh/sokol with native dynamic link libraries. 6 | 7 | To learn more about `sokol` and it's philosophy, see the [*A Tour of `sokol_gfx.h`*](https://floooh.github.io/2017/07/29/sokol-gfx-tour.html) blog post, written Andre Weissflog, the owner of `sokol`. 8 | 9 | ## How to use 10 | 11 | 1. Download and install [.NET 7](https://dotnet.microsoft.com/download). 12 | 2. Fork the repository using GitHub or clone the repository manually with submodules: `git clone --recurse-submodules https://github.com/bottlenoselabs/sokol-cs`. 13 | 3. Build the native library by running `library.sh`. To execute `.sh` scripts on Windows, use Git Bash which can be installed with Git itself: https://git-scm.com/download/win. The `library.sh` script requires that CMake is installed and in your path. 14 | 4. To setup everything you need: Either (1), add the `src/cs/production/Sokol/Sokol.csproj` C# project to your solution as an existing project and reference it within your own solution, or (2) import the MSBuild `sokol.props` file which is located in the root of this directory to your `.csproj` file. See the [Sokol.csproj](src/cs/production/Sokol/Sokol.csproj) file for how to import the `sokol.props` directly. 15 | ```xml 16 | 17 | 18 | ``` 19 | 20 | ## Developers: Documentation 21 | 22 | ### Run: "Hello, world!" of computer graphics 23 | 24 | The most basic example of rendering a triangle in clip space using your GPU. 25 | 26 | ![Triangle](docs/images/1-triangle.png) 27 | 28 | Build + run: `dotnet run --project ./src/cs/samples/Triangle/Triangle.csproj` 29 | 30 | ## Developers: Documentation 31 | 32 | For more information on how C# bindings work, see [`C2CS`](https://github.com/lithiumtoast/c2cs), the tool that generates the bindings for `sokol` and other C libraries. 33 | 34 | To learn how to use `sokol`, check out the [official C samples](https://github.com/floooh/sokol-samples). You can also find the same examples that run in [your browser](https://floooh.github.io/sokol-html5/index.html). The comments in the [`sokol_gfx.h`](https://github.com/floooh/sokol/blob/master/sokol_gfx.h), [`sokol_app.h`](https://github.com/floooh/sokol/blob/master/sokol_app.h), etc, are also a good reference for documentation. 35 | 36 | ## 3D Graphics APIs 37 | 38 | [`sokol_gfx`](https://github.com/floooh/sokol#sokol_gfxh) converges old and modern graphics APIs to one simple and easy to use API. To learn more about the convergence of modern 3D graphics APIs (such as Metal, DirectX11/12, and WebGPU) and how they compare to legacy APIs (such as OpenGL), see *[A Comparison of Modern Graphics APIs](https://alain.xyz/blog/comparison-of-modern-graphics-apis)* blog written by Alain Galvan, a graphics software engineer. 39 | 40 | ## License 41 | 42 | `sokol-cs` is licensed under the MIT license (`MIT`) - see the [LICENSE file](LICENSE) for details. 43 | 44 | `sokol` is licensed under the ZLib license (`zlib`) - see https://github.com/floooh/sokol/blob/master/LICENSE for more details. 45 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: "Release" 2 | on: 3 | workflow_dispatch: 4 | inputs: 5 | pre-release: 6 | description: 'Is this a release candidate (pre-release)? (NOTE: candidates get uploaded to MyGet.org instead of NuGet.org)' 7 | required: true 8 | default: 'true' 9 | schedule: 10 | - cron: "0 0 1 * *" # First day of every month 11 | 12 | jobs: 13 | 14 | build-job: 15 | name: "Build" 16 | uses: "./.github/workflows/build.yml" 17 | 18 | release-job: 19 | name: "Release" 20 | needs: [build-job] 21 | runs-on: ubuntu-latest 22 | permissions: 23 | contents: write 24 | steps: 25 | 26 | - name: "Clone Git repository" 27 | uses: actions/checkout@master 28 | with: 29 | submodules: "recursive" 30 | 31 | - name: "Set version" 32 | id: set-version 33 | shell: bash 34 | run: | 35 | IS_PRERELEASE="${{ github.event.inputs.pre-release }}" 36 | if [[ "$IS_PRERELEASE" = "true" ]]; then 37 | VERSION="$(date +'%Y.%m.%d')-rc" 38 | else 39 | VERSION="$(date +'%Y.%m.%d')" 40 | fi 41 | echo "VERSION=$VERSION" 42 | echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT" 43 | 44 | - name: "Download native libraries (win-x64)" 45 | uses: actions/download-artifact@v1 46 | with: 47 | name: "native-libraries-win-x64" 48 | path: "./lib" 49 | 50 | - name: "Download native libraries (osx)" 51 | uses: actions/download-artifact@v1 52 | with: 53 | name: "native-libraries-osx" 54 | path: "./lib" 55 | 56 | - name: "Download native libraries (linux-x64)" 57 | uses: actions/download-artifact@v1 58 | with: 59 | name: "native-libraries-linux-x64" 60 | path: "./lib" 61 | 62 | - name: ".NET pack" 63 | run: dotnet pack "./src/cs" --nologo --verbosity minimal --configuration Release -p:PackageVersion="${{ steps.set-version.outputs.VERSION }}" -p:RepositoryBranch="${{ github.head_ref || github.ref_name }}" -p:RepositoryCommit="${{ github.sha }}" 64 | 65 | - name: "Upload packages to MyGet" 66 | if: github.event_name == 'workflow_dispatch' && github.event.inputs.pre-release == 'true' 67 | env: 68 | MYGET_ACCESS_TOKEN: ${{ secrets.MYGET_ACCESS_TOKEN }} 69 | run: dotnet nuget push "./nupkg/**/*.nupkg" --source https://www.myget.org/F/bottlenoselabs/api/v3/index.json --skip-duplicate --api-key $MYGET_ACCESS_TOKEN 70 | 71 | - name: "Upload packages to NuGet" 72 | if: github.event_name == 'schedule' || github.event.inputs.pre-release == 'false' 73 | env: 74 | NUGET_ACCESS_TOKEN: ${{ secrets.NUGET_ACCESS_TOKEN }} 75 | run: dotnet nuget push "./nupkg/**/*.nupkg" --source https://api.nuget.org/v3/index.json --skip-duplicate --api-key $NUGET_ACCESS_TOKEN 76 | 77 | - name: "Create tag and GitHub release" 78 | uses: softprops/action-gh-release@v1 79 | if: github.event_name == 'schedule' || github.event.inputs.pre-release == 'false' 80 | with: 81 | generate_release_notes: true 82 | prerelease: "{{ github.event.inputs.pre-release == 'true' }}" 83 | tag_name: "v${{ steps.set-version.outputs.VERSION }}" 84 | -------------------------------------------------------------------------------- /.github/workflows/bindgen.yml: -------------------------------------------------------------------------------- 1 | name: "Bindgen" 2 | 3 | on: 4 | workflow_dispatch: 5 | workflow_call: 6 | 7 | jobs: 8 | 9 | bindgen-ast-job: 10 | name: "Bindgen AST" 11 | runs-on: ${{ matrix.platform.os }} 12 | strategy: 13 | fail-fast: false 14 | matrix: 15 | platform: 16 | - { name: Windows, os: windows-latest, rid: win } 17 | - { name: macOS, os: macos-latest, rid: osx } 18 | - { name: Linux, os: ubuntu-latest, rid: linux } 19 | 20 | steps: 21 | - name: "Clone Git repository" 22 | uses: actions/checkout@v2 23 | with: 24 | submodules: 'true' 25 | 26 | - name: "Install CAstFfi" 27 | shell: bash 28 | run: dotnet tool install --global bottlenoselabs.CAstFfi.Tool 29 | 30 | - name: "Read C code: Linux dependencies" 31 | if: runner.os == 'Linux' 32 | run: sudo apt-get update && sudo apt-get install gcc-aarch64-linux-gnu 33 | 34 | - name: "Read C code: extract ${{ matrix.platform.rid }}" 35 | shell: bash 36 | run: cd ./bindgen && ./extract.sh 37 | 38 | - name: "Upload C code platform abstract syntax trees" 39 | uses: actions/upload-artifact@v2 40 | with: 41 | name: "ast-${{ matrix.platform.rid }}" 42 | path: "./bindgen/ast" 43 | 44 | bindgen-cross-platform-ast-job: 45 | name: "Bindgen AST cross-platform" 46 | needs: [bindgen-ast-job] 47 | runs-on: ubuntu-latest 48 | 49 | steps: 50 | - name: "Clone Git repository" 51 | uses: actions/checkout@v2 52 | with: 53 | submodules: 'false' 54 | 55 | - name: "Download C code platform abstract syntax trees (win)" 56 | uses: actions/download-artifact@v1 57 | with: 58 | name: "ast-win" 59 | path: "./bindgen/ast" 60 | 61 | - name: "Download C code platform abstract syntax trees (osx)" 62 | uses: actions/download-artifact@v1 63 | with: 64 | name: "ast-osx" 65 | path: "./bindgen/ast" 66 | 67 | - name: "Download C code platform abstract syntax trees (linux)" 68 | uses: actions/download-artifact@v1 69 | with: 70 | name: "ast-linux" 71 | path: "./bindgen/ast" 72 | 73 | - name: "Install CAstFfi" 74 | shell: bash 75 | run: dotnet tool install --global bottlenoselabs.CAstFfi.Tool 76 | 77 | - name: "Generate cross-platform AST" 78 | shell: bash 79 | run: cd ./bindgen && ./merge.sh 80 | 81 | - name: "Upload cross-platform AST" 82 | uses: actions/upload-artifact@v2 83 | with: 84 | name: "ast-cross-platform" 85 | path: "./bindgen/x-ast/ast-cross-platform.json" 86 | 87 | bindgen-cs-job: 88 | name: "Bindgen C#" 89 | needs: [bindgen-cross-platform-ast-job] 90 | runs-on: ubuntu-latest 91 | 92 | steps: 93 | - name: "Clone Git repository" 94 | uses: actions/checkout@v2 95 | with: 96 | submodules: 'false' 97 | 98 | - name: "Download C code cross-platform abstract syntax tree" 99 | uses: actions/download-artifact@v1 100 | with: 101 | name: "ast-cross-platform" 102 | path: "./bindgen/x-ast" 103 | 104 | - name: "Install C2CS" 105 | shell: bash 106 | run: dotnet tool install --global bottlenoselabs.C2CS.Tool 107 | 108 | - name: "Generate C# code" 109 | shell: bash 110 | run: cd ./bindgen && ./generate.sh 111 | 112 | - name: "Upload generated C# code" 113 | uses: actions/upload-artifact@v2 114 | with: 115 | name: "bindgen-cs" 116 | path: "./src/cs/production/Interop.Sokol/Generated" 117 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: "Build" 2 | 3 | on: 4 | workflow_dispatch: 5 | workflow_call: 6 | push: 7 | tags: 8 | - v* 9 | branches: 10 | - main 11 | paths-ignore: 12 | - "**.md" 13 | 14 | jobs: 15 | 16 | native-job: 17 | name: "Build native libraries: ${{ matrix.platform.rid }}" 18 | runs-on: ${{ matrix.platform.os }} 19 | strategy: 20 | fail-fast: false 21 | matrix: 22 | platform: 23 | - { name: Windows (x64), os: windows-latest, rid: win-x64 } 24 | - { name: macOS (x64 + arm64), os: macos-latest, rid: osx } 25 | - { name: Linux (x64), os: ubuntu-latest, rid: linux-x64 } 26 | steps: 27 | 28 | - name: "Clone Git repository" 29 | uses: actions/checkout@master 30 | with: 31 | submodules: "recursive" 32 | 33 | - name: "Install C2CS" 34 | shell: bash 35 | run: dotnet tool install --global bottlenoselabs.C2CS.Tool 36 | 37 | - name: "Get C2CS version" 38 | shell: bash 39 | run: echo "C2CS_VERSION=$(c2cs --version)" >> $GITHUB_ENV 40 | 41 | - name: "Cache native libraries" 42 | id: cache-libs 43 | uses: actions/cache@v3 44 | with: 45 | path: "./lib" 46 | key: "libs-${{ matrix.platform.rid }}-${{ hashFiles('ext/sokol/**/*') }}-${{ hashFiles('src/c/**/*') }}-${{ hashFiles('bindgen/**/*') }}-${{ env.C2CS_VERSION }}" 47 | 48 | - name: "Install Windows dependencies" 49 | if: runner.os == 'Windows' && steps.cache-libs.outputs.cache-hit != 'true' 50 | run: | 51 | choco install ninja 52 | 53 | - name: "Install macOS dependencies" 54 | if: runner.os == 'macOS' && steps.cache-libs.outputs.cache-hit != 'true' 55 | run: | 56 | brew install ninja 57 | 58 | - name: Setup Linux dependencies 59 | if: runner.os == 'Linux' && steps.cache-libs.outputs.cache-hit != 'true' 60 | run: | 61 | sudo apt-get update 62 | sudo apt-get install \ 63 | ninja-build \ 64 | libxi-dev libxcursor-dev libgl-dev libasound2-dev 65 | 66 | - name: "Build native libraries" 67 | if: steps.cache-libs.outputs.cache-hit != 'true' 68 | shell: bash 69 | run: ./library.sh "auto" 70 | 71 | - name: "Upload native libraries" 72 | uses: actions/upload-artifact@v2 73 | with: 74 | path: "./lib" 75 | name: "native-libraries-${{ matrix.platform.rid }}" 76 | 77 | dotnet-job: 78 | name: "Build .NET solution" 79 | needs: [native-job] 80 | runs-on: ubuntu-latest 81 | steps: 82 | 83 | - name: "Clone Git repository" 84 | uses: actions/checkout@master 85 | with: 86 | submodules: 'true' 87 | 88 | - name: "Download native libraries (win-x64)" 89 | uses: actions/download-artifact@v1 90 | with: 91 | name: "native-libraries-win-x64" 92 | path: "./lib" 93 | 94 | - name: "Download native libraries (osx)" 95 | uses: actions/download-artifact@v1 96 | with: 97 | name: "native-libraries-osx" 98 | path: "./lib" 99 | 100 | - name: "Download native libraries (linux-x64)" 101 | uses: actions/download-artifact@v1 102 | with: 103 | name: "native-libraries-linux-x64" 104 | path: "./lib" 105 | 106 | - name: "Download generated C# code" 107 | uses: actions/download-artifact@v1 108 | continue-on-error: true 109 | with: 110 | name: "bindgen-cs" 111 | path: "./src/cs/production/Interop.Sokol/Generated" 112 | 113 | - name: ".NET Build" 114 | run: dotnet build "./src/cs" --nologo --verbosity minimal --configuration Release -p:PackageVersion="$(date +'%Y.%m.%d')" 115 | 116 | -------------------------------------------------------------------------------- /src/cs/samples/Samples.ImGui/Program.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Bottlenose Labs Inc. (https://github.com/bottlenoselabs). All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the Git repository root directory for full license information. 3 | 4 | using System.Globalization; 5 | using System.Numerics; 6 | using System.Runtime.CompilerServices; 7 | using System.Runtime.InteropServices; 8 | using bottlenoselabs.C2CS.Runtime; 9 | using bottlenoselabs.Interop.Sokol; 10 | using static bottlenoselabs.Interop.ImGui.PInvoke; 11 | using static bottlenoselabs.Interop.Sokol.PInvoke; 12 | using ImGui = bottlenoselabs.Interop.ImGui.PInvoke.ImGui; 13 | 14 | namespace Samples; 15 | 16 | internal static unsafe class Program 17 | { 18 | private static ProgramState _state; 19 | 20 | private struct ProgramState 21 | { 22 | public Rgba32F ClearColor; 23 | 24 | public bool ShowTestWindow; 25 | public bool ShowAnotherWindow; 26 | } 27 | 28 | private static void Main() 29 | { 30 | var desc = default(App.Desc); 31 | desc.InitCb.Pointer = &Initialize; 32 | desc.FrameCb.Pointer = &Frame; 33 | desc.EventCb.Pointer = &Event; 34 | desc.Width = 800; 35 | desc.Height = 600; 36 | desc.SampleCount = 4; 37 | desc.WindowTitle = "ImGui"; 38 | desc.Icon.SokolDefault = true; 39 | 40 | App.Run(&desc); 41 | } 42 | 43 | [UnmanagedCallersOnly] 44 | private static void Initialize() 45 | { 46 | var desc = default(Graphics.Desc); 47 | desc.Context = App.Sgcontext(); 48 | Graphics.Setup(&desc); 49 | 50 | var imGuiDesc = default(SImGui.DescT); 51 | SImGui.Setup(&imGuiDesc); 52 | } 53 | 54 | [UnmanagedCallersOnly] 55 | private static void Frame() 56 | { 57 | Draw(); 58 | Graphics.Commit(); 59 | } 60 | 61 | [UnmanagedCallersOnly] 62 | private static void Event(App.Event* e) 63 | { 64 | SImGui.HandleEvent(e); 65 | } 66 | 67 | private static void Draw() 68 | { 69 | var width = App.Width(); 70 | var height = App.Height(); 71 | 72 | var imGuiFrameDesc = default(SImGui.FrameDescT); 73 | imGuiFrameDesc.Width = width; 74 | imGuiFrameDesc.Height = height; 75 | imGuiFrameDesc.DeltaTime = App.FrameDuration(); 76 | imGuiFrameDesc.DpiScale = App.DpiScale(); 77 | SImGui.NewFrame(&imGuiFrameDesc); 78 | 79 | var action = default(Graphics.PassAction); 80 | ref var colorAttachment = ref action.Colors[0]; 81 | colorAttachment.LoadAction = Graphics.LoadAction.Clear; 82 | colorAttachment.ClearValue = Rgba32F.Black; 83 | Graphics.BeginDefaultPass(&action, width, height); 84 | 85 | // 1. Show a simple window 86 | // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug" 87 | var f = 0.0f; 88 | ImGui.Text((CString)"Hello, world!"); 89 | ImGui.SliderFloat((CString)"float", &f, 0.0f, 1.0f, (CString)"%.3f", ImGuiSliderFlags.None); 90 | 91 | ImGui.ColorEdit3((CString)"clear color", (float*)Unsafe.AsPointer(ref _state.ClearColor.R), 0); 92 | if (ImGui.Button((CString)"Test Window", Vector2.Zero)) 93 | { 94 | _state.ShowTestWindow = !_state.ShowTestWindow; 95 | } 96 | 97 | var format = string.Format( 98 | CultureInfo.InvariantCulture, 99 | "Application average {0} ms/frame {1} FPS)", 100 | 1000.0f / ImGui.GetIO()->Framerate, 101 | ImGui.GetIO()->Framerate); 102 | ImGui.Text((CString)format); 103 | 104 | var format2 = string.Format( 105 | CultureInfo.InvariantCulture, 106 | "w: {0}, h: {1}, dpi_scale: {2}", 107 | App.Width(), 108 | App.Height(), 109 | App.DpiScale()); 110 | ImGui.Text((CString)format2); 111 | 112 | var format3 = App.IsFullscreen() ? (CString)"Switch to windowed" : (CString)"Switch to fullscreen"; 113 | if (ImGui.Button(format3, Vector2.Zero)) 114 | { 115 | App.ToggleFullscreen(); 116 | } 117 | 118 | if (_state.ShowTestWindow) 119 | { 120 | ImGui.SetNextWindowSize(new Vector2(200, 100), ImGuiCond.FirstUseEver); 121 | ImGui.Begin((CString)"Another Window", (CBool*)Unsafe.AsPointer(ref _state.ShowAnotherWindow), 0); 122 | ImGui.Text((CString)"Hello"); 123 | ImGui.End(); 124 | } 125 | 126 | SImGui.Render(); 127 | Graphics.EndPass(); 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /src/cs/Sokol.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Production", "Production", "{081F91DD-336C-4BB1-B619-ED0DD3ED32D0}" 4 | EndProject 5 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{D96A33BC-F5E8-4080-AA0A-8588A1C41312}" 6 | EndProject 7 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples.Cube", "samples\Cube\Samples.Cube.csproj", "{B3FC66C4-0D2B-49A8-B39B-0478E853E67E}" 8 | EndProject 9 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples.Triangle", "samples\Samples.Triangle\Samples.Triangle.csproj", "{19B4C212-E580-4122-82FE-940AC439C4A1}" 10 | EndProject 11 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Interop.Sokol", "production\Interop.Sokol\Interop.Sokol.csproj", "{C2D26EF1-5704-4B7E-920D-2537D26B0CC3}" 12 | EndProject 13 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples.ImGui", "samples\Samples.ImGui\Samples.ImGui.csproj", "{AF9E4E1D-52EA-4D2C-99C9-FD1208FD2D72}" 14 | EndProject 15 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "External", "External", "{462BF9C1-AE31-4443-B4E1-C5B42ABB4EA3}" 16 | EndProject 17 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Interop.Sokol.runtime.osx", "production\Interop.Sokol.runtime.osx\Interop.Sokol.runtime.osx.csproj", "{51CE53D3-699B-456C-A195-D80187212A6E}" 18 | EndProject 19 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Interop.Sokol.runtime.linux-x64", "production\Interop.Sokol.runtime.linux-x64\Interop.Sokol.runtime.linux-x64.csproj", "{7F1C2DF9-F28D-4591-A507-70989D1FE4AB}" 20 | EndProject 21 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Interop.Sokol.runtime.win-x64", "production\Interop.Sokol.runtime.win-x64\Interop.Sokol.runtime.win-x64.csproj", "{D19CFB61-47C8-4255-A690-581C50B9D17A}" 22 | EndProject 23 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Interop.ImGui", "..\..\ext\imgui-cs\src\cs\production\Interop.ImGui\Interop.ImGui.csproj", "{F0B7FC94-9415-409E-84B9-60B511C823B7}" 24 | EndProject 25 | Global 26 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 27 | Debug|Any CPU = Debug|Any CPU 28 | Release|Any CPU = Release|Any CPU 29 | EndGlobalSection 30 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 31 | {B3FC66C4-0D2B-49A8-B39B-0478E853E67E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 32 | {B3FC66C4-0D2B-49A8-B39B-0478E853E67E}.Debug|Any CPU.Build.0 = Debug|Any CPU 33 | {B3FC66C4-0D2B-49A8-B39B-0478E853E67E}.Release|Any CPU.ActiveCfg = Release|Any CPU 34 | {B3FC66C4-0D2B-49A8-B39B-0478E853E67E}.Release|Any CPU.Build.0 = Release|Any CPU 35 | {19B4C212-E580-4122-82FE-940AC439C4A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 36 | {19B4C212-E580-4122-82FE-940AC439C4A1}.Debug|Any CPU.Build.0 = Debug|Any CPU 37 | {19B4C212-E580-4122-82FE-940AC439C4A1}.Release|Any CPU.ActiveCfg = Release|Any CPU 38 | {19B4C212-E580-4122-82FE-940AC439C4A1}.Release|Any CPU.Build.0 = Release|Any CPU 39 | {C2D26EF1-5704-4B7E-920D-2537D26B0CC3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 40 | {C2D26EF1-5704-4B7E-920D-2537D26B0CC3}.Debug|Any CPU.Build.0 = Debug|Any CPU 41 | {C2D26EF1-5704-4B7E-920D-2537D26B0CC3}.Release|Any CPU.ActiveCfg = Release|Any CPU 42 | {C2D26EF1-5704-4B7E-920D-2537D26B0CC3}.Release|Any CPU.Build.0 = Release|Any CPU 43 | {AF9E4E1D-52EA-4D2C-99C9-FD1208FD2D72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 44 | {AF9E4E1D-52EA-4D2C-99C9-FD1208FD2D72}.Debug|Any CPU.Build.0 = Debug|Any CPU 45 | {AF9E4E1D-52EA-4D2C-99C9-FD1208FD2D72}.Release|Any CPU.ActiveCfg = Release|Any CPU 46 | {AF9E4E1D-52EA-4D2C-99C9-FD1208FD2D72}.Release|Any CPU.Build.0 = Release|Any CPU 47 | {51CE53D3-699B-456C-A195-D80187212A6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 48 | {51CE53D3-699B-456C-A195-D80187212A6E}.Debug|Any CPU.Build.0 = Debug|Any CPU 49 | {51CE53D3-699B-456C-A195-D80187212A6E}.Release|Any CPU.ActiveCfg = Release|Any CPU 50 | {51CE53D3-699B-456C-A195-D80187212A6E}.Release|Any CPU.Build.0 = Release|Any CPU 51 | {7F1C2DF9-F28D-4591-A507-70989D1FE4AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 52 | {7F1C2DF9-F28D-4591-A507-70989D1FE4AB}.Debug|Any CPU.Build.0 = Debug|Any CPU 53 | {7F1C2DF9-F28D-4591-A507-70989D1FE4AB}.Release|Any CPU.ActiveCfg = Release|Any CPU 54 | {7F1C2DF9-F28D-4591-A507-70989D1FE4AB}.Release|Any CPU.Build.0 = Release|Any CPU 55 | {D19CFB61-47C8-4255-A690-581C50B9D17A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 56 | {D19CFB61-47C8-4255-A690-581C50B9D17A}.Debug|Any CPU.Build.0 = Debug|Any CPU 57 | {D19CFB61-47C8-4255-A690-581C50B9D17A}.Release|Any CPU.ActiveCfg = Release|Any CPU 58 | {D19CFB61-47C8-4255-A690-581C50B9D17A}.Release|Any CPU.Build.0 = Release|Any CPU 59 | {F0B7FC94-9415-409E-84B9-60B511C823B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 60 | {F0B7FC94-9415-409E-84B9-60B511C823B7}.Debug|Any CPU.Build.0 = Debug|Any CPU 61 | {F0B7FC94-9415-409E-84B9-60B511C823B7}.Release|Any CPU.ActiveCfg = Release|Any CPU 62 | {F0B7FC94-9415-409E-84B9-60B511C823B7}.Release|Any CPU.Build.0 = Release|Any CPU 63 | EndGlobalSection 64 | GlobalSection(NestedProjects) = preSolution 65 | {B3FC66C4-0D2B-49A8-B39B-0478E853E67E} = {D96A33BC-F5E8-4080-AA0A-8588A1C41312} 66 | {19B4C212-E580-4122-82FE-940AC439C4A1} = {D96A33BC-F5E8-4080-AA0A-8588A1C41312} 67 | {C2D26EF1-5704-4B7E-920D-2537D26B0CC3} = {081F91DD-336C-4BB1-B619-ED0DD3ED32D0} 68 | {AF9E4E1D-52EA-4D2C-99C9-FD1208FD2D72} = {D96A33BC-F5E8-4080-AA0A-8588A1C41312} 69 | {51CE53D3-699B-456C-A195-D80187212A6E} = {081F91DD-336C-4BB1-B619-ED0DD3ED32D0} 70 | {7F1C2DF9-F28D-4591-A507-70989D1FE4AB} = {081F91DD-336C-4BB1-B619-ED0DD3ED32D0} 71 | {D19CFB61-47C8-4255-A690-581C50B9D17A} = {081F91DD-336C-4BB1-B619-ED0DD3ED32D0} 72 | {F0B7FC94-9415-409E-84B9-60B511C823B7} = {462BF9C1-AE31-4443-B4E1-C5B42ABB4EA3} 73 | EndGlobalSection 74 | EndGlobal 75 | -------------------------------------------------------------------------------- /src/cs/samples/Samples.Triangle/Program.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Bottlenose Labs Inc. (https://github.com/bottlenoselabs). All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the Git repository root directory for full license information. 3 | 4 | using System; 5 | using System.IO; 6 | using System.Numerics; 7 | using System.Runtime.CompilerServices; 8 | using System.Runtime.InteropServices; 9 | using bottlenoselabs.Interop.Sokol; 10 | using static bottlenoselabs.Interop.Sokol.PInvoke; 11 | 12 | namespace Samples 13 | { 14 | internal static unsafe class Program 15 | { 16 | private struct Vertex 17 | { 18 | public Vector3 Position; 19 | public Rgba32F Color; 20 | } 21 | 22 | private struct ProgramState 23 | { 24 | public Graphics.Shader Shader; 25 | public Graphics.Pipeline Pipeline; 26 | public Graphics.Bindings Bindings; 27 | } 28 | 29 | private static ProgramState _state; 30 | 31 | private static void Main() 32 | { 33 | var desc = default(App.Desc); 34 | desc.InitCb.Pointer = &Initialize; 35 | desc.FrameCb.Pointer = &Frame; 36 | desc.Width = 400; 37 | desc.Height = 300; 38 | desc.WindowTitle = "Triangle"; 39 | desc.Icon.SokolDefault = true; 40 | 41 | App.Run(&desc); 42 | } 43 | 44 | [UnmanagedCallersOnly] 45 | private static void Initialize() 46 | { 47 | var desc = default(Graphics.Desc); 48 | desc.Context = App.Sgcontext(); 49 | Graphics.Setup(&desc); 50 | 51 | CreateResources(); 52 | } 53 | 54 | private static void CreateResources() 55 | { 56 | _state.Bindings.VertexBuffers[0] = CreateVertexBuffer(); 57 | _state.Shader = CreateShader(); 58 | _state.Pipeline = CreatePipeline(_state.Shader); 59 | } 60 | 61 | [UnmanagedCallersOnly] 62 | private static void Frame() 63 | { 64 | var width = App.Width(); 65 | var height = App.Height(); 66 | var action = default(Graphics.PassAction); 67 | 68 | ref var colorAttachment = ref action.Colors[0]; 69 | colorAttachment.LoadAction = Graphics.LoadAction.Clear; 70 | colorAttachment.ClearValue = Rgba32F.Black; 71 | Graphics.BeginDefaultPass(&action, width, height); 72 | 73 | Graphics.ApplyPipeline(_state.Pipeline); 74 | Graphics.ApplyBindings((Graphics.Bindings*)Unsafe.AsPointer(ref _state.Bindings)); 75 | Graphics.Draw(0, 3, 1); 76 | 77 | Graphics.EndPass(); 78 | Graphics.Commit(); 79 | } 80 | 81 | private static Graphics.Buffer CreateVertexBuffer() 82 | { 83 | var vertices = (Span)stackalloc Vertex[3]; 84 | 85 | vertices[0].Position = new Vector3(0.0f, 0.5f, 0.5f); 86 | vertices[0].Color = Rgba32F.Red; 87 | vertices[1].Position = new Vector3(0.5f, -0.5f, 0.5f); 88 | vertices[1].Color = Rgba32F.Green; 89 | vertices[2].Position = new Vector3(-0.5f, -0.5f, 0.5f); 90 | vertices[2].Color = Rgba32F.Blue; 91 | 92 | var desc = new Graphics.BufferDesc 93 | { 94 | Usage = Graphics.Usage.Immutable, 95 | Type = Graphics.BufferType.Vertexbuffer 96 | }; 97 | 98 | ref var reference = ref MemoryMarshal.GetReference(vertices); 99 | desc.Data.Ptr = Unsafe.AsPointer(ref reference); 100 | desc.Data.Size = (uint)(Marshal.SizeOf() * vertices.Length); 101 | 102 | return Graphics.MakeBuffer(&desc); 103 | } 104 | 105 | private static Graphics.Shader CreateShader() 106 | { 107 | var desc = default(Graphics.ShaderDesc); 108 | 109 | ref var attribute0 = ref desc.Attrs[0]; 110 | ref var attribute1 = ref desc.Attrs[1]; 111 | 112 | switch (Graphics.QueryBackend()) 113 | { 114 | case Graphics.Backend.Glcore33: 115 | desc.Vs.Source = File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "assets/shaders/opengl/mainVert.glsl")); 116 | desc.Fs.Source = File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "assets/shaders/opengl/mainFrag.glsl")); 117 | break; 118 | case Graphics.Backend.MetalIos: 119 | case Graphics.Backend.MetalMacos: 120 | case Graphics.Backend.MetalSimulator: 121 | desc.Vs.Source = File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "assets/shaders/metal/mainVert.metal")); 122 | desc.Fs.Source = File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "assets/shaders/metal/mainFrag.metal")); 123 | break; 124 | case Graphics.Backend.D3d11: 125 | desc.Vs.Source = File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "assets/shaders/d3d11/mainVert.hlsl")); 126 | desc.Fs.Source = File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "assets/shaders/d3d11/mainFrag.hlsl")); 127 | attribute0.SemName = "POS"; 128 | attribute1.SemName = "COLOR"; 129 | break; 130 | case Graphics.Backend.Dummy: 131 | case Graphics.Backend.Gles3: 132 | case Graphics.Backend.Wgpu: 133 | throw new NotImplementedException(); 134 | default: 135 | throw new ArgumentOutOfRangeException(); 136 | } 137 | 138 | return Graphics.MakeShader(&desc); 139 | } 140 | 141 | private static Graphics.Pipeline CreatePipeline(Graphics.Shader shader) 142 | { 143 | var desc = new Graphics.PipelineDesc 144 | { 145 | Shader = shader 146 | }; 147 | 148 | desc.Layout.Attrs[0].Format = Graphics.VertexFormat.Float3; 149 | desc.Layout.Attrs[1].Format = Graphics.VertexFormat.Float4; 150 | 151 | return Graphics.MakePipeline(&desc); 152 | } 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /src/cs/production/Interop.Sokol/Rgb8U.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Bottlenose Labs Inc. (https://github.com/bottlenoselabs). All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the Git repository root directory for full license information. 3 | 4 | #nullable enable 5 | 6 | using System; 7 | using System.Diagnostics.CodeAnalysis; 8 | using System.Globalization; 9 | using System.Runtime.InteropServices; 10 | using JetBrains.Annotations; 11 | 12 | namespace bottlenoselabs.Interop.Sokol; 13 | 14 | /// 15 | /// 16 | /// A pixel color value type with 8 bits each for the 3 un-signed integer components: red, green, and blue. 17 | /// 18 | /// 19 | /// 20 | /// is mutable on purpose for easier use when working with the components directly. 21 | /// 22 | /// 23 | /// is blittable. 24 | /// 25 | /// 26 | [PublicAPI] 27 | [StructLayout(LayoutKind.Sequential)] 28 | public partial struct Rgb8U : IEquatable 29 | { 30 | /// 31 | /// The red component value. 32 | /// 33 | public byte R; 34 | 35 | /// 36 | /// The green component value. 37 | /// 38 | public byte G; 39 | 40 | /// 41 | /// The blue component value. 42 | /// 43 | public byte B; 44 | 45 | /// 46 | /// Initializes a new instance of the struct using values. 47 | /// 48 | /// The red component value. 49 | /// The green component value. 50 | /// The blue component value. 51 | public Rgb8U(byte r, byte g, byte b) 52 | { 53 | R = r; 54 | G = g; 55 | B = b; 56 | } 57 | 58 | /// 59 | /// Initializes a new instance of the struct using a packed RGB value. 60 | /// 61 | /// The packed value with the format 0x00RRGGBB. 62 | public Rgb8U(uint value) 63 | { 64 | R = (byte)((value >> 16) & 0xFF); 65 | G = (byte)((value >> 8) & 0xFF); 66 | B = (byte)(value & 0xFF); 67 | } 68 | 69 | /// 70 | /// Initializes a new instance of the struct using a hexadecimal packed RGB 71 | /// value. 72 | /// 73 | /// The packed value with the format 0x00RRGGBB. 74 | public Rgb8U(string value) 75 | { 76 | var span = value.AsSpan(); 77 | if (span[0] == '#') 78 | { 79 | span = span.Slice(1); 80 | } 81 | 82 | if (!uint.TryParse(span, NumberStyles.HexNumber, null, out var u)) 83 | { 84 | throw new ArgumentException($"Failed to parse the hex rgb '{value}' as an unsigned 32-bit integer."); 85 | } 86 | 87 | u = uint.Parse(span, NumberStyles.HexNumber, CultureInfo.InvariantCulture); 88 | 89 | R = (byte)((u >> 16) & 0xFF); 90 | G = (byte)((u >> 8) & 0xFF); 91 | B = (byte)(u & 0xFF); 92 | } 93 | 94 | /// 95 | /// Compares two structs for equality. 96 | /// 97 | /// The first struct. 98 | /// The second struct. 99 | /// true if and are equal; otherwise, false. 100 | public static bool operator ==(Rgb8U a, Rgb8U b) 101 | { 102 | return a.Equals(b); 103 | } 104 | 105 | /// 106 | /// Compares two structs for inequality. 107 | /// 108 | /// The first struct. 109 | /// The second struct. 110 | /// true if and are not equal; otherwise, false. 111 | public static bool operator !=(Rgb8U a, Rgb8U b) 112 | { 113 | return !(a == b); 114 | } 115 | 116 | /// 117 | /// Vector subtraction of two structs. 118 | /// 119 | /// The first struct. 120 | /// The second struct. 121 | /// 122 | /// The struct resulting from vector subtraction of from 123 | /// . 124 | /// 125 | public static Rgb8U operator -(Rgb8U b, Rgb8U a) 126 | { 127 | var red = (byte)Math.Max(b.R - a.R, 0); 128 | var green = (byte)Math.Max(b.G - a.G, 0); 129 | var blue = (byte)Math.Max(b.B - a.B, 0); 130 | return new Rgb8U(red, green, blue); 131 | } 132 | 133 | /// 134 | /// Vector subtraction of two structs. 135 | /// 136 | /// The first struct. 137 | /// The second struct. 138 | /// 139 | /// The struct resulting from vector subtraction of from 140 | /// . 141 | /// 142 | public static Rgb8U Subtract(Rgb8U b, Rgb8U a) 143 | { 144 | var red = (byte)Math.Max(b.R - a.R, 0); 145 | var green = (byte)Math.Max(b.G - a.G, 0); 146 | var blue = (byte)Math.Max(b.B - a.B, 0); 147 | return new Rgb8U(red, green, blue); 148 | } 149 | 150 | /// 151 | /// Vector addition of two structs. 152 | /// 153 | /// The first struct. 154 | /// The second struct. 155 | /// 156 | /// The struct resulting from vector addition of and . 157 | /// 158 | public static Rgb8U operator +(Rgb8U a, Rgb8U b) 159 | { 160 | var red = (byte)(a.R + b.R); 161 | var green = (byte)(a.G + b.G); 162 | var blue = (byte)(a.B + b.B); 163 | return new Rgb8U(red, green, blue); 164 | } 165 | 166 | /// 167 | /// Vector addition of two structs. 168 | /// 169 | /// The first struct. 170 | /// The second struct. 171 | /// 172 | /// The struct resulting from vector addition of and . 173 | /// 174 | public static Rgb8U Add(Rgb8U a, Rgb8U b) 175 | { 176 | var red = (byte)(a.R + b.R); 177 | var green = (byte)(a.G + b.G); 178 | var blue = (byte)(a.B + b.B); 179 | return new Rgb8U(red, green, blue); 180 | } 181 | 182 | /// 183 | /// Implicit conversion from to using the 184 | /// constructor. 185 | /// 186 | /// The . 187 | /// The converted . 188 | public static implicit operator Rgb8U(uint value) 189 | { 190 | return new Rgb8U(value); 191 | } 192 | 193 | /// 194 | /// Conversion from to using the 195 | /// constructor. 196 | /// 197 | /// The . 198 | /// The converted . 199 | public static Rgb8U ToRgb8U(uint value) 200 | { 201 | return new Rgb8U(value); 202 | } 203 | 204 | /// 205 | /// Implicit conversion from to using the 206 | /// constructor. 207 | /// 208 | /// The . 209 | /// The converted . 210 | public static implicit operator Rgb8U(string value) 211 | { 212 | return new Rgb8U(value); 213 | } 214 | 215 | /// 216 | public readonly override string ToString() 217 | { 218 | return $"R:{R}, G:{G}, B:{B}"; 219 | } 220 | 221 | /// 222 | [SuppressMessage("ReSharper", "NonReadonlyMemberInGetHashCode", Justification = "Mutable value type.")] 223 | public readonly override int GetHashCode() 224 | { 225 | return HashCode.Combine(R, G, B); 226 | } 227 | 228 | /// 229 | public bool Equals(Rgb8U other) 230 | { 231 | return R == other.R && G == other.G && B == other.B; 232 | } 233 | 234 | /// 235 | public override bool Equals(object? obj) 236 | { 237 | return obj is Rgb8U other && Equals(other); 238 | } 239 | } 240 | -------------------------------------------------------------------------------- /src/cs/StyleCop.globalconfig: -------------------------------------------------------------------------------- 1 | # NOTE: Requires .NET 5 SDK (VS2019 16.8 or later) 2 | # but recommended to use .NET 6 SDK for better support and features such as `global_level` 3 | # https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/configuration-files#global-analyzerconfig 4 | is_global = true 5 | 6 | # StyleCop Rules 7 | # Description: StyleCop code analysis rules for C# projects. 8 | 9 | dotnet_diagnostic.SA0001.severity = none 10 | dotnet_diagnostic.SA0002.severity = error 11 | dotnet_diagnostic.SA1000.severity = error 12 | dotnet_diagnostic.SA1001.severity = error 13 | dotnet_diagnostic.SA1002.severity = error 14 | dotnet_diagnostic.SA1003.severity = error 15 | dotnet_diagnostic.SA1004.severity = error 16 | dotnet_diagnostic.SA1005.severity = error 17 | dotnet_diagnostic.SA1006.severity = error 18 | dotnet_diagnostic.SA1007.severity = error 19 | dotnet_diagnostic.SA1008.severity = error 20 | dotnet_diagnostic.SA1009.severity = error 21 | dotnet_diagnostic.SA1010.severity = error 22 | dotnet_diagnostic.SA1011.severity = error 23 | dotnet_diagnostic.SA1012.severity = none 24 | dotnet_diagnostic.SA1013.severity = none 25 | dotnet_diagnostic.SA1014.severity = error 26 | dotnet_diagnostic.SA1015.severity = error 27 | dotnet_diagnostic.SA1016.severity = error 28 | dotnet_diagnostic.SA1017.severity = error 29 | dotnet_diagnostic.SA1018.severity = error 30 | dotnet_diagnostic.SA1019.severity = error 31 | dotnet_diagnostic.SA1020.severity = error 32 | dotnet_diagnostic.SA1021.severity = error 33 | dotnet_diagnostic.SA1022.severity = error 34 | dotnet_diagnostic.SA1023.severity = error 35 | dotnet_diagnostic.SA1024.severity = error 36 | dotnet_diagnostic.SA1025.severity = error 37 | dotnet_diagnostic.SA1026.severity = error 38 | dotnet_diagnostic.SA1027.severity = error 39 | dotnet_diagnostic.SA1028.severity = error 40 | 41 | dotnet_diagnostic.SA1100.severity = error 42 | dotnet_diagnostic.SA1101.severity = none 43 | dotnet_diagnostic.SA1102.severity = error 44 | dotnet_diagnostic.SA1103.severity = error 45 | dotnet_diagnostic.SA1104.severity = error 46 | dotnet_diagnostic.SA1105.severity = error 47 | dotnet_diagnostic.SA1106.severity = error 48 | dotnet_diagnostic.SA1107.severity = error 49 | dotnet_diagnostic.SA1108.severity = error 50 | dotnet_diagnostic.SA1109.severity = error 51 | dotnet_diagnostic.SA1110.severity = error 52 | dotnet_diagnostic.SA1111.severity = error 53 | dotnet_diagnostic.SA1112.severity = error 54 | dotnet_diagnostic.SA1113.severity = error 55 | dotnet_diagnostic.SA1114.severity = error 56 | dotnet_diagnostic.SA1115.severity = error 57 | dotnet_diagnostic.SA1116.severity = error 58 | dotnet_diagnostic.SA1117.severity = error 59 | dotnet_diagnostic.SA1118.severity = error 60 | dotnet_diagnostic.SA1119.severity = error 61 | dotnet_diagnostic.SA1120.severity = error 62 | dotnet_diagnostic.SA1121.severity = error 63 | dotnet_diagnostic.SA1122.severity = error 64 | dotnet_diagnostic.SA1123.severity = error 65 | dotnet_diagnostic.SA1124.severity = error 66 | dotnet_diagnostic.SA1125.severity = error 67 | dotnet_diagnostic.SA1126.severity = error 68 | dotnet_diagnostic.SA1127.severity = error 69 | dotnet_diagnostic.SA1128.severity = error 70 | dotnet_diagnostic.SA1129.severity = error 71 | dotnet_diagnostic.SA1130.severity = error 72 | dotnet_diagnostic.SA1131.severity = error 73 | dotnet_diagnostic.SA1132.severity = error 74 | dotnet_diagnostic.SA1133.severity = error 75 | dotnet_diagnostic.SA1134.severity = error 76 | dotnet_diagnostic.SA1135.severity = error 77 | dotnet_diagnostic.SA1136.severity = error 78 | dotnet_diagnostic.SA1137.severity = error 79 | dotnet_diagnostic.SA1138.severity = error 80 | dotnet_diagnostic.SA1139.severity = error 81 | dotnet_diagnostic.SA1140.severity = error 82 | dotnet_diagnostic.SA1141.severity = error 83 | dotnet_diagnostic.SA1142.severity = error 84 | 85 | dotnet_diagnostic.SA1200.severity = error 86 | dotnet_diagnostic.SA1201.severity = none 87 | dotnet_diagnostic.SA1202.severity = none 88 | dotnet_diagnostic.SA1203.severity = none 89 | dotnet_diagnostic.SA1204.severity = error 90 | dotnet_diagnostic.SA1205.severity = error 91 | dotnet_diagnostic.SA1206.severity = error 92 | dotnet_diagnostic.SA1207.severity = error 93 | dotnet_diagnostic.SA1208.severity = error 94 | dotnet_diagnostic.SA1209.severity = error 95 | dotnet_diagnostic.SA1210.severity = error 96 | dotnet_diagnostic.SA1211.severity = error 97 | dotnet_diagnostic.SA1212.severity = error 98 | dotnet_diagnostic.SA1213.severity = error 99 | dotnet_diagnostic.SA1214.severity = none 100 | dotnet_diagnostic.SA1215.severity = error 101 | dotnet_diagnostic.SA1216.severity = error 102 | dotnet_diagnostic.SA1217.severity = error 103 | 104 | dotnet_diagnostic.SA1300.severity = none 105 | dotnet_diagnostic.SA1301.severity = error 106 | dotnet_diagnostic.SA1302.severity = none 107 | dotnet_diagnostic.SA1303.severity = error 108 | dotnet_diagnostic.SA1304.severity = error 109 | dotnet_diagnostic.SA1305.severity = none 110 | dotnet_diagnostic.SA1306.severity = error 111 | dotnet_diagnostic.SA1307.severity = error 112 | dotnet_diagnostic.SA1308.severity = error 113 | dotnet_diagnostic.SA1309.severity = none 114 | dotnet_diagnostic.SA1310.severity = error 115 | dotnet_diagnostic.SA1311.severity = error 116 | dotnet_diagnostic.SA1312.severity = error 117 | dotnet_diagnostic.SA1313.severity = error 118 | dotnet_diagnostic.SA1314.severity = error 119 | dotnet_diagnostic.SA1315.severity = error 120 | dotnet_diagnostic.SA1316.severity = error 121 | 122 | dotnet_diagnostic.SA1400.severity = error 123 | dotnet_diagnostic.SA1401.severity = none 124 | dotnet_diagnostic.SA1402.severity = none 125 | dotnet_diagnostic.SA1403.severity = error 126 | dotnet_diagnostic.SA1404.severity = error 127 | dotnet_diagnostic.SA1405.severity = error 128 | dotnet_diagnostic.SA1406.severity = error 129 | dotnet_diagnostic.SA1407.severity = error 130 | dotnet_diagnostic.SA1408.severity = error 131 | dotnet_diagnostic.SA1409.severity = error 132 | dotnet_diagnostic.SA1410.severity = error 133 | dotnet_diagnostic.SA1411.severity = error 134 | dotnet_diagnostic.SA1412.severity = none 135 | dotnet_diagnostic.SA1413.severity = none 136 | dotnet_diagnostic.SA1414.severity = error 137 | 138 | dotnet_diagnostic.SA1500.severity = error 139 | dotnet_diagnostic.SA1501.severity = error 140 | dotnet_diagnostic.SA1502.severity = error 141 | dotnet_diagnostic.SA1503.severity = error 142 | dotnet_diagnostic.SA1504.severity = error 143 | dotnet_diagnostic.SA1505.severity = error 144 | dotnet_diagnostic.SA1506.severity = error 145 | dotnet_diagnostic.SA1507.severity = error 146 | dotnet_diagnostic.SA1508.severity = error 147 | dotnet_diagnostic.SA1509.severity = error 148 | dotnet_diagnostic.SA1510.severity = error 149 | dotnet_diagnostic.SA1511.severity = error 150 | dotnet_diagnostic.SA1512.severity = none 151 | dotnet_diagnostic.SA1513.severity = error 152 | dotnet_diagnostic.SA1514.severity = none 153 | dotnet_diagnostic.SA1515.severity = none 154 | dotnet_diagnostic.SA1516.severity = error 155 | dotnet_diagnostic.SA1517.severity = error 156 | dotnet_diagnostic.SA1518.severity = error 157 | dotnet_diagnostic.SA1519.severity = error 158 | dotnet_diagnostic.SA1520.severity = error 159 | 160 | dotnet_diagnostic.SA1600.severity = none 161 | dotnet_diagnostic.SA1601.severity = none 162 | dotnet_diagnostic.SA1602.severity = none 163 | dotnet_diagnostic.SA1603.severity = none 164 | dotnet_diagnostic.SA1604.severity = none 165 | dotnet_diagnostic.SA1605.severity = none 166 | dotnet_diagnostic.SA1606.severity = none 167 | dotnet_diagnostic.SA1607.severity = none 168 | dotnet_diagnostic.SA1608.severity = none 169 | dotnet_diagnostic.SA1609.severity = none 170 | dotnet_diagnostic.SA1610.severity = none 171 | dotnet_diagnostic.SA1611.severity = none 172 | dotnet_diagnostic.SA1612.severity = none 173 | dotnet_diagnostic.SA1613.severity = none 174 | dotnet_diagnostic.SA1614.severity = none 175 | dotnet_diagnostic.SA1615.severity = none 176 | dotnet_diagnostic.SA1616.severity = none 177 | dotnet_diagnostic.SA1617.severity = none 178 | dotnet_diagnostic.SA1618.severity = none 179 | dotnet_diagnostic.SA1619.severity = none 180 | dotnet_diagnostic.SA1620.severity = none 181 | dotnet_diagnostic.SA1621.severity = none 182 | dotnet_diagnostic.SA1622.severity = none 183 | dotnet_diagnostic.SA1623.severity = none 184 | dotnet_diagnostic.SA1624.severity = none 185 | dotnet_diagnostic.SA1625.severity = none 186 | dotnet_diagnostic.SA1626.severity = none 187 | dotnet_diagnostic.SA1627.severity = none 188 | dotnet_diagnostic.SA1628.severity = none 189 | dotnet_diagnostic.SA1629.severity = none 190 | dotnet_diagnostic.SA1630.severity = none 191 | dotnet_diagnostic.SA1631.severity = none 192 | dotnet_diagnostic.SA1632.severity = none 193 | dotnet_diagnostic.SA1633.severity = error 194 | dotnet_diagnostic.SA1634.severity = none 195 | dotnet_diagnostic.SA1635.severity = none 196 | dotnet_diagnostic.SA1636.severity = none 197 | dotnet_diagnostic.SA1637.severity = none 198 | dotnet_diagnostic.SA1638.severity = none 199 | dotnet_diagnostic.SA1639.severity = none 200 | dotnet_diagnostic.SA1640.severity = none 201 | dotnet_diagnostic.SA1641.severity = none 202 | dotnet_diagnostic.SA1642.severity = none 203 | dotnet_diagnostic.SA1643.severity = none 204 | dotnet_diagnostic.SA1644.severity = none 205 | dotnet_diagnostic.SA1645.severity = none 206 | dotnet_diagnostic.SA1646.severity = none 207 | dotnet_diagnostic.SA1647.severity = none 208 | dotnet_diagnostic.SA1648.severity = none 209 | dotnet_diagnostic.SA1649.severity = none 210 | dotnet_diagnostic.SA1650.severity = none 211 | dotnet_diagnostic.SA1651.severity = none 212 | dotnet_diagnostic.SA1652.severity = none 213 | 214 | dotnet_diagnostic.SX1101.severity = error 215 | dotnet_diagnostic.SX1309.severity = error 216 | dotnet_diagnostic.SX1309S.severity = error -------------------------------------------------------------------------------- /src/cs/production/Interop.Sokol/Rgba8U.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Bottlenose Labs Inc. (https://github.com/bottlenoselabs). All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the Git repository root directory for full license information. 3 | 4 | #nullable enable 5 | 6 | using System; 7 | using System.Diagnostics.CodeAnalysis; 8 | using System.Globalization; 9 | using JetBrains.Annotations; 10 | 11 | namespace bottlenoselabs.Interop.Sokol; 12 | 13 | /// 14 | /// 15 | /// A pixel color value type with 8 bits each for the 4 un-signed integer components: red, green, blue, and 16 | /// alpha. 17 | /// 18 | /// 19 | /// 20 | /// is mutable on purpose for easier use when working with the components directly. 21 | /// 22 | /// 23 | /// is blittable. 24 | /// 25 | /// 26 | [PublicAPI] 27 | public partial struct Rgba8U : IEquatable 28 | { 29 | /// 30 | /// The red component value. 31 | /// 32 | public byte R; 33 | 34 | /// 35 | /// The green component value. 36 | /// 37 | public byte G; 38 | 39 | /// 40 | /// The blue component value. 41 | /// 42 | public byte B; 43 | 44 | /// 45 | /// The alpha component value. 46 | /// 47 | public byte A; 48 | 49 | /// 50 | /// Initializes a new instance of the structure using specified values. 51 | /// 52 | /// The red component value. 53 | /// The green component value. 54 | /// The blue component value. 55 | /// The alpha component value. 56 | public Rgba8U(byte r, byte g, byte b, byte a) 57 | { 58 | R = r; 59 | G = g; 60 | B = b; 61 | A = a; 62 | } 63 | 64 | /// 65 | /// Initializes a new instance of the struct using a packed RGBA value. 66 | /// 67 | /// The packed value with the format 0xRRGGBBAA. 68 | public Rgba8U(uint value) 69 | { 70 | R = (byte)((value >> 24) & 0xFF); 71 | G = (byte)((value >> 16) & 0xFF); 72 | B = (byte)((value >> 8) & 0xFF); 73 | A = (byte)(value & 0xFF); 74 | } 75 | 76 | /// 77 | /// Initializes a new instance of the struct using a hexadecimal packed RGBA 78 | /// value. 79 | /// 80 | /// The packed value with the format 0xRRGGBBAA. 81 | public Rgba8U(string value) 82 | { 83 | var span = value.AsSpan(); 84 | if (span[0] == '#') 85 | { 86 | span = span.Slice(1); 87 | } 88 | 89 | if (!uint.TryParse(span, NumberStyles.HexNumber, null, out var u)) 90 | { 91 | throw new ArgumentException($"Failed to parse the hex rgba '{value}' as an unsigned 32-bit integer."); 92 | } 93 | 94 | u = uint.Parse(span, NumberStyles.HexNumber, CultureInfo.InvariantCulture); 95 | 96 | R = (byte)((u >> 24) & 0xFF); 97 | G = (byte)((u >> 16) & 0xFF); 98 | B = (byte)((u >> 8) & 0xFF); 99 | A = (byte)(u & 0xFF); 100 | } 101 | 102 | /// 103 | /// Compares two structs for equality. 104 | /// 105 | /// The first struct. 106 | /// The second struct. 107 | /// true if and are equal; otherwise, false. 108 | public static bool operator ==(Rgba8U a, Rgba8U b) 109 | { 110 | return a.Equals(b); 111 | } 112 | 113 | /// 114 | /// Compares two structs for inequality. 115 | /// 116 | /// The first struct. 117 | /// The second struct. 118 | /// true if and are not equal; otherwise, false. 119 | public static bool operator !=(Rgba8U a, Rgba8U b) 120 | { 121 | return !(a == b); 122 | } 123 | 124 | /// 125 | /// Vector subtraction of two structs. 126 | /// 127 | /// The first struct. 128 | /// The second struct. 129 | /// 130 | /// The struct resulting from vector subtraction of from 131 | /// . 132 | /// 133 | public static Rgba8U operator -(Rgba8U b, Rgba8U a) 134 | { 135 | var red = (byte)Math.Max(b.R - a.R, 0); 136 | var green = (byte)Math.Max(b.G - a.G, 0); 137 | var blue = (byte)Math.Max(b.B - a.B, 0); 138 | var alpha = (byte)Math.Max(b.A - a.A, 0); 139 | return new Rgba8U(red, green, blue, alpha); 140 | } 141 | 142 | /// 143 | /// Vector subtraction of two structs. 144 | /// 145 | /// The first struct. 146 | /// The second struct. 147 | /// 148 | /// The struct resulting from vector subtraction of from 149 | /// . 150 | /// 151 | public static Rgba8U Subtract(Rgba8U b, Rgba8U a) 152 | { 153 | var red = (byte)Math.Max(b.R - a.R, 0); 154 | var green = (byte)Math.Max(b.G - a.G, 0); 155 | var blue = (byte)Math.Max(b.B - a.B, 0); 156 | var alpha = (byte)Math.Max(b.A - a.A, 0); 157 | return new Rgba8U(red, green, blue, alpha); 158 | } 159 | 160 | /// 161 | /// Vector addition of two structs. 162 | /// 163 | /// The first struct. 164 | /// The second struct. 165 | /// 166 | /// The struct resulting from vector addition of and . 167 | /// 168 | public static Rgba8U operator +(Rgba8U a, Rgba8U b) 169 | { 170 | var red = (byte)(a.R + b.R); 171 | var green = (byte)(a.G + b.G); 172 | var blue = (byte)(a.B + b.B); 173 | var alpha = (byte)(a.A + b.A); 174 | return new Rgba8U(red, green, blue, alpha); 175 | } 176 | 177 | /// 178 | /// Vector addition of two structs. 179 | /// 180 | /// The first struct. 181 | /// The second struct. 182 | /// 183 | /// The struct resulting from vector addition of and . 184 | /// 185 | public static Rgba8U Add(Rgba8U a, Rgba8U b) 186 | { 187 | var red = (byte)(a.R + b.R); 188 | var green = (byte)(a.G + b.G); 189 | var blue = (byte)(a.B + b.B); 190 | var alpha = (byte)(a.A + b.A); 191 | return new Rgba8U(red, green, blue, alpha); 192 | } 193 | 194 | /// 195 | /// Implicit conversion from to using the 196 | /// constructor. 197 | /// 198 | /// The . 199 | /// The struct resulting from converting . 200 | public static implicit operator Rgba8U(uint value) 201 | { 202 | return new Rgba8U(value); 203 | } 204 | 205 | /// 206 | /// Conversion from to using the 207 | /// constructor. 208 | /// 209 | /// The . 210 | /// The struct resulting from converting . 211 | public static Rgba8U ToRgba8U(uint value) 212 | { 213 | return new Rgba8U(value); 214 | } 215 | 216 | /// 217 | /// Implicit conversion from to using the 218 | /// constructor. 219 | /// 220 | /// The . 221 | /// The struct resulting from converting . 222 | public static implicit operator Rgba8U(string value) 223 | { 224 | return new Rgba8U(value); 225 | } 226 | 227 | /// 228 | public readonly override string ToString() 229 | { 230 | return $"R:{R}, G:{G}, B:{B}, A:{A}"; 231 | } 232 | 233 | /// 234 | [SuppressMessage("ReSharper", "NonReadonlyMemberInGetHashCode", Justification = "Mutable value type.")] 235 | public readonly override int GetHashCode() 236 | { 237 | return HashCode.Combine(R, G, B, A); 238 | } 239 | 240 | /// 241 | public bool Equals(Rgba8U other) 242 | { 243 | return R == other.R && G == other.G && B == other.B && A == other.A; 244 | } 245 | 246 | /// 247 | public override bool Equals(object? obj) 248 | { 249 | return obj is Rgba8U other && Equals(other); 250 | } 251 | } 252 | -------------------------------------------------------------------------------- /src/cs/production/Interop.Sokol/Rgb32F.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Bottlenose Labs Inc. (https://github.com/bottlenoselabs). All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the Git repository root directory for full license information. 3 | 4 | #nullable enable 5 | 6 | using System; 7 | using System.Diagnostics.CodeAnalysis; 8 | using System.Globalization; 9 | using System.Numerics; 10 | using JetBrains.Annotations; 11 | 12 | namespace bottlenoselabs.Interop.Sokol; 13 | 14 | /// 15 | /// 16 | /// A pixel color value type with 32 bits each for the 3 float components: red, green, and blue. 17 | /// 18 | /// 19 | /// 20 | /// is mutable on purpose for easier use when working with the components directly. 21 | /// 22 | /// 23 | /// is blittable. 24 | /// 25 | /// 26 | [PublicAPI] 27 | public partial struct Rgb32F : IEquatable 28 | { 29 | /// 30 | /// The red component value. 31 | /// 32 | public float R; 33 | 34 | /// 35 | /// The green component value. 36 | /// 37 | public float G; 38 | 39 | /// 40 | /// The blue component value. 41 | /// 42 | public float B; 43 | 44 | /// 45 | /// Initializes a new instance of the structure using float values. 46 | /// 47 | /// The red component value. 48 | /// The green component value. 49 | /// The blue component value. 50 | public Rgb32F(float r, float g, float b) 51 | { 52 | R = r; 53 | G = g; 54 | B = b; 55 | } 56 | 57 | /// 58 | /// Initializes a new instance of the struct using a packed RGB value. 59 | /// 60 | /// The packed value with the format 0x00RRGGBB. 61 | public Rgb32F(uint value) 62 | { 63 | R = ((value >> 16) & 0xFF) / 255f; 64 | G = ((value >> 8) & 0xFF) / 255f; 65 | B = (value & 0xFF) / 255f; 66 | } 67 | 68 | /// 69 | /// Initializes a new instance of the struct using a hexadecimal packed RGB 70 | /// value. 71 | /// 72 | /// The packed value with the format 0x00RRGGBB. 73 | public Rgb32F(string value) 74 | { 75 | var span = value.AsSpan(); 76 | if (span[0] == '#') 77 | { 78 | span = span.Slice(1); 79 | } 80 | 81 | if (!uint.TryParse(span, NumberStyles.HexNumber, null, out var u)) 82 | { 83 | throw new ArgumentException($"Failed to parse the hex rgb '{value}' as an unsigned 32-bit integer."); 84 | } 85 | 86 | u = uint.Parse(span, NumberStyles.HexNumber, CultureInfo.InvariantCulture); 87 | 88 | R = ((u >> 16) & 0xFF) / 255f; 89 | G = ((u >> 8) & 0xFF) / 255f; 90 | B = (u & 0xFF) / 255f; 91 | } 92 | 93 | /// 94 | /// Initializes a new instance of the structure using a interpreted as a 95 | /// RGB pixel color. 96 | /// 97 | /// The vector value. 98 | public Rgb32F(Vector3 vector3) 99 | { 100 | R = vector3.X; 101 | G = vector3.Y; 102 | B = vector3.Z; 103 | } 104 | 105 | /// 106 | /// Compares two structs for equality. 107 | /// 108 | /// The first struct. 109 | /// The second struct. 110 | /// true if and are equal; otherwise, false. 111 | public static bool operator ==(Rgb32F a, Rgb32F b) 112 | { 113 | return a.Equals(b); 114 | } 115 | 116 | /// 117 | /// Compares two structs for inequality. 118 | /// 119 | /// The first struct. 120 | /// The second struct. 121 | /// true if and are not equal; otherwise, false. 122 | public static bool operator !=(Rgb32F a, Rgb32F b) 123 | { 124 | return !(a == b); 125 | } 126 | 127 | /// 128 | /// Vector subtraction of two structs. 129 | /// 130 | /// The first struct. 131 | /// The second struct. 132 | /// 133 | /// The struct resulting from vector subtraction of from 134 | /// . 135 | /// 136 | public static Rgb32F operator -(Rgb32F b, Rgb32F a) 137 | { 138 | var red = Math.Max(b.R - a.R, 0); 139 | var green = Math.Max(b.G - a.G, 0); 140 | var blue = Math.Max(b.B - a.B, 0); 141 | return new Rgb32F(red, green, blue); 142 | } 143 | 144 | /// 145 | /// Vector subtraction of two structs. 146 | /// 147 | /// The first struct. 148 | /// The second struct. 149 | /// 150 | /// The struct resulting from vector subtraction of from 151 | /// . 152 | /// 153 | public static Rgb32F Subtract(Rgb32F b, Rgb32F a) 154 | { 155 | var red = Math.Max(b.R - a.R, 0); 156 | var green = Math.Max(b.G - a.G, 0); 157 | var blue = Math.Max(b.B - a.B, 0); 158 | return new Rgb32F(red, green, blue); 159 | } 160 | 161 | /// 162 | /// Vector addition of two structs. 163 | /// 164 | /// The first struct. 165 | /// The second struct. 166 | /// 167 | /// The struct resulting from vector addition of and . 168 | /// 169 | public static Rgb32F operator +(Rgb32F a, Rgb32F b) 170 | { 171 | var red = a.R + b.R; 172 | var green = a.G + b.G; 173 | var blue = a.B + b.B; 174 | return new Rgb32F(red, green, blue); 175 | } 176 | 177 | /// 178 | /// Vector addition of two structs. 179 | /// 180 | /// The first struct. 181 | /// The second struct. 182 | /// 183 | /// The struct resulting from vector addition of and . 184 | /// 185 | public static Rgb32F Add(Rgb32F a, Rgb32F b) 186 | { 187 | var red = a.R + b.R; 188 | var green = a.G + b.G; 189 | var blue = a.B + b.B; 190 | return new Rgb32F(red, green, blue); 191 | } 192 | 193 | /// 194 | /// Implicit conversion from to using the 195 | /// constructor. 196 | /// 197 | /// The . 198 | /// The struct resulting from converting . 199 | public static implicit operator Rgb32F(uint value) 200 | { 201 | return new Rgb32F(value); 202 | } 203 | 204 | /// 205 | /// Conversion from to using the 206 | /// constructor. 207 | /// 208 | /// The . 209 | /// The struct resulting from converting . 210 | public static Rgb32F ToRgb32F(uint value) 211 | { 212 | return new Rgb32F(value); 213 | } 214 | 215 | /// 216 | /// Implicit conversion from to using the 217 | /// constructor. 218 | /// 219 | /// The . 220 | /// The struct resulting from converting . 221 | public static implicit operator Rgb32F(string value) 222 | { 223 | return new Rgb32F(value); 224 | } 225 | 226 | /// 227 | /// Implicit conversion from to using the 228 | /// constructor. 229 | /// 230 | /// The . 231 | /// The struct resulting from converting . 232 | public static implicit operator Rgb32F(Vector3 value) 233 | { 234 | return new Rgb32F(value); 235 | } 236 | 237 | /// 238 | public readonly override string ToString() 239 | { 240 | return $"R:{R}, G:{G}, B:{B}"; 241 | } 242 | 243 | /// 244 | [SuppressMessage("ReSharper", "NonReadonlyMemberInGetHashCode", Justification = "Mutable value type.")] 245 | public readonly override int GetHashCode() 246 | { 247 | return HashCode.Combine(R, G, B); 248 | } 249 | 250 | /// 251 | public bool Equals(Rgb32F other) 252 | { 253 | return R.Equals(other.R) && G.Equals(other.G) && B.Equals(other.B); 254 | } 255 | 256 | /// 257 | public override bool Equals(object? obj) 258 | { 259 | return obj is Rgb32F other && Equals(other); 260 | } 261 | } 262 | -------------------------------------------------------------------------------- /src/cs/production/Interop.Sokol/Rgba32F.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Bottlenose Labs Inc. (https://github.com/bottlenoselabs). All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the Git repository root directory for full license information. 3 | 4 | #nullable enable 5 | 6 | using System; 7 | using System.Diagnostics.CodeAnalysis; 8 | using System.Globalization; 9 | using System.Numerics; 10 | using System.Runtime.InteropServices; 11 | using JetBrains.Annotations; 12 | 13 | namespace bottlenoselabs.Interop.Sokol; 14 | 15 | /// 16 | /// 17 | /// A pixel color value type with 32 bits each for the 4 float components: red, green, blue, and alpha. 18 | /// 19 | /// 20 | /// 21 | /// is mutable on purpose for easier use when working with the components directly. 22 | /// 23 | /// 24 | /// is blittable. 25 | /// 26 | /// 27 | [PublicAPI] 28 | [StructLayout(LayoutKind.Sequential)] 29 | public partial struct Rgba32F : IEquatable 30 | { 31 | /// 32 | /// The red component value. 33 | /// 34 | public float R; 35 | 36 | /// 37 | /// The green component value. 38 | /// 39 | public float G; 40 | 41 | /// 42 | /// The blue component value. 43 | /// 44 | public float B; 45 | 46 | /// 47 | /// The alpha component value. 48 | /// 49 | public float A; 50 | 51 | /// 52 | /// Initializes a new instance of the structure using float values. 53 | /// 54 | /// The red component value. 55 | /// The green component value. 56 | /// The blue component value. 57 | /// The alpha component value. 58 | public Rgba32F(float r, float g, float b, float a) 59 | { 60 | R = r; 61 | G = g; 62 | B = b; 63 | A = a; 64 | } 65 | 66 | /// 67 | /// Initializes a new instance of the struct using a packed RGBA value. 68 | /// 69 | /// The packed value with the format 0xRRGGBBAA. 70 | public Rgba32F(uint value) 71 | { 72 | R = ((value >> 24) & 0xFF) / 255f; 73 | G = ((value >> 16) & 0xFF) / 255f; 74 | B = ((value >> 8) & 0xFF) / 255f; 75 | A = (value & 0xFF) / 255f; 76 | } 77 | 78 | /// 79 | /// Initializes a new instance of the struct using a hexadecimal packed RGBA 80 | /// value. 81 | /// 82 | /// The packed value with the format 0xRRGGBBAA. 83 | public Rgba32F(string value) 84 | { 85 | var span = value.AsSpan(); 86 | if (span[0] == '#') 87 | { 88 | span = span.Slice(1); 89 | } 90 | 91 | if (!uint.TryParse(span, NumberStyles.HexNumber, null, out var u)) 92 | { 93 | throw new ArgumentException($"Failed to parse the hex rgba '{value}' as an unsigned 32-bit integer."); 94 | } 95 | 96 | u = uint.Parse(span, NumberStyles.HexNumber, CultureInfo.InvariantCulture); 97 | 98 | R = ((u >> 24) & 0xFF) / 255f; 99 | G = ((u >> 16) & 0xFF) / 255f; 100 | B = ((u >> 8) & 0xFF) / 255f; 101 | A = (u & 0xFF) / 255f; 102 | } 103 | 104 | /// 105 | /// Initializes a new instance of the structure using a 106 | /// interpreted as a RGBA pixel color. 107 | /// 108 | /// The vector value. 109 | public Rgba32F(Vector4 vector4) 110 | { 111 | R = vector4.X; 112 | G = vector4.Y; 113 | B = vector4.Z; 114 | A = vector4.W; 115 | } 116 | 117 | /// 118 | /// Compares two structs for equality. 119 | /// 120 | /// The first struct. 121 | /// The second struct. 122 | /// true if and are equal; otherwise, false. 123 | public static bool operator ==(Rgba32F a, Rgba32F b) 124 | { 125 | return a.Equals(b); 126 | } 127 | 128 | /// 129 | /// Compares two structs for inequality. 130 | /// 131 | /// The first struct. 132 | /// The second struct. 133 | /// true if and are not equal; otherwise, false. 134 | public static bool operator !=(Rgba32F a, Rgba32F b) 135 | { 136 | return !(a == b); 137 | } 138 | 139 | /// 140 | /// Vector subtraction of two structs. 141 | /// 142 | /// The first struct. 143 | /// The second struct. 144 | /// 145 | /// The struct resulting from vector subtraction of from 146 | /// . 147 | /// 148 | public static Rgba32F operator -(Rgba32F b, Rgba32F a) 149 | { 150 | var red = Math.Max(b.R - a.R, 0); 151 | var green = Math.Max(b.G - a.G, 0); 152 | var blue = Math.Max(b.B - a.B, 0); 153 | var alpha = Math.Max(b.A - a.A, 0); 154 | return new Rgba32F(red, green, blue, alpha); 155 | } 156 | 157 | /// 158 | /// Vector subtraction of two structs. 159 | /// 160 | /// The first struct. 161 | /// The second struct. 162 | /// 163 | /// The struct resulting from vector subtraction of from 164 | /// . 165 | /// 166 | public static Rgba32F Subtract(Rgba32F b, Rgba32F a) 167 | { 168 | var red = Math.Max(b.R - a.R, 0); 169 | var green = Math.Max(b.G - a.G, 0); 170 | var blue = Math.Max(b.B - a.B, 0); 171 | var alpha = Math.Max(b.A - a.A, 0); 172 | return new Rgba32F(red, green, blue, alpha); 173 | } 174 | 175 | /// 176 | /// Vector addition of two structs. 177 | /// 178 | /// The first struct. 179 | /// The second struct. 180 | /// 181 | /// The struct resulting from vector addition of and 182 | /// . 183 | /// 184 | public static Rgba32F operator +(Rgba32F a, Rgba32F b) 185 | { 186 | var red = a.R + b.R; 187 | var green = a.G + b.G; 188 | var blue = a.B + b.B; 189 | var alpha = a.A + b.A; 190 | return new Rgba32F(red, green, blue, alpha); 191 | } 192 | 193 | /// 194 | /// Vector addition of two structs. 195 | /// 196 | /// The first struct. 197 | /// The second struct. 198 | /// 199 | /// The struct resulting from vector addition of and 200 | /// . 201 | /// 202 | public static Rgba32F Add(Rgba32F a, Rgba32F b) 203 | { 204 | var red = a.R + b.R; 205 | var green = a.G + b.G; 206 | var blue = a.B + b.B; 207 | var alpha = a.A + b.A; 208 | return new Rgba32F(red, green, blue, alpha); 209 | } 210 | 211 | /// 212 | /// Implicit conversion from to using the 213 | /// constructor. 214 | /// 215 | /// The . 216 | /// The struct resulting from converting . 217 | public static implicit operator Rgba32F(uint value) 218 | { 219 | return new Rgba32F(value); 220 | } 221 | 222 | /// 223 | /// Implicit conversion from to using the 224 | /// constructor. 225 | /// 226 | /// The . 227 | /// The struct resulting from converting . 228 | public static Rgba32F ToRgba32F(uint value) 229 | { 230 | return new Rgba32F(value); 231 | } 232 | 233 | /// 234 | /// Conversion from to using the 235 | /// constructor. 236 | /// 237 | /// The . 238 | /// The struct resulting from converting . 239 | public static implicit operator Rgba32F(string value) 240 | { 241 | return new Rgba32F(value); 242 | } 243 | 244 | /// 245 | /// Implicit conversion from to using the 246 | /// constructor. 247 | /// 248 | /// The . 249 | /// The struct resulting from converting . 250 | public static implicit operator Rgba32F(Vector4 value) 251 | { 252 | return new Rgba32F(value); 253 | } 254 | 255 | /// 256 | public readonly override string ToString() 257 | { 258 | return $"R:{R}, G:{G}, B:{B}, A:{A}"; 259 | } 260 | 261 | /// 262 | [SuppressMessage("ReSharper", "NonReadonlyMemberInGetHashCode", Justification = "Mutable value type.")] 263 | public readonly override int GetHashCode() 264 | { 265 | return HashCode.Combine(R, G, B, A); 266 | } 267 | 268 | /// 269 | public bool Equals(Rgba32F other) 270 | { 271 | return R.Equals(other.R) && G.Equals(other.G) && B.Equals(other.B) && A.Equals(other.A); 272 | } 273 | 274 | /// 275 | public override bool Equals(object? obj) 276 | { 277 | return obj is Rgba32F other && Equals(other); 278 | } 279 | } 280 | -------------------------------------------------------------------------------- /src/cs/samples/Cube/Program.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Bottlenose Labs Inc. (https://github.com/bottlenoselabs). All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the Git repository root directory for full license information. 3 | 4 | using System; 5 | using System.IO; 6 | using System.Numerics; 7 | using System.Runtime.CompilerServices; 8 | using System.Runtime.InteropServices; 9 | using bottlenoselabs.Interop.Sokol; 10 | using static bottlenoselabs.Interop.Sokol.PInvoke; 11 | 12 | namespace Samples; 13 | 14 | internal static unsafe class Program 15 | { 16 | private struct Vertex 17 | { 18 | public Vector3 Position; 19 | public Rgba32F Color; 20 | } 21 | 22 | private struct VertexShaderParams 23 | { 24 | public Matrix4x4 ModelViewProjection; 25 | } 26 | 27 | private struct ProgramState 28 | { 29 | public Graphics.Bindings Bindings; 30 | public Graphics.Pipeline Pipeline; 31 | 32 | public VertexShaderParams VertexShaderParams; 33 | public float CubeRotationX; 34 | public float CubeRotationY; 35 | 36 | public bool PauseUpdate; 37 | } 38 | 39 | private static ProgramState _state; 40 | 41 | private static void Main() 42 | { 43 | var desc = default(App.Desc); 44 | desc.InitCb.Pointer = &Initialize; 45 | desc.FrameCb.Pointer = &Frame; 46 | desc.EventCb.Pointer = &Event; 47 | desc.Width = 800; 48 | desc.Height = 600; 49 | desc.SampleCount = 4; 50 | desc.WindowTitle = "Cube"; 51 | desc.Icon.SokolDefault = true; 52 | 53 | App.Run(&desc); 54 | } 55 | 56 | [UnmanagedCallersOnly] 57 | private static void Initialize() 58 | { 59 | var desc = default(Graphics.Desc); 60 | desc.Context = App.Sgcontext(); 61 | Graphics.Setup(&desc); 62 | 63 | CreateResources(); 64 | } 65 | 66 | private static void CreateResources() 67 | { 68 | _state.Bindings.VertexBuffers[0] = CreateVertexBuffer(); 69 | _state.Bindings.IndexBuffer = CreateIndexBuffer(); 70 | var shader = CreateShader(); 71 | _state.Pipeline = CreatePipeline(shader); 72 | } 73 | 74 | [UnmanagedCallersOnly] 75 | private static void Frame() 76 | { 77 | Update(); 78 | Draw(); 79 | Graphics.Commit(); 80 | } 81 | 82 | [UnmanagedCallersOnly] 83 | private static void Event(App.Event* e) 84 | { 85 | if (e->Type == App.EventType.KeyUp) 86 | { 87 | _state.PauseUpdate = !_state.PauseUpdate; 88 | } 89 | } 90 | 91 | private static void Update() 92 | { 93 | if (_state.PauseUpdate) 94 | { 95 | return; 96 | } 97 | 98 | RotateCube(); 99 | } 100 | 101 | private static void Draw() 102 | { 103 | var width = App.Width(); 104 | var height = App.Height(); 105 | 106 | var action = default(Graphics.PassAction); 107 | 108 | ref var colorAttachment = ref action.Colors[0]; 109 | colorAttachment.LoadAction = Graphics.LoadAction.Clear; 110 | colorAttachment.ClearValue = Rgba32F.Gray; 111 | Graphics.BeginDefaultPass(&action, width, height); 112 | 113 | Graphics.ApplyPipeline(_state.Pipeline); 114 | Graphics.ApplyBindings((Graphics.Bindings*)Unsafe.AsPointer(ref _state.Bindings)); 115 | 116 | var uniforms = default(Graphics.Range); 117 | uniforms.Ptr = Unsafe.AsPointer(ref _state.VertexShaderParams); 118 | uniforms.Size = (ulong)Marshal.SizeOf(); 119 | Graphics.ApplyUniforms(Graphics.ShaderStage.Vs, 0, &uniforms); 120 | 121 | // draw the cube (36 indices) 122 | // try drawing only parts of the cube by specifying 6, 12, 18, 24 or 30 for the number of indices! 123 | Graphics.Draw(0, 36, 1); 124 | 125 | Graphics.EndPass(); 126 | } 127 | 128 | private static void RotateCube() 129 | { 130 | const float deltaSeconds = 1 / 60f; 131 | 132 | _state.CubeRotationX += 1.0f * deltaSeconds; 133 | _state.CubeRotationY += 2.0f * deltaSeconds; 134 | var rotationMatrixX = Matrix4x4.CreateFromAxisAngle(Vector3.UnitX, _state.CubeRotationX); 135 | var rotationMatrixY = Matrix4x4.CreateFromAxisAngle(Vector3.UnitY, _state.CubeRotationY); 136 | var modelMatrix = rotationMatrixX * rotationMatrixY; 137 | 138 | var width = App.Widthf(); 139 | var height = App.Heightf(); 140 | 141 | var projectionMatrix = Matrix4x4.CreatePerspectiveFieldOfView( 142 | (float)(60.0f * Math.PI / 180), 143 | width / height, 144 | 0.01f, 145 | 10.0f); 146 | var viewMatrix = Matrix4x4.CreateLookAt( 147 | new Vector3(0.0f, 1.5f, 6.0f), 148 | Vector3.Zero, 149 | Vector3.UnitY); 150 | 151 | _state.VertexShaderParams.ModelViewProjection = modelMatrix * viewMatrix * projectionMatrix; 152 | } 153 | 154 | private static Graphics.Buffer CreateVertexBuffer() 155 | { 156 | var vertices = stackalloc Vertex[24]; 157 | 158 | // model vertices of the cube using standard cartesian coordinate system: 159 | // +Z is towards your eyes, -Z is towards the screen 160 | // +X is to the right, -X to the left 161 | // +Y is towards the sky (up), -Y is towards the floor (down) 162 | const float leftX = -1.0f; 163 | const float rightX = 1.0f; 164 | const float bottomY = -1.0f; 165 | const float topY = 1.0f; 166 | const float backZ = -1.0f; 167 | const float frontZ = 1.0f; 168 | 169 | // each face of the cube is a rectangle (two triangles), each rectangle is 4 vertices 170 | // rectangle 1; back 171 | var color1 = Rgba32F.Red; // #FF0000 172 | vertices[0].Position = new Vector3(leftX, bottomY, backZ); 173 | vertices[0].Color = color1; 174 | vertices[1].Position = new Vector3(rightX, bottomY, backZ); 175 | vertices[1].Color = color1; 176 | vertices[2].Position = new Vector3(rightX, topY, backZ); 177 | vertices[2].Color = color1; 178 | vertices[3].Position = new Vector3(leftX, topY, backZ); 179 | vertices[3].Color = color1; 180 | // rectangle 2; front 181 | var color2 = Rgba32F.Lime; // NOTE: "lime" is #00FF00; "green" is actually #008000 182 | vertices[4].Position = new Vector3(leftX, bottomY, frontZ); 183 | vertices[4].Color = color2; 184 | vertices[5].Position = new Vector3(rightX, bottomY, frontZ); 185 | vertices[5].Color = color2; 186 | vertices[6].Position = new Vector3(rightX, topY, frontZ); 187 | vertices[6].Color = color2; 188 | vertices[7].Position = new Vector3(leftX, topY, frontZ); 189 | vertices[7].Color = color2; 190 | // rectangle 3; left 191 | var color3 = Rgba32F.Blue; // #0000FF 192 | vertices[8].Position = new Vector3(leftX, bottomY, backZ); 193 | vertices[8].Color = color3; 194 | vertices[9].Position = new Vector3(leftX, topY, backZ); 195 | vertices[9].Color = color3; 196 | vertices[10].Position = new Vector3(leftX, topY, frontZ); 197 | vertices[10].Color = color3; 198 | vertices[11].Position = new Vector3(leftX, bottomY, frontZ); 199 | vertices[11].Color = color3; 200 | // rectangle 4; right 201 | var color4 = Rgba32F.Yellow; // #FFFF00 202 | vertices[12].Position = new Vector3(rightX, bottomY, backZ); 203 | vertices[12].Color = color4; 204 | vertices[13].Position = new Vector3(rightX, topY, backZ); 205 | vertices[13].Color = color4; 206 | vertices[14].Position = new Vector3(rightX, topY, frontZ); 207 | vertices[14].Color = color4; 208 | vertices[15].Position = new Vector3(rightX, bottomY, frontZ); 209 | vertices[15].Color = color4; 210 | // rectangle 5; bottom 211 | var color5 = Rgba32F.Aqua; // #00FFFF 212 | vertices[16].Position = new Vector3(leftX, bottomY, backZ); 213 | vertices[16].Color = color5; 214 | vertices[17].Position = new Vector3(leftX, bottomY, frontZ); 215 | vertices[17].Color = color5; 216 | vertices[18].Position = new Vector3(rightX, bottomY, frontZ); 217 | vertices[18].Color = color5; 218 | vertices[19].Position = new Vector3(rightX, bottomY, backZ); 219 | vertices[19].Color = color5; 220 | // rectangle 6; top 221 | var color6 = Rgba32F.Fuchsia; // #FF00FF 222 | vertices[20].Position = new Vector3(leftX, topY, backZ); 223 | vertices[20].Color = color6; 224 | vertices[21].Position = new Vector3(leftX, topY, frontZ); 225 | vertices[21].Color = color6; 226 | vertices[22].Position = new Vector3(rightX, topY, frontZ); 227 | vertices[22].Color = color6; 228 | vertices[23].Position = new Vector3(rightX, topY, backZ); 229 | vertices[23].Color = color6; 230 | 231 | var desc = new Graphics.BufferDesc 232 | { 233 | Usage = Graphics.Usage.Immutable, 234 | Type = Graphics.BufferType.Vertexbuffer, 235 | Data = 236 | { 237 | Ptr = vertices, 238 | Size = (uint)(Marshal.SizeOf() * 24) 239 | } 240 | }; 241 | 242 | return Graphics.MakeBuffer(&desc); 243 | } 244 | 245 | private static Graphics.Buffer CreateIndexBuffer() 246 | { 247 | var indices = stackalloc ushort[] 248 | { 249 | 0, 1, 2, 0, 2, 3, // rectangle 1 of cube, back, clockwise, base vertex: 0 250 | 6, 5, 4, 7, 6, 4, // rectangle 2 of cube, front, counter-clockwise, base vertex: 4 251 | 8, 9, 10, 8, 10, 11, // rectangle 3 of cube, left, clockwise, base vertex: 8 252 | 14, 13, 12, 15, 14, 12, // rectangle 4 of cube, right, counter-clockwise, base vertex: 12 253 | 16, 17, 18, 16, 18, 19, // rectangle 5 of cube, bottom, clockwise, base vertex: 16 254 | 22, 21, 20, 23, 22, 20 // rectangle 6 of cube, top, counter-clockwise, base vertex: 20 255 | }; 256 | 257 | var desc = new Graphics.BufferDesc 258 | { 259 | Usage = Graphics.Usage.Immutable, 260 | Type = Graphics.BufferType.Indexbuffer, 261 | Data = 262 | { 263 | Ptr = indices, 264 | Size = (uint)(Marshal.SizeOf() * 36) 265 | } 266 | }; 267 | 268 | return Graphics.MakeBuffer(&desc); 269 | } 270 | 271 | private static Graphics.Shader CreateShader() 272 | { 273 | var desc = default(Graphics.ShaderDesc); 274 | ref var uniformBlock = ref desc.Vs.UniformBlocks[0]; 275 | uniformBlock.Size = (ulong)Marshal.SizeOf(); 276 | ref var mvpUniform = ref uniformBlock.Uniforms[0]; 277 | mvpUniform.Name = "mvp"; 278 | mvpUniform.Type = Graphics.UniformType.Mat4; 279 | 280 | switch (Graphics.QueryBackend()) 281 | { 282 | case Graphics.Backend.Glcore33: 283 | desc.Vs.Source = File.ReadAllText(Path.Combine( 284 | AppContext.BaseDirectory, 285 | "assets/shaders/opengl/mainVert.glsl")); 286 | desc.Fs.Source = File.ReadAllText(Path.Combine( 287 | AppContext.BaseDirectory, 288 | "assets/shaders/opengl/mainFrag.glsl")); 289 | break; 290 | case Graphics.Backend.MetalIos: 291 | case Graphics.Backend.MetalMacos: 292 | case Graphics.Backend.MetalSimulator: 293 | desc.Vs.Source = File.ReadAllText(Path.Combine( 294 | AppContext.BaseDirectory, 295 | "assets/shaders/metal/mainVert.metal")); 296 | desc.Fs.Source = File.ReadAllText(Path.Combine( 297 | AppContext.BaseDirectory, 298 | "assets/shaders/metal/mainFrag.metal")); 299 | break; 300 | case Graphics.Backend.D3d11: 301 | desc.Vs.Source = File.ReadAllText(Path.Combine( 302 | AppContext.BaseDirectory, 303 | "assets/shaders/d3d11/mainVert.hlsl")); 304 | desc.Fs.Source = File.ReadAllText(Path.Combine( 305 | AppContext.BaseDirectory, 306 | "assets/shaders/d3d11/mainFrag.hlsl")); 307 | ref var attribute0 = ref desc.Attrs[0]; 308 | attribute0.SemName = "POSITION"; 309 | attribute0.SemIndex = 0; 310 | ref var attribute1 = ref desc.Attrs[1]; 311 | attribute1.SemName = "COLOR"; 312 | attribute1.SemIndex = 1; 313 | break; 314 | case Graphics.Backend.Gles3: 315 | case Graphics.Backend.Wgpu: 316 | case Graphics.Backend.Dummy: 317 | throw new NotImplementedException(); 318 | default: 319 | throw new ArgumentOutOfRangeException(); 320 | } 321 | 322 | return Graphics.MakeShader(&desc); 323 | } 324 | 325 | private static Graphics.Pipeline CreatePipeline(Graphics.Shader shader) 326 | { 327 | var desc = default(Graphics.PipelineDesc); 328 | desc.Layout.Attrs[0].Format = Graphics.VertexFormat.Float3; 329 | desc.Layout.Attrs[1].Format = Graphics.VertexFormat.Float4; 330 | desc.Shader = shader; 331 | desc.IndexType = Graphics.IndexType.Uint16; 332 | desc.CullMode = Graphics.CullMode.Back; 333 | 334 | return Graphics.MakePipeline(&desc); 335 | } 336 | } 337 | -------------------------------------------------------------------------------- /src/cs/production/Interop.Sokol/Rgb8U.Colors.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Bottlenose Labs Inc. (https://github.com/bottlenoselabs). All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the Git repository root directory for full license information. 3 | 4 | namespace bottlenoselabs.Interop.Sokol; 5 | 6 | public partial struct Rgb8U 7 | { 8 | // https://en.wikipedia.org/wiki/X11_color_names 9 | 10 | /// 11 | /// Gets a that has an RGB value of #000000. 12 | /// 13 | public static readonly Rgb8U TransparentBlack = 0x000000; 14 | 15 | /// 16 | /// Gets a that has a RGB value of #000000. 17 | /// 18 | public static readonly Rgb8U Transparent = 0x000000; 19 | 20 | /// 21 | /// Gets a that has a RGB value of #E73C00. 22 | /// 23 | public static readonly Rgb8U MonoGameOrange = 0xE73C00; 24 | 25 | /// 26 | /// Gets a that has a RGB value of #F0F8FF. 27 | /// 28 | public static readonly Rgb8U AliceBlue = 0xF0F8FF; 29 | 30 | /// 31 | /// Gets a that has a RGB value of #FAEBD7. 32 | /// 33 | public static readonly Rgb8U AntiqueWhite = 0xFAEBD7; 34 | 35 | /// 36 | /// Gets a that has a RGB value of #00FFFF. 37 | /// 38 | public static readonly Rgb8U Aqua = 0x00FFFF; 39 | 40 | /// 41 | /// Gets a that has a RGB value of #7FFFD4. 42 | /// 43 | public static readonly Rgb8U Aquamarine = 0x7FFFD4; 44 | 45 | /// 46 | /// Gets a that has a RGB value of #F0FFFF. 47 | /// 48 | public static readonly Rgb8U Azure = 0xF0FFFF; 49 | 50 | /// 51 | /// Gets a that has a RGB value of #F5F5DC. 52 | /// 53 | public static readonly Rgb8U Beige = 0xF5F5DC; 54 | 55 | /// 56 | /// Gets a that has a RGB value of #FFE4C4. 57 | /// 58 | public static readonly Rgb8U Bisque = 0xFFE4C4; 59 | 60 | /// 61 | /// Gets a that has a RGB value of #000000. 62 | /// 63 | public static readonly Rgb8U Black = 0x000000; 64 | 65 | /// 66 | /// Gets a that has a RGB value of #FFEBCD. 67 | /// 68 | public static readonly Rgb8U BlanchedAlmond = 0xFFEBCD; 69 | 70 | /// 71 | /// Gets a that has a RGB value of #0000FF. 72 | /// 73 | public static readonly Rgb8U Blue = 0x0000FF; 74 | 75 | /// 76 | /// Gets a that has a RGB value of #8A2BE2. 77 | /// 78 | public static readonly Rgb8U BlueViolet = 0x8A2BE2; 79 | 80 | /// 81 | /// Gets a that has a RGB value of #A52A2A. 82 | /// 83 | public static readonly Rgb8U Brown = 0xA52A2A; 84 | 85 | /// 86 | /// Gets a that has a RGB value of #DEB887. 87 | /// 88 | public static readonly Rgb8U BurlyWood = 0xDEB887; 89 | 90 | /// 91 | /// Gets a that has a RGB value of #5F9EA0. 92 | /// 93 | public static readonly Rgb8U CadetBlue = 0x5F9EA0; 94 | 95 | /// 96 | /// Gets a that has a RGB value of #7FFF00. 97 | /// 98 | public static readonly Rgb8U Chartreuse = 0x7FFF00; 99 | 100 | /// 101 | /// Gets a that has a RGB value of #D2691E. 102 | /// 103 | public static readonly Rgb8U Chocolate = 0xD2691E; 104 | 105 | /// 106 | /// Gets a that has a RGB value of #FF7F50. 107 | /// 108 | public static readonly Rgb8U Coral = 0xFF7F50; 109 | 110 | /// 111 | /// Gets a that has a RGB value of #6495ED. 112 | /// 113 | public static readonly Rgb8U CornflowerBlue = 0x6495ED; 114 | 115 | /// 116 | /// Gets a that has a RGB value of #FFF8DC. 117 | /// 118 | public static readonly Rgb8U Cornsilk = 0xFFF8DC; 119 | 120 | /// 121 | /// Gets a that has a RGB value of #DC143C. 122 | /// 123 | public static readonly Rgb8U Crimson = 0xDC143C; 124 | 125 | /// 126 | /// Gets a that has a RGB value of #00FFFF. 127 | /// 128 | public static readonly Rgb8U Cyan = 0x00FFFF; 129 | 130 | /// 131 | /// Gets a that has a RGB value of #00008B. 132 | /// 133 | public static readonly Rgb8U DarkBlue = 0x00008B; 134 | 135 | /// 136 | /// Gets a that has a RGB value of #008B8B. 137 | /// 138 | public static readonly Rgb8U DarkCyan = 0x008B8B; 139 | 140 | /// 141 | /// Gets a that has a RGB value of #B8860B. 142 | /// 143 | public static readonly Rgb8U DarkGoldenrod = 0xB8860B; 144 | 145 | /// 146 | /// Gets a that has a RGB value of #A9A9A9. 147 | /// 148 | public static readonly Rgb8U DarkGray = 0xA9A9A9; 149 | 150 | /// 151 | /// Gets a that has a RGB value of #006400. 152 | /// 153 | public static readonly Rgb8U DarkGreen = 0x006400; 154 | 155 | /// 156 | /// Gets a that has a RGB value of #A9A9A9. 157 | /// 158 | public static readonly Rgb8U DarkGrey = 0xA9A9A9; 159 | 160 | /// 161 | /// Gets a that has a RGB value of #BDB76B. 162 | /// 163 | public static readonly Rgb8U DarkKhaki = 0xBDB76B; 164 | 165 | /// 166 | /// Gets a that has a RGB value of #8B008B. 167 | /// 168 | public static readonly Rgb8U DarkMagenta = 0x8B008B; 169 | 170 | /// 171 | /// Gets a that has a RGB value of #556B2F. 172 | /// 173 | public static readonly Rgb8U DarkOliveGreen = 0x556B2F; 174 | 175 | /// 176 | /// Gets a that has a RGB value of #FF8C00. 177 | /// 178 | public static readonly Rgb8U DarkOrange = 0xFF8C00; 179 | 180 | /// 181 | /// Gets a that has a RGB value of #9932CC. 182 | /// 183 | public static readonly Rgb8U DarkOrchid = 0x9932CC; 184 | 185 | /// 186 | /// Gets a that has a RGB value of #8B0000. 187 | /// 188 | public static readonly Rgb8U DarkRed = 0x8B0000; 189 | 190 | /// 191 | /// Gets a that has a RGB value of #E9967A. 192 | /// 193 | public static readonly Rgb8U DarkSalmon = 0xE9967A; 194 | 195 | /// 196 | /// Gets a that has a RGB value of #8FBC8F. 197 | /// 198 | public static readonly Rgb8U DarkSeaGreen = 0x8FBC8F; 199 | 200 | /// 201 | /// Gets a that has a RGB value of #483D8B. 202 | /// 203 | public static readonly Rgb8U DarkStateBlue = 0x483D8B; 204 | 205 | /// 206 | /// Gets a that has a RGB value of #2F4F4F. 207 | /// 208 | public static readonly Rgb8U DarkStateGray = 0x2F4F4F; 209 | 210 | /// 211 | /// Gets a that has a RGB value of #2F4F4F. 212 | /// 213 | public static readonly Rgb8U DarkStateGrey = 0x2F4F4F; 214 | 215 | /// 216 | /// Gets a that has a RGB value of #00CED1. 217 | /// 218 | public static readonly Rgb8U DarkTurquoise = 0x00CED1; 219 | 220 | /// 221 | /// Gets a that has a RGB value of #9400D3. 222 | /// 223 | public static readonly Rgb8U DarkViolet = 0x9400D3; 224 | 225 | /// 226 | /// Gets a that has a RGB value of #FF1493. 227 | /// 228 | public static readonly Rgb8U DeepPink = 0xFF1493; 229 | 230 | /// 231 | /// Gets a that has a RGB value of #00BFFF. 232 | /// 233 | public static readonly Rgb8U DeepSkyBlue = 0x00BFFF; 234 | 235 | /// 236 | /// Gets a that has a RGB value of #696969. 237 | /// 238 | public static readonly Rgb8U DimGray = 0x696969; 239 | 240 | /// 241 | /// Gets a that has a RGB value of #696969. 242 | /// 243 | public static readonly Rgb8U DimGrey = 0x696969; 244 | 245 | /// 246 | /// Gets a that has a RGB value of #1E90FF. 247 | /// 248 | public static readonly Rgb8U DodgerBlue = 0x1E90FF; 249 | 250 | /// 251 | /// Gets a that has a RGB value of #B22222. 252 | /// 253 | public static readonly Rgb8U Firebrick = 0xB22222; 254 | 255 | /// 256 | /// Gets a that has a RGB value of #FFFAF0. 257 | /// 258 | public static readonly Rgb8U FloralWhite = 0xFFFAF0; 259 | 260 | /// 261 | /// Gets a that has a RGB value of #228B22. 262 | /// 263 | public static readonly Rgb8U ForestGreen = 0x228B22; 264 | 265 | /// 266 | /// Gets a that has a RGB value of #FF00FF. 267 | /// 268 | public static readonly Rgb8U Fuchsia = 0xFF00FF; 269 | 270 | /// 271 | /// Gets a that has a RGB value of #DCDCDC. 272 | /// 273 | public static readonly Rgb8U Gainsboro = 0xDCDCDC; 274 | 275 | /// 276 | /// Gets a that has a RGB value of #F8F8FF. 277 | /// 278 | public static readonly Rgb8U GhostWhite = 0xF8F8FF; 279 | 280 | /// 281 | /// Gets a that has a RGB value of #FFD700. 282 | /// 283 | public static readonly Rgb8U Gold = 0xFFD700; 284 | 285 | /// 286 | /// Gets a that has a RGB value of #DAA520. 287 | /// 288 | public static readonly Rgb8U Goldenrod = 0xDAA520; 289 | 290 | /// 291 | /// Gets a that has a RGB value of #808080. 292 | /// 293 | public static readonly Rgb8U Gray = 0x808080; 294 | 295 | /// 296 | /// Gets a that has a RGB value of #008000. 297 | /// 298 | public static readonly Rgb8U Green = 0x008000; 299 | 300 | /// 301 | /// Gets a that has a RGB value of #ADFF2F. 302 | /// 303 | public static readonly Rgb8U GreenYellow = 0xADFF2F; 304 | 305 | /// 306 | /// Gets a that has a RGB value of #808080. 307 | /// 308 | public static readonly Rgb8U Grey = 0x808080; 309 | 310 | /// 311 | /// Gets a that has a RGB value of #F0FFF0. 312 | /// 313 | public static readonly Rgb8U Honeydew = 0xF0FFF0; 314 | 315 | /// 316 | /// Gets a that has a RGB value of #FF69B4. 317 | /// 318 | public static readonly Rgb8U HotPink = 0xFF69B4; 319 | 320 | /// 321 | /// Gets a that has a RGB value of #CD5C5C. 322 | /// 323 | public static readonly Rgb8U IndianRed = 0xCD5C5C; 324 | 325 | /// 326 | /// Gets a that has a RGB value of #4B0082. 327 | /// 328 | public static readonly Rgb8U Indigo = 0x4B0082; 329 | 330 | /// 331 | /// Gets a that has a RGB value of #FFFFF0. 332 | /// 333 | public static readonly Rgb8U Ivory = 0xFFFFF0; 334 | 335 | /// 336 | /// Gets a that has a RGB value of #F0E68C. 337 | /// 338 | public static readonly Rgb8U Khaki = 0xF0E68C; 339 | 340 | /// 341 | /// Gets a that has a RGB value of #E6E6FA. 342 | /// 343 | public static readonly Rgb8U Lavender = 0xE6E6FA; 344 | 345 | /// 346 | /// Gets a that has a RGB value of #FFF0F5. 347 | /// 348 | public static readonly Rgb8U LavenderBlush = 0xFFF0F5; 349 | 350 | /// 351 | /// Gets a that has a RGB value of #7CFC00. 352 | /// 353 | public static readonly Rgb8U LawnGreen = 0x7CFC00; 354 | 355 | /// 356 | /// Gets a that has a RGB value of #FFFACD. 357 | /// 358 | public static readonly Rgb8U LemonChiffon = 0xFFFACD; 359 | 360 | /// 361 | /// Gets a that has a RGB value of #ADD8E6. 362 | /// 363 | public static readonly Rgb8U LightBlue = 0xADD8E6; 364 | 365 | /// 366 | /// Gets a that has a RGB value of #F08080. 367 | /// 368 | public static readonly Rgb8U LightCoral = 0xF08080; 369 | 370 | /// 371 | /// Gets a that has a RGB value of #E0FFFF. 372 | /// 373 | public static readonly Rgb8U LightCyan = 0xE0FFFF; 374 | 375 | /// 376 | /// Gets a that has a RGB value of #FAFAD2. 377 | /// 378 | public static readonly Rgb8U LightGoldenrodYellow = 0xFAFAD2; 379 | 380 | /// 381 | /// Gets a that has a RGB value of #D3D3D3. 382 | /// 383 | public static readonly Rgb8U LightGray = 0xD3D3D3; 384 | 385 | /// 386 | /// Gets a that has a RGB value of #90EE90. 387 | /// 388 | public static readonly Rgb8U LightGreen = 0x90EE90; 389 | 390 | /// 391 | /// Gets a that has a RGB value of #D3D3D3. 392 | /// 393 | public static readonly Rgb8U LightGrey = 0xD3D3D3; 394 | 395 | /// 396 | /// Gets a that has a RGB value of #FFB6C1. 397 | /// 398 | public static readonly Rgb8U LightPink = 0xFFB6C1; 399 | 400 | /// 401 | /// Gets a that has a RGB value of #FFA07A. 402 | /// 403 | public static readonly Rgb8U LightSalmon = 0xFFA07A; 404 | 405 | /// 406 | /// Gets a that has a RGB value of #20B2AA. 407 | /// 408 | public static readonly Rgb8U LightSeaGreen = 0x20B2AA; 409 | 410 | /// 411 | /// Gets a that has a RGB value of #87CEFA. 412 | /// 413 | public static readonly Rgb8U LightSkyBlue = 0x87CEFA; 414 | 415 | /// 416 | /// Gets a that has a RGB value of #778899. 417 | /// 418 | public static readonly Rgb8U LightSlateGray = 0x778899; 419 | 420 | /// 421 | /// Gets a that has a RGB value of #778899. 422 | /// 423 | public static readonly Rgb8U LightSlateGrey = 0x778899; 424 | 425 | /// 426 | /// Gets a that has a RGB value of #B0C4DE. 427 | /// 428 | public static readonly Rgb8U LightSteelBlue = 0xB0C4DE; 429 | 430 | /// 431 | /// Gets a that has a RGB value of #FFFFE0. 432 | /// 433 | public static readonly Rgb8U LightYellow = 0xFFFFE0; 434 | 435 | /// 436 | /// Gets a that has a RGB value of #00FF00. 437 | /// 438 | public static readonly Rgb8U Lime = 0x00FF00; 439 | 440 | /// 441 | /// Gets a that has a RGB value of #32CD32. 442 | /// 443 | public static readonly Rgb8U LimeGreen = 0x32CD32; 444 | 445 | /// 446 | /// Gets a that has a RGB value of #FAF0E6. 447 | /// 448 | public static readonly Rgb8U Linen = 0xFAF0E6; 449 | 450 | /// 451 | /// Gets a that has a RGB value of #FF00FF. 452 | /// 453 | public static readonly Rgb8U Magenta = 0xFF00FF; 454 | 455 | /// 456 | /// Gets a that has a RGB value of #800000. 457 | /// 458 | public static readonly Rgb8U Maroon = 0x800000; 459 | 460 | /// 461 | /// Gets a that has a RGB value of #66CDAA. 462 | /// 463 | public static readonly Rgb8U MediumAquamarine = 0x66CDAA; 464 | 465 | /// 466 | /// Gets a that has a RGB value of #0000CD. 467 | /// 468 | public static readonly Rgb8U MediumBlue = 0x0000CD; 469 | 470 | /// 471 | /// Gets a that has a RGB value of #BA55D3. 472 | /// 473 | public static readonly Rgb8U MediumOrchid = 0xBA55D3; 474 | 475 | /// 476 | /// Gets a that has a RGB value of #9370DB. 477 | /// 478 | public static readonly Rgb8U MediumPurple = 0x9370DB; 479 | 480 | /// 481 | /// Gets a that has a RGB value of #3CB371. 482 | /// 483 | public static readonly Rgb8U MediumSeaGreen = 0x3CB371; 484 | 485 | /// 486 | /// Gets a that has a RGB value of #7B68EE. 487 | /// 488 | public static readonly Rgb8U MediumStateBlue = 0x7B68EE; 489 | 490 | /// 491 | /// Gets a that has a RGB value of #00FA9A. 492 | /// 493 | public static readonly Rgb8U MediumSpringGreen = 0x00FA9A; 494 | 495 | /// 496 | /// Gets a that has a RGB value of #48D1CC. 497 | /// 498 | public static readonly Rgb8U MediumTurquoise = 0x48D1CC; 499 | 500 | /// 501 | /// Gets a that has a RGB value of #C71585. 502 | /// 503 | public static readonly Rgb8U MediumVioletRed = 0xC71585; 504 | 505 | /// 506 | /// Gets a that has a RGB value of #191970. 507 | /// 508 | public static readonly Rgb8U MidnightBlue = 0x191970; 509 | 510 | /// 511 | /// Gets a that has a RGB value of #F5FFFA. 512 | /// 513 | public static readonly Rgb8U MintCream = 0xF5FFFA; 514 | 515 | /// 516 | /// Gets a that has a RGB value of #FFE4E1. 517 | /// 518 | public static readonly Rgb8U MistyRose = 0xFFE4E1; 519 | 520 | /// 521 | /// Gets a that has a RGB value of #FFE4B5. 522 | /// 523 | public static readonly Rgb8U Moccasin = 0xFFE4B5; 524 | 525 | /// 526 | /// Gets a that has a RGB value of #FFDEAD. 527 | /// 528 | public static readonly Rgb8U NavajoWhite = 0xFFDEAD; 529 | 530 | /// 531 | /// Gets a that has a RGB value of #000080. 532 | /// 533 | public static readonly Rgb8U Navy = 0x000080; 534 | 535 | /// 536 | /// Gets a that has a RGB value of #FDF5E6. 537 | /// 538 | public static readonly Rgb8U OldLace = 0xFDF5E6; 539 | 540 | /// 541 | /// Gets a that has a RGB value of #808000. 542 | /// 543 | public static readonly Rgb8U Olive = 0x808000; 544 | 545 | /// 546 | /// Gets a that has a RGB value of #6B8E23. 547 | /// 548 | public static readonly Rgb8U OliveDrab = 0x6B8E23; 549 | 550 | /// 551 | /// Gets a that has a RGB value of #FFA500. 552 | /// 553 | public static readonly Rgb8U Orange = 0xFFA500; 554 | 555 | /// 556 | /// Gets a that has a RGB value of #FF4500. 557 | /// 558 | public static readonly Rgb8U OrangeRed = 0xFF4500; 559 | 560 | /// 561 | /// Gets a that has a RGB value of #DA70D6. 562 | /// 563 | public static readonly Rgb8U Orchid = 0xDA70D6; 564 | 565 | /// 566 | /// Gets a that has a RGB value of #EEE8AA. 567 | /// 568 | public static readonly Rgb8U PaleGoldenrod = 0xEEE8AA; 569 | 570 | /// 571 | /// Gets a that has a RGB value of #98FB98. 572 | /// 573 | public static readonly Rgb8U PaleGreen = 0x98FB98; 574 | 575 | /// 576 | /// Gets a that has a RGB value of #AFEEEE. 577 | /// 578 | public static readonly Rgb8U PaleTurquoise = 0xAFEEEE; 579 | 580 | /// 581 | /// Gets a that has a RGB value of #DB7093. 582 | /// 583 | public static readonly Rgb8U PaleVioletRed = 0xDB7093; 584 | 585 | /// 586 | /// Gets a that has a RGB value of #FFEFD5. 587 | /// 588 | public static readonly Rgb8U PapayaWhip = 0xFFEFD5; 589 | 590 | /// 591 | /// Gets a that has a RGB value of #FFDAB9. 592 | /// 593 | public static readonly Rgb8U PeachPuff = 0xFFDAB9; 594 | 595 | /// 596 | /// Gets a that has a RGB value of #CD853F. 597 | /// 598 | public static readonly Rgb8U Peru = 0xCD853F; 599 | 600 | /// 601 | /// Gets a that has a RGB value of #FFC0CB. 602 | /// 603 | public static readonly Rgb8U Pink = 0xFFC0CB; 604 | 605 | /// 606 | /// Gets a that has a RGB value of #DDA0DD. 607 | /// 608 | public static readonly Rgb8U Plum = 0xDDA0DD; 609 | 610 | /// 611 | /// Gets a that has a RGB value of #B0E0E6. 612 | /// 613 | public static readonly Rgb8U PowderBlue = 0xB0E0E6; 614 | 615 | /// 616 | /// Gets a that has a RGB value of #800080. 617 | /// 618 | public static readonly Rgb8U Purple = 0x800080; 619 | 620 | /// 621 | /// Gets a that has a RGB value of #FF0000. 622 | /// 623 | public static readonly Rgb8U Red = 0xFF0000; 624 | 625 | /// 626 | /// Gets a that has a RGB value of #BC8F8F. 627 | /// 628 | public static readonly Rgb8U RosyBrown = 0xBC8F8F; 629 | 630 | /// 631 | /// Gets a that has a RGB value of #4169E1. 632 | /// 633 | public static readonly Rgb8U RoyalBlue = 0x4169E1; 634 | 635 | /// 636 | /// Gets a that has a RGB value of #8B4513. 637 | /// 638 | public static readonly Rgb8U SaddleBrown = 0x8B4513; 639 | 640 | /// 641 | /// Gets a that has a RGB value of #FA8072. 642 | /// 643 | public static readonly Rgb8U Salmon = 0xFA8072; 644 | 645 | /// 646 | /// Gets a that has a RGB value of #F4A460. 647 | /// 648 | public static readonly Rgb8U SandyBrown = 0xF4A460; 649 | 650 | /// 651 | /// Gets a that has a RGB value of #2E8B57. 652 | /// 653 | public static readonly Rgb8U SeaGreen = 0x2E8B57; 654 | 655 | /// 656 | /// Gets a that has a RGB value of #FFF5EE. 657 | /// 658 | public static readonly Rgb8U SeaShell = 0xFFF5EE; 659 | 660 | /// 661 | /// Gets a that has a RGB value of #A0522D. 662 | /// 663 | public static readonly Rgb8U Sienna = 0xA0522D; 664 | 665 | /// 666 | /// Gets a that has a RGB value of #C0C0C0. 667 | /// 668 | public static readonly Rgb8U Silver = 0xC0C0C0; 669 | 670 | /// 671 | /// Gets a that has a RGB value of #87CEEB. 672 | /// 673 | public static readonly Rgb8U SkyBlue = 0x87CEEB; 674 | 675 | /// 676 | /// Gets a that has a RGB value of #6A5ACD. 677 | /// 678 | public static readonly Rgb8U SlateBlue = 0x6A5ACD; 679 | 680 | /// 681 | /// Gets a that has a RGB value of #708090. 682 | /// 683 | public static readonly Rgb8U SlateGray = 0x708090; 684 | 685 | /// 686 | /// Gets a that has a RGB value of #708090. 687 | /// 688 | public static readonly Rgb8U SlateGrey = 0x708090; 689 | 690 | /// 691 | /// Gets a that has a RGB value of #FFFAFA. 692 | /// 693 | public static readonly Rgb8U Snow = 0xFFFAFA; 694 | 695 | /// 696 | /// Gets a that has a RGB value of #00FF7F. 697 | /// 698 | public static readonly Rgb8U SpringGreen = 0x00FF7F; 699 | 700 | /// 701 | /// Gets a that has a RGB value of #4682B4. 702 | /// 703 | public static readonly Rgb8U SteelBlue = 0x4682B4; 704 | 705 | /// 706 | /// Gets a that has a RGB value of #D2B48C. 707 | /// 708 | public static readonly Rgb8U Tan = 0xD2B48C; 709 | 710 | /// 711 | /// Gets a that has a RGB value of #008080. 712 | /// 713 | public static readonly Rgb8U Teal = 0x008080; 714 | 715 | /// 716 | /// Gets a that has a RGB value of #D8BFD8. 717 | /// 718 | public static readonly Rgb8U Thistle = 0xD8BFD8; 719 | 720 | /// 721 | /// Gets a that has a RGB value of #FF6347. 722 | /// 723 | public static readonly Rgb8U Tomato = 0xFF6347; 724 | 725 | /// 726 | /// Gets a that has a RGB value of #40E0D0. 727 | /// 728 | public static readonly Rgb8U Turquoise = 0x40E0D0; 729 | 730 | /// 731 | /// Gets a that has a RGB value of #EE82EE. 732 | /// 733 | public static readonly Rgb8U Violet = 0xEE82EE; 734 | 735 | /// 736 | /// Gets a that has a RGB value of #F5DEB3. 737 | /// 738 | public static readonly Rgb8U Wheat = 0xF5DEB3; 739 | 740 | /// 741 | /// Gets a that has a RGB value of #FFFFFF. 742 | /// 743 | public static readonly Rgb8U White = 0xFFFFFF; 744 | 745 | /// 746 | /// Gets a that has a RGB value of #F5F5F5. 747 | /// 748 | public static readonly Rgb8U WhiteSmoke = 0xF5F5F5; 749 | 750 | /// 751 | /// Gets a that has a RGB value of #FFFF00. 752 | /// 753 | public static readonly Rgb8U Yellow = 0xFFFF00; 754 | 755 | /// 756 | /// Gets a that has a RGB value of #9ACD32. 757 | /// 758 | public static readonly Rgb8U YellowGreen = 0x9ACD32; 759 | } 760 | -------------------------------------------------------------------------------- /src/cs/production/Interop.Sokol/Rgb32F.Colors.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Bottlenose Labs Inc. (https://github.com/bottlenoselabs). All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the Git repository root directory for full license information. 3 | 4 | using System.Diagnostics.CodeAnalysis; 5 | 6 | namespace bottlenoselabs.Interop.Sokol; 7 | 8 | public partial struct Rgb32F 9 | { 10 | // https://en.wikipedia.org/wiki/X11_color_names 11 | 12 | /// 13 | /// Gets a that has a RGB value of #000000. 14 | /// 15 | public static readonly Rgb32F TransparentBlack = 0x000000; 16 | 17 | /// 18 | /// Gets a that has an RGB value of #000000. 19 | /// 20 | public static readonly Rgb32F Transparent = 0x000000; 21 | 22 | /// 23 | /// Gets a that has a RGB value of #E73C00. 24 | /// 25 | public static readonly Rgb32F MonoGameOrange = 0xE73C00; 26 | 27 | /// 28 | /// Gets a that has a RGB value of #F0F8FF. 29 | /// 30 | public static readonly Rgb32F AliceBlue = 0xF0F8FF; 31 | 32 | /// 33 | /// Gets a that has a RGB value of #FAEBD7. 34 | /// 35 | public static readonly Rgb32F AntiqueWhite = 0xFAEBD7; 36 | 37 | /// 38 | /// Gets a that has a RGB value of #00FFFF. 39 | /// 40 | public static readonly Rgb32F Aqua = 0x00FFFF; 41 | 42 | /// 43 | /// Gets a that has a RGB value of #7FFFD4. 44 | /// 45 | public static readonly Rgb32F Aquamarine = 0x7FFFD4; 46 | 47 | /// 48 | /// Gets a that has a RGB value of #F0FFFF. 49 | /// 50 | public static readonly Rgb32F Azure = 0xF0FFFF; 51 | 52 | /// 53 | /// Gets a that has a RGB value of #F5F5DC. 54 | /// 55 | public static readonly Rgb32F Beige = 0xF5F5DC; 56 | 57 | /// 58 | /// Gets a that has a RGB value of #FFE4C4. 59 | /// 60 | public static readonly Rgb32F Bisque = 0xFFE4C4; 61 | 62 | /// 63 | /// Gets a that has a RGB value of #000000. 64 | /// 65 | public static readonly Rgb32F Black = 0x000000; 66 | 67 | /// 68 | /// Gets a that has a RGB value of #FFEBCD. 69 | /// 70 | public static readonly Rgb32F BlanchedAlmond = 0xFFEBCD; 71 | 72 | /// 73 | /// Gets a that has a RGB value of #0000FF. 74 | /// 75 | public static readonly Rgb32F Blue = 0x0000FF; 76 | 77 | /// 78 | /// Gets a that has a RGB value of #8A2BE2. 79 | /// 80 | public static readonly Rgb32F BlueViolet = 0x8A2BE2; 81 | 82 | /// 83 | /// Gets a that has a RGB value of #A52A2A. 84 | /// 85 | public static readonly Rgb32F Brown = 0xA52A2A; 86 | 87 | /// 88 | /// Gets a that has a RGB value of #DEB887. 89 | /// 90 | public static readonly Rgb32F BurlyWood = 0xDEB887; 91 | 92 | /// 93 | /// Gets a that has a RGB value of #5F9EA0. 94 | /// 95 | public static readonly Rgb32F CadetBlue = 0x5F9EA0; 96 | 97 | /// 98 | /// Gets a that has a RGB value of #7FFF00. 99 | /// 100 | public static readonly Rgb32F Chartreuse = 0x7FFF00; 101 | 102 | /// 103 | /// Gets a that has a RGB value of #D2691E. 104 | /// 105 | public static readonly Rgb32F Chocolate = 0xD2691E; 106 | 107 | /// 108 | /// Gets a that has a RGB value of #FF7F50. 109 | /// 110 | public static readonly Rgb32F Coral = 0xFF7F50; 111 | 112 | /// 113 | /// Gets a that has a RGB value of #6495ED. 114 | /// 115 | public static readonly Rgb32F CornflowerBlue = 0x6495ED; 116 | 117 | /// 118 | /// Gets a that has a RGB value of #FFF8DC. 119 | /// 120 | public static readonly Rgb32F Cornsilk = 0xFFF8DC; 121 | 122 | /// 123 | /// Gets a that has a RGB value of #DC143C. 124 | /// 125 | public static readonly Rgb32F Crimson = 0xDC143C; 126 | 127 | /// 128 | /// Gets a that has a RGB value of #00FFFF. 129 | /// 130 | public static readonly Rgb32F Cyan = 0x00FFFF; 131 | 132 | /// 133 | /// Gets a that has a RGB value of #00008B. 134 | /// 135 | public static readonly Rgb32F DarkBlue = 0x00008B; 136 | 137 | /// 138 | /// Gets a that has a RGB value of #008B8B. 139 | /// 140 | public static readonly Rgb32F DarkCyan = 0x008B8B; 141 | 142 | /// 143 | /// Gets a that has a RGB value of #B8860B. 144 | /// 145 | public static readonly Rgb32F DarkGoldenrod = 0xB8860B; 146 | 147 | /// 148 | /// Gets a that has a RGB value of #A9A9A9. 149 | /// 150 | public static readonly Rgb32F DarkGray = 0xA9A9A9; 151 | 152 | /// 153 | /// Gets a that has a RGB value of #006400. 154 | /// 155 | public static readonly Rgb32F DarkGreen = 0x006400; 156 | 157 | /// 158 | /// Gets a that has a RGB value of #A9A9A9. 159 | /// 160 | public static readonly Rgb32F DarkGrey = 0xA9A9A9; 161 | 162 | /// 163 | /// Gets a that has a RGB value of #BDB76B. 164 | /// 165 | public static readonly Rgb32F DarkKhaki = 0xBDB76B; 166 | 167 | /// 168 | /// Gets a that has a RGB value of #8B008B. 169 | /// 170 | public static readonly Rgb32F DarkMagenta = 0x8B008B; 171 | 172 | /// 173 | /// Gets a that has a RGB value of #556B2F. 174 | /// 175 | public static readonly Rgb32F DarkOliveGreen = 0x556B2F; 176 | 177 | /// 178 | /// Gets a that has a RGB value of #FF8C00. 179 | /// 180 | public static readonly Rgb32F DarkOrange = 0xFF8C00; 181 | 182 | /// 183 | /// Gets a that has a RGB value of #9932CC. 184 | /// 185 | public static readonly Rgb32F DarkOrchid = 0x9932CC; 186 | 187 | /// 188 | /// Gets a that has a RGB value of #8B0000. 189 | /// 190 | public static readonly Rgb32F DarkRed = 0x8B0000; 191 | 192 | /// 193 | /// Gets a that has a RGB value of #E9967A. 194 | /// 195 | public static readonly Rgb32F DarkSalmon = 0xE9967A; 196 | 197 | /// 198 | /// Gets a that has a RGB value of #8FBC8F. 199 | /// 200 | public static readonly Rgb32F DarkSeaGreen = 0x8FBC8F; 201 | 202 | /// 203 | /// Gets a that has a RGB value of #483D8B. 204 | /// 205 | public static readonly Rgb32F DarkStateBlue = 0x483D8B; 206 | 207 | /// 208 | /// Gets a that has a RGB value of #2F4F4F. 209 | /// 210 | public static readonly Rgb32F DarkStateGray = 0x2F4F4F; 211 | 212 | /// 213 | /// Gets a that has a RGB value of #2F4F4F. 214 | /// 215 | public static readonly Rgb32F DarkStateGrey = 0x2F4F4F; 216 | 217 | /// 218 | /// Gets a that has a RGB value of #00CED1. 219 | /// 220 | public static readonly Rgb32F DarkTurquoise = 0x00CED1; 221 | 222 | /// 223 | /// Gets a that has a RGB value of #9400D3. 224 | /// 225 | public static readonly Rgb32F DarkViolet = 0x9400D3; 226 | 227 | /// 228 | /// Gets a that has a RGB value of #FF1493. 229 | /// 230 | public static readonly Rgb32F DeepPink = 0xFF1493; 231 | 232 | /// 233 | /// Gets a that has a RGB value of #00BFFF. 234 | /// 235 | public static readonly Rgb32F DeepSkyBlue = 0x00BFFF; 236 | 237 | /// 238 | /// Gets a that has a RGB value of #696969. 239 | /// 240 | public static readonly Rgb32F DimGray = 0x696969; 241 | 242 | /// 243 | /// Gets a that has a RGB value of #696969. 244 | /// 245 | public static readonly Rgb32F DimGrey = 0x696969; 246 | 247 | /// 248 | /// Gets a that has a RGB value of #1E90FF. 249 | /// 250 | public static readonly Rgb32F DodgerBlue = 0x1E90FF; 251 | 252 | /// 253 | /// Gets a that has a RGB value of #B22222. 254 | /// 255 | public static readonly Rgb32F Firebrick = 0xB22222; 256 | 257 | /// 258 | /// Gets a that has a RGB value of #FFFAF0. 259 | /// 260 | public static readonly Rgb32F FloralWhite = 0xFFFAF0; 261 | 262 | /// 263 | /// Gets a that has a RGB value of #228B22. 264 | /// 265 | public static readonly Rgb32F ForestGreen = 0x228B22; 266 | 267 | /// 268 | /// Gets a that has a RGB value of #FF00FF. 269 | /// 270 | public static readonly Rgb32F Fuchsia = 0xFF00FF; 271 | 272 | /// 273 | /// Gets a that has a RGB value of #DCDCDC. 274 | /// 275 | public static readonly Rgb32F Gainsboro = 0xDCDCDC; 276 | 277 | /// 278 | /// Gets a that has a RGB value of #F8F8FF. 279 | /// 280 | public static readonly Rgb32F GhostWhite = 0xF8F8FF; 281 | 282 | /// 283 | /// Gets a that has a RGB value of #FFD700. 284 | /// 285 | public static readonly Rgb32F Gold = 0xFFD700; 286 | 287 | /// 288 | /// Gets a that has a RGB value of #DAA520. 289 | /// 290 | public static readonly Rgb32F Goldenrod = 0xDAA520; 291 | 292 | /// 293 | /// Gets a that has a RGB value of #808080. 294 | /// 295 | public static readonly Rgb32F Gray = 0x808080; 296 | 297 | /// 298 | /// Gets a that has a RGB value of #008000. 299 | /// 300 | public static readonly Rgb32F Green = 0x008000; 301 | 302 | /// 303 | /// Gets a that has a RGB value of #ADFF2F. 304 | /// 305 | public static readonly Rgb32F GreenYellow = 0xADFF2F; 306 | 307 | /// 308 | /// Gets a that has a RGB value of #808080. 309 | /// 310 | public static readonly Rgb32F Grey = 0x808080; 311 | 312 | /// 313 | /// Gets a that has a RGB value of #F0FFF0. 314 | /// 315 | public static readonly Rgb32F Honeydew = 0xF0FFF0; 316 | 317 | /// 318 | /// Gets a that has a RGB value of #FF69B4. 319 | /// 320 | public static readonly Rgb32F HotPink = 0xFF69B4; 321 | 322 | /// 323 | /// Gets a that has a RGB value of #CD5C5C. 324 | /// 325 | public static readonly Rgb32F IndianRed = 0xCD5C5C; 326 | 327 | /// 328 | /// Gets a that has a RGB value of #4B0082. 329 | /// 330 | public static readonly Rgb32F Indigo = 0x4B0082; 331 | 332 | /// 333 | /// Gets a that has a RGB value of #FFFFF0. 334 | /// 335 | public static readonly Rgb32F Ivory = 0xFFFFF0; 336 | 337 | /// 338 | /// Gets a that has a RGB value of #F0E68C. 339 | /// 340 | public static readonly Rgb32F Khaki = 0xF0E68C; 341 | 342 | /// 343 | /// Gets a that has a RGB value of #E6E6FA. 344 | /// 345 | public static readonly Rgb32F Lavender = 0xE6E6FA; 346 | 347 | /// 348 | /// Gets a that has a RGB value of #FFF0F5. 349 | /// 350 | public static readonly Rgb32F LavenderBlush = 0xFFF0F5; 351 | 352 | /// 353 | /// Gets a that has a RGB value of #7CFC00. 354 | /// 355 | public static readonly Rgb32F LawnGreen = 0x7CFC00; 356 | 357 | /// 358 | /// Gets a that has a RGB value of #FFFACD. 359 | /// 360 | public static readonly Rgb32F LemonChiffon = 0xFFFACD; 361 | 362 | /// 363 | /// Gets a that has a RGB value of #ADD8E6. 364 | /// 365 | public static readonly Rgb32F LightBlue = 0xADD8E6; 366 | 367 | /// 368 | /// Gets a that has a RGB value of #F08080. 369 | /// 370 | public static readonly Rgb32F LightCoral = 0xF08080; 371 | 372 | /// 373 | /// Gets a that has a RGB value of #E0FFFF. 374 | /// 375 | public static readonly Rgb32F LightCyan = 0xE0FFFF; 376 | 377 | /// 378 | /// Gets a that has a RGB value of #FAFAD2. 379 | /// 380 | public static readonly Rgb32F LightGoldenrodYellow = 0xFAFAD2; 381 | 382 | /// 383 | /// Gets a that has a RGB value of #D3D3D3. 384 | /// 385 | public static readonly Rgb32F LightGray = 0xD3D3D3; 386 | 387 | /// 388 | /// Gets a that has a RGB value of #90EE90. 389 | /// 390 | public static readonly Rgb32F LightGreen = 0x90EE90; 391 | 392 | /// 393 | /// Gets a that has a RGB value of #D3D3D3. 394 | /// 395 | public static readonly Rgb32F LightGrey = 0xD3D3D3; 396 | 397 | /// 398 | /// Gets a that has a RGB value of #FFB6C1. 399 | /// 400 | public static readonly Rgb32F LightPink = 0xFFB6C1; 401 | 402 | /// 403 | /// Gets a that has a RGB value of #FFA07A. 404 | /// 405 | public static readonly Rgb32F LightSalmon = 0xFFA07A; 406 | 407 | /// 408 | /// Gets a that has a RGB value of #20B2AA. 409 | /// 410 | public static readonly Rgb32F LightSeaGreen = 0x20B2AA; 411 | 412 | /// 413 | /// Gets a that has a RGB value of #87CEFA. 414 | /// 415 | public static readonly Rgb32F LightSkyBlue = 0x87CEFA; 416 | 417 | /// 418 | /// Gets a that has a RGB value of #778899. 419 | /// 420 | public static readonly Rgb32F LightSlateGray = 0x778899; 421 | 422 | /// 423 | /// Gets a that has a RGB value of #778899. 424 | /// 425 | public static readonly Rgb32F LightSlateGrey = 0x778899; 426 | 427 | /// 428 | /// Gets a that has a RGB value of #B0C4DE. 429 | /// 430 | public static readonly Rgb32F LightSteelBlue = 0xB0C4DE; 431 | 432 | /// 433 | /// Gets a that has a RGB value of #FFFFE0. 434 | /// 435 | public static readonly Rgb32F LightYellow = 0xFFFFE0; 436 | 437 | /// 438 | /// Gets a that has a RGB value of #00FF00. 439 | /// 440 | public static readonly Rgb32F Lime = 0x00FF00; 441 | 442 | /// 443 | /// Gets a that has a RGB value of #32CD32. 444 | /// 445 | public static readonly Rgb32F LimeGreen = 0x32CD32; 446 | 447 | /// 448 | /// Gets a that has a RGB value of #FAF0E6. 449 | /// 450 | public static readonly Rgb32F Linen = 0xFAF0E6; 451 | 452 | /// 453 | /// Gets a that has a RGB value of #FF00FF. 454 | /// 455 | public static readonly Rgb32F Magenta = 0xFF00FF; 456 | 457 | /// 458 | /// Gets a that has a RGB value of #800000. 459 | /// 460 | public static readonly Rgb32F Maroon = 0x800000; 461 | 462 | /// 463 | /// Gets a that has a RGB value of #66CDAA. 464 | /// 465 | public static readonly Rgb32F MediumAquamarine = 0x66CDAA; 466 | 467 | /// 468 | /// Gets a that has a RGB value of #0000CD. 469 | /// 470 | public static readonly Rgb32F MediumBlue = 0x0000CD; 471 | 472 | /// 473 | /// Gets a that has a RGB value of #BA55D3. 474 | /// 475 | public static readonly Rgb32F MediumOrchid = 0xBA55D3; 476 | 477 | /// 478 | /// Gets a that has a RGB value of #9370DB. 479 | /// 480 | public static readonly Rgb32F MediumPurple = 0x9370DB; 481 | 482 | /// 483 | /// Gets a that has a RGB value of #3CB371. 484 | /// 485 | public static readonly Rgb32F MediumSeaGreen = 0x3CB371; 486 | 487 | /// 488 | /// Gets a that has a RGB value of #7B68EE. 489 | /// 490 | public static readonly Rgb32F MediumStateBlue = 0x7B68EE; 491 | 492 | /// 493 | /// Gets a that has a RGB value of #00FA9A. 494 | /// 495 | public static readonly Rgb32F MediumSpringGreen = 0x00FA9A; 496 | 497 | /// 498 | /// Gets a that has a RGB value of #48D1CC. 499 | /// 500 | public static readonly Rgb32F MediumTurquoise = 0x48D1CC; 501 | 502 | /// 503 | /// Gets a that has a RGB value of #C71585. 504 | /// 505 | public static readonly Rgb32F MediumVioletRed = 0xC71585; 506 | 507 | /// 508 | /// Gets a that has a RGB value of #191970. 509 | /// 510 | public static readonly Rgb32F MidnightBlue = 0x191970; 511 | 512 | /// 513 | /// Gets a that has a RGB value of #F5FFFA. 514 | /// 515 | public static readonly Rgb32F MintCream = 0xF5FFFA; 516 | 517 | /// 518 | /// Gets a that has a RGB value of #FFE4E1. 519 | /// 520 | public static readonly Rgb32F MistyRose = 0xFFE4E1; 521 | 522 | /// 523 | /// Gets a that has a RGB value of #FFE4B5. 524 | /// 525 | public static readonly Rgb32F Moccasin = 0xFFE4B5; 526 | 527 | /// 528 | /// Gets a that has a RGB value of #FFDEAD. 529 | /// 530 | public static readonly Rgb32F NavajoWhite = 0xFFDEAD; 531 | 532 | /// 533 | /// Gets a that has a RGB value of #000080. 534 | /// 535 | public static readonly Rgb32F Navy = 0x000080; 536 | 537 | /// 538 | /// Gets a that has a RGB value of #FDF5E6. 539 | /// 540 | public static readonly Rgb32F OldLace = 0xFDF5E6; 541 | 542 | /// 543 | /// Gets a that has a RGB value of #808000. 544 | /// 545 | public static readonly Rgb32F Olive = 0x808000; 546 | 547 | /// 548 | /// Gets a that has a RGB value of #6B8E23. 549 | /// 550 | public static readonly Rgb32F OliveDrab = 0x6B8E23; 551 | 552 | /// 553 | /// Gets a that has a RGB value of #FFA500. 554 | /// 555 | public static readonly Rgb32F Orange = 0xFFA500; 556 | 557 | /// 558 | /// Gets a that has a RGB value of #FF4500. 559 | /// 560 | public static readonly Rgb32F OrangeRed = 0xFF4500; 561 | 562 | /// 563 | /// Gets a that has a RGB value of #DA70D6. 564 | /// 565 | public static readonly Rgb32F Orchid = 0xDA70D6; 566 | 567 | /// 568 | /// Gets a that has a RGB value of #EEE8AA. 569 | /// 570 | public static readonly Rgb32F PaleGoldenrod = 0xEEE8AA; 571 | 572 | /// 573 | /// Gets a that has a RGB value of #98FB98. 574 | /// 575 | public static readonly Rgb32F PaleGreen = 0x98FB98; 576 | 577 | /// 578 | /// Gets a that has a RGB value of #AFEEEE. 579 | /// 580 | public static readonly Rgb32F PaleTurquoise = 0xAFEEEE; 581 | 582 | /// 583 | /// Gets a that has a RGB value of #DB7093. 584 | /// 585 | public static readonly Rgb32F PaleVioletRed = 0xDB7093; 586 | 587 | /// 588 | /// Gets a that has a RGB value of #FFEFD5. 589 | /// 590 | public static readonly Rgb32F PapayaWhip = 0xFFEFD5; 591 | 592 | /// 593 | /// Gets a that has a RGB value of #FFDAB9. 594 | /// 595 | public static readonly Rgb32F PeachPuff = 0xFFDAB9; 596 | 597 | /// 598 | /// Gets a that has a RGB value of #CD853F. 599 | /// 600 | public static readonly Rgb32F Peru = 0xCD853F; 601 | 602 | /// 603 | /// Gets a that has a RGB value of #FFC0CB. 604 | /// 605 | public static readonly Rgb32F Pink = 0xFFC0CB; 606 | 607 | /// 608 | /// Gets a that has a RGB value of #DDA0DD. 609 | /// 610 | public static readonly Rgb32F Plum = 0xDDA0DD; 611 | 612 | /// 613 | /// Gets a that has a RGB value of #B0E0E6. 614 | /// 615 | public static readonly Rgb32F PowderBlue = 0xB0E0E6; 616 | 617 | /// 618 | /// Gets a that has a RGB value of #800080. 619 | /// 620 | public static readonly Rgb32F Purple = 0x800080; 621 | 622 | /// 623 | /// Gets a that has a RGB value of #FF0000. 624 | /// 625 | public static readonly Rgb32F Red = 0xFF0000; 626 | 627 | /// 628 | /// Gets a that has a RGB value of #BC8F8F. 629 | /// 630 | public static readonly Rgb32F RosyBrown = 0xBC8F8F; 631 | 632 | /// 633 | /// Gets a that has a RGB value of #4169E1. 634 | /// 635 | public static readonly Rgb32F RoyalBlue = 0x4169E1; 636 | 637 | /// 638 | /// Gets a that has a RGB value of #8B4513. 639 | /// 640 | public static readonly Rgb32F SaddleBrown = 0x8B4513; 641 | 642 | /// 643 | /// Gets a that has a RGB value of #FA8072. 644 | /// 645 | public static readonly Rgb32F Salmon = 0xFA8072; 646 | 647 | /// 648 | /// Gets a that has a RGB value of #F4A460. 649 | /// 650 | public static readonly Rgb32F SandyBrown = 0xF4A460; 651 | 652 | /// 653 | /// Gets a that has a RGB value of #2E8B57. 654 | /// 655 | public static readonly Rgb32F SeaGreen = 0x2E8B57; 656 | 657 | /// 658 | /// Gets a that has a RGB value of #FFF5EE. 659 | /// 660 | public static readonly Rgb32F SeaShell = 0xFFF5EE; 661 | 662 | /// 663 | /// Gets a that has a RGB value of #A0522D. 664 | /// 665 | public static readonly Rgb32F Sienna = 0xA0522D; 666 | 667 | /// 668 | /// Gets a that has a RGB value of #C0C0C0. 669 | /// 670 | public static readonly Rgb32F Silver = 0xC0C0C0; 671 | 672 | /// 673 | /// Gets a that has a RGB value of #87CEEB. 674 | /// 675 | public static readonly Rgb32F SkyBlue = 0x87CEEB; 676 | 677 | /// 678 | /// Gets a that has a RGB value of #6A5ACD. 679 | /// 680 | public static readonly Rgb32F SlateBlue = 0x6A5ACD; 681 | 682 | /// 683 | /// Gets a that has a RGB value of #708090. 684 | /// 685 | public static readonly Rgb32F SlateGray = 0x708090; 686 | 687 | /// 688 | /// Gets a that has a RGB value of #708090. 689 | /// 690 | public static readonly Rgb32F SlateGrey = 0x708090; 691 | 692 | /// 693 | /// Gets a that has a RGB value of #FFFAFA. 694 | /// 695 | public static readonly Rgb32F Snow = 0xFFFAFA; 696 | 697 | /// 698 | /// Gets a that has a RGB value of #00FF7F. 699 | /// 700 | public static readonly Rgb32F SpringGreen = 0x00FF7F; 701 | 702 | /// 703 | /// Gets a that has a RGB value of #4682B4. 704 | /// 705 | public static readonly Rgb32F SteelBlue = 0x4682B4; 706 | 707 | /// 708 | /// Gets a that has a RGB value of #D2B48C. 709 | /// 710 | public static readonly Rgb32F Tan = 0xD2B48C; 711 | 712 | /// 713 | /// Gets a that has a RGB value of #008080. 714 | /// 715 | public static readonly Rgb32F Teal = 0x008080; 716 | 717 | /// 718 | /// Gets a that has a RGB value of #D8BFD8. 719 | /// 720 | public static readonly Rgb32F Thistle = 0xD8BFD8; 721 | 722 | /// 723 | /// Gets a that has a RGB value of #FF6347. 724 | /// 725 | public static readonly Rgb32F Tomato = 0xFF6347; 726 | 727 | /// 728 | /// Gets a that has a RGB value of #40E0D0. 729 | /// 730 | public static readonly Rgb32F Turquoise = 0x40E0D0; 731 | 732 | /// 733 | /// Gets a that has a RGB value of #EE82EE. 734 | /// 735 | public static readonly Rgb32F Violet = 0xEE82EE; 736 | 737 | /// 738 | /// Gets a that has a RGB value of #F5DEB3. 739 | /// 740 | public static readonly Rgb32F Wheat = 0xF5DEB3; 741 | 742 | /// 743 | /// Gets a that has a RGB value of #FFFFFF. 744 | /// 745 | public static readonly Rgb32F White = 0xFFFFFF; 746 | 747 | /// 748 | /// Gets a that has a RGB value of #F5F5F5. 749 | /// 750 | public static readonly Rgb32F WhiteSmoke = 0xF5F5F5; 751 | 752 | /// 753 | /// Gets a that has a RGB value of #FFFF00. 754 | /// 755 | public static readonly Rgb32F Yellow = 0xFFFF00; 756 | 757 | /// 758 | /// Gets a that has a RGB value of #9ACD32. 759 | /// 760 | public static readonly Rgb32F YellowGreen = 0x9ACD32; 761 | } 762 | -------------------------------------------------------------------------------- /src/cs/production/Interop.Sokol/Rgba8U.Colors.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Bottlenose Labs Inc. (https://github.com/bottlenoselabs). All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the Git repository root directory for full license information. 3 | 4 | namespace bottlenoselabs.Interop.Sokol; 5 | 6 | public partial struct Rgba8U 7 | { 8 | // https://en.wikipedia.org/wiki/X11_color_names 9 | 10 | /// 11 | /// Gets a that has a RGBA value of #00000000. 12 | /// 13 | public static readonly Rgba8U TransparentBlack = 0x00000000; 14 | 15 | /// 16 | /// Gets a that has a RGBA value of #000000FF. 17 | /// 18 | public static readonly Rgba8U Transparent = 0x00000000; 19 | 20 | /// 21 | /// Gets a that has a RGBA value of #E73C00FF. 22 | /// 23 | public static readonly Rgba8U MonoGameOrange = 0xE73C00FF; 24 | 25 | /// 26 | /// Gets a that has a RGBA value of #F0F8FFFF. 27 | /// 28 | public static readonly Rgba8U AliceBlue = 0xF0F8FFFF; 29 | 30 | /// 31 | /// Gets a that has a RGBA value of #FAEBD7FF. 32 | /// 33 | public static readonly Rgba8U AntiqueWhite = 0xFAEBD7FF; 34 | 35 | /// 36 | /// Gets a that has a RGBA value of #00FFFFFF. 37 | /// 38 | public static readonly Rgba8U Aqua = 0x00FFFFFF; 39 | 40 | /// 41 | /// Gets a that has a RGBA value of #7FFFD4FF. 42 | /// 43 | public static readonly Rgba8U Aquamarine = 0x7FFFD4FF; 44 | 45 | /// 46 | /// Gets a that has a RGBA value of #F0FFFFFF. 47 | /// 48 | public static readonly Rgba8U Azure = 0xF0FFFFFF; 49 | 50 | /// 51 | /// Gets a that has a RGBA value of #F5F5DCFF. 52 | /// 53 | public static readonly Rgba8U Beige = 0xF5F5DCFF; 54 | 55 | /// 56 | /// Gets a that has a RGBA value of #FFE4C4FF. 57 | /// 58 | public static readonly Rgba8U Bisque = 0xFFE4C4FF; 59 | 60 | /// 61 | /// Gets a that has a RGBA value of #000000FF. 62 | /// 63 | public static readonly Rgba8U Black = 0x000000FF; 64 | 65 | /// 66 | /// Gets a that has a RGBA value of #FFEBCDFF. 67 | /// 68 | public static readonly Rgba8U BlanchedAlmond = 0xFFEBCDFF; 69 | 70 | /// 71 | /// Gets a that has a RGBA value of #0000FFFF. 72 | /// 73 | public static readonly Rgba8U Blue = 0x0000FFFF; 74 | 75 | /// 76 | /// Gets a that has a RGBA value of #8A2BE2FF. 77 | /// 78 | public static readonly Rgba8U BlueViolet = 0x8A2BE2FF; 79 | 80 | /// 81 | /// Gets a that has a RGBA value of #A52A2AFF. 82 | /// 83 | public static readonly Rgba8U Brown = 0xA52A2AFF; 84 | 85 | /// 86 | /// Gets a that has a RGBA value of #DEB887FF. 87 | /// 88 | public static readonly Rgba8U BurlyWood = 0xDEB887FF; 89 | 90 | /// 91 | /// Gets a that has a RGBA value of #5F9EA0FF. 92 | /// 93 | public static readonly Rgba8U CadetBlue = 0x5F9EA0FF; 94 | 95 | /// 96 | /// Gets a that has a RGBA value of #7FFF00FF. 97 | /// 98 | public static readonly Rgba8U Chartreuse = 0x7FFF00FF; 99 | 100 | /// 101 | /// Gets a that has a RGBA value of #D2691EFF. 102 | /// 103 | public static readonly Rgba8U Chocolate = 0xD2691EFF; 104 | 105 | /// 106 | /// Gets a that has a RGBA value of #FF7F50FF. 107 | /// 108 | public static readonly Rgba8U Coral = 0xFF7F50FF; 109 | 110 | /// 111 | /// Gets a that has a RGBA value of #6495EDFF. 112 | /// 113 | public static readonly Rgba8U CornflowerBlue = 0x6495EDFF; 114 | 115 | /// 116 | /// Gets a that has a RGBA value of #FFF8DCFF. 117 | /// 118 | public static readonly Rgba8U Cornsilk = 0xFFF8DCFF; 119 | 120 | /// 121 | /// Gets a that has a RGBA value of #DC143CFF. 122 | /// 123 | public static readonly Rgba8U Crimson = 0xDC143CFF; 124 | 125 | /// 126 | /// Gets a that has a RGBA value of #00FFFFFF. 127 | /// 128 | public static readonly Rgba8U Cyan = 0x00FFFFFF; 129 | 130 | /// 131 | /// Gets a that has a RGBA value of #00008BFF. 132 | /// 133 | public static readonly Rgba8U DarkBlue = 0x00008BFF; 134 | 135 | /// 136 | /// Gets a that has a RGBA value of #008B8BFF. 137 | /// 138 | public static readonly Rgba8U DarkCyan = 0x008B8BFF; 139 | 140 | /// 141 | /// Gets a that has a RGBA value of #B8860BFF. 142 | /// 143 | public static readonly Rgba8U DarkGoldenrod = 0xB8860BFF; 144 | 145 | /// 146 | /// Gets a that has a RGBA value of #A9A9A9FF. 147 | /// 148 | public static readonly Rgba8U DarkGray = 0xA9A9A9FF; 149 | 150 | /// 151 | /// Gets a that has a RGBA value of #006400FF. 152 | /// 153 | public static readonly Rgba8U DarkGreen = 0x006400FF; 154 | 155 | /// 156 | /// Gets a that has a RGBA value of #A9A9A9FF. 157 | /// 158 | public static readonly Rgba8U DarkGrey = 0xA9A9A9FF; 159 | 160 | /// 161 | /// Gets a that has a RGBA value of #BDB76BFF. 162 | /// 163 | public static readonly Rgba8U DarkKhaki = 0xBDB76BFF; 164 | 165 | /// 166 | /// Gets a that has a RGBA value of #8B008BFF. 167 | /// 168 | public static readonly Rgba8U DarkMagenta = 0x8B008BFF; 169 | 170 | /// 171 | /// Gets a that has a RGBA value of #556B2FFF. 172 | /// 173 | public static readonly Rgba8U DarkOliveGreen = 0x556B2FFF; 174 | 175 | /// 176 | /// Gets a that has a RGBA value of #FF8C00FF. 177 | /// 178 | public static readonly Rgba8U DarkOrange = 0xFF8C00FF; 179 | 180 | /// 181 | /// Gets a that has a RGBA value of #9932CCFF. 182 | /// 183 | public static readonly Rgba8U DarkOrchid = 0x9932CCFF; 184 | 185 | /// 186 | /// Gets a that has a RGBA value of #8B0000FF. 187 | /// 188 | public static readonly Rgba8U DarkRed = 0x8B0000FF; 189 | 190 | /// 191 | /// Gets a that has a RGBA value of #E9967AFF. 192 | /// 193 | public static readonly Rgba8U DarkSalmon = 0xE9967AFF; 194 | 195 | /// 196 | /// Gets a that has a RGBA value of #8FBC8FFF. 197 | /// 198 | public static readonly Rgba8U DarkSeaGreen = 0x8FBC8FFF; 199 | 200 | /// 201 | /// Gets a that has a RGBA value of #483D8BFF. 202 | /// 203 | public static readonly Rgba8U DarkStateBlue = 0x483D8BFF; 204 | 205 | /// 206 | /// Gets a that has a RGBA value of #2F4F4FFF. 207 | /// 208 | public static readonly Rgba8U DarkStateGray = 0x2F4F4FFF; 209 | 210 | /// 211 | /// Gets a that has a RGBA value of #2F4F4FFF. 212 | /// 213 | public static readonly Rgba8U DarkStateGrey = 0x2F4F4FFF; 214 | 215 | /// 216 | /// Gets a that has a RGBA value of #00CED1FF. 217 | /// 218 | public static readonly Rgba8U DarkTurquoise = 0x00CED1FF; 219 | 220 | /// 221 | /// Gets a that has a RGBA value of #9400D3FF. 222 | /// 223 | public static readonly Rgba8U DarkViolet = 0x9400D3FF; 224 | 225 | /// 226 | /// Gets a that has a RGBA value of #FF1493FF. 227 | /// 228 | public static readonly Rgba8U DeepPink = 0xFF1493FF; 229 | 230 | /// 231 | /// Gets a that has a RGBA value of #00BFFFFF. 232 | /// 233 | public static readonly Rgba8U DeepSkyBlue = 0x00BFFFFF; 234 | 235 | /// 236 | /// Gets a that has a RGBA value of #696969FF. 237 | /// 238 | public static readonly Rgba8U DimGray = 0x696969FF; 239 | 240 | /// 241 | /// Gets a that has a RGBA value of #696969FF. 242 | /// 243 | public static readonly Rgba8U DimGrey = 0x696969FF; 244 | 245 | /// 246 | /// Gets a that has a RGBA value of #1E90FFFF. 247 | /// 248 | public static readonly Rgba8U DodgerBlue = 0x1E90FFFF; 249 | 250 | /// 251 | /// Gets a that has a RGBA value of #B22222FF. 252 | /// 253 | public static readonly Rgba8U Firebrick = 0xB22222FF; 254 | 255 | /// 256 | /// Gets a that has a RGBA value of #FFFAF0FF. 257 | /// 258 | public static readonly Rgba8U FloralWhite = 0xFFFAF0FF; 259 | 260 | /// 261 | /// Gets a that has a RGBA value of #228B22FF. 262 | /// 263 | public static readonly Rgba8U ForestGreen = 0x228B22FF; 264 | 265 | /// 266 | /// Gets a that has a RGBA value of #FF00FFFF. 267 | /// 268 | public static readonly Rgba8U Fuchsia = 0xFF00FFFF; 269 | 270 | /// 271 | /// Gets a that has a RGBA value of #DCDCDCFF. 272 | /// 273 | public static readonly Rgba8U Gainsboro = 0xDCDCDCFF; 274 | 275 | /// 276 | /// Gets a that has a RGBA value of #F8F8FFFF. 277 | /// 278 | public static readonly Rgba8U GhostWhite = 0xF8F8FFFF; 279 | 280 | /// 281 | /// Gets a that has a RGBA value of #FFD700FF. 282 | /// 283 | public static readonly Rgba8U Gold = 0xFFD700FF; 284 | 285 | /// 286 | /// Gets a that has a RGBA value of #DAA520FF. 287 | /// 288 | public static readonly Rgba8U Goldenrod = 0xDAA520FF; 289 | 290 | /// 291 | /// Gets a that has a RGBA value of #808080FF. 292 | /// 293 | public static readonly Rgba8U Gray = 0x808080FF; 294 | 295 | /// 296 | /// Gets a that has a RGBA value of #008000FF. 297 | /// 298 | public static readonly Rgba8U Green = 0x008000FF; 299 | 300 | /// 301 | /// Gets a that has a RGBA value of #ADFF2FFF. 302 | /// 303 | public static readonly Rgba8U GreenYellow = 0xADFF2FFF; 304 | 305 | /// 306 | /// Gets a that has a RGBA value of #808080FF. 307 | /// 308 | public static readonly Rgba8U Grey = 0x808080FF; 309 | 310 | /// 311 | /// Gets a that has a RGBA value of #F0FFF0FF. 312 | /// 313 | public static readonly Rgba8U Honeydew = 0xF0FFF0FF; 314 | 315 | /// 316 | /// Gets a that has a RGBA value of #FF69B4FF. 317 | /// 318 | public static readonly Rgba8U HotPink = 0xFF69B4FF; 319 | 320 | /// 321 | /// Gets a that has a RGBA value of #CD5C5CFF. 322 | /// 323 | public static readonly Rgba8U IndianRed = 0xCD5C5CFF; 324 | 325 | /// 326 | /// Gets a that has a RGBA value of #4B0082FF. 327 | /// 328 | public static readonly Rgba8U Indigo = 0x4B0082FF; 329 | 330 | /// 331 | /// Gets a that has a RGBA value of #FFFFF0FF. 332 | /// 333 | public static readonly Rgba8U Ivory = 0xFFFFF0FF; 334 | 335 | /// 336 | /// Gets a that has a RGBA value of #F0E68CFF. 337 | /// 338 | public static readonly Rgba8U Khaki = 0xF0E68CFF; 339 | 340 | /// 341 | /// Gets a that has a RGBA value of #E6E6FAFF. 342 | /// 343 | public static readonly Rgba8U Lavender = 0xE6E6FAFF; 344 | 345 | /// 346 | /// Gets a that has a RGBA value of #FFF0F5FF. 347 | /// 348 | public static readonly Rgba8U LavenderBlush = 0xFFF0F5FF; 349 | 350 | /// 351 | /// Gets a that has a RGBA value of #7CFC00FF. 352 | /// 353 | public static readonly Rgba8U LawnGreen = 0x7CFC00FF; 354 | 355 | /// 356 | /// Gets a that has a RGBA value of #FFFACDFF. 357 | /// 358 | public static readonly Rgba8U LemonChiffon = 0xFFFACDFF; 359 | 360 | /// 361 | /// Gets a that has a RGBA value of #ADD8E6FF. 362 | /// 363 | public static readonly Rgba8U LightBlue = 0xADD8E6FF; 364 | 365 | /// 366 | /// Gets a that has a RGBA value of #F08080FF. 367 | /// 368 | public static readonly Rgba8U LightCoral = 0xF08080FF; 369 | 370 | /// 371 | /// Gets a that has a RGBA value of #E0FFFFFF. 372 | /// 373 | public static readonly Rgba8U LightCyan = 0xE0FFFFFF; 374 | 375 | /// 376 | /// Gets a that has a RGBA value of #FAFAD2FF. 377 | /// 378 | public static readonly Rgba8U LightGoldenrodYellow = 0xFAFAD2FF; 379 | 380 | /// 381 | /// Gets a that has a RGBA value of #D3D3D3FF. 382 | /// 383 | public static readonly Rgba8U LightGray = 0xD3D3D3FF; 384 | 385 | /// 386 | /// Gets a that has a RGBA value of #90EE90FF. 387 | /// 388 | public static readonly Rgba8U LightGreen = 0x90EE90FF; 389 | 390 | /// 391 | /// Gets a that has a RGBA value of #D3D3D3FF. 392 | /// 393 | public static readonly Rgba8U LightGrey = 0xD3D3D3FF; 394 | 395 | /// 396 | /// Gets a that has a RGBA value of #FFB6C1FF. 397 | /// 398 | public static readonly Rgba8U LightPink = 0xFFB6C1FF; 399 | 400 | /// 401 | /// Gets a that has a RGBA value of #FFA07AFF. 402 | /// 403 | public static readonly Rgba8U LightSalmon = 0xFFA07AFF; 404 | 405 | /// 406 | /// Gets a that has a RGBA value of #20B2AAFF. 407 | /// 408 | public static readonly Rgba8U LightSeaGreen = 0x20B2AAFF; 409 | 410 | /// 411 | /// Gets a that has a RGBA value of #87CEFAFF. 412 | /// 413 | public static readonly Rgba8U LightSkyBlue = 0x87CEFAFF; 414 | 415 | /// 416 | /// Gets a that has a RGBA value of #778899FF. 417 | /// 418 | public static readonly Rgba8U LightSlateGray = 0x778899FF; 419 | 420 | /// 421 | /// Gets a that has a RGBA value of #778899FF. 422 | /// 423 | public static readonly Rgba8U LightSlateGrey = 0x778899FF; 424 | 425 | /// 426 | /// Gets a that has a RGBA value of #B0C4DEFF. 427 | /// 428 | public static readonly Rgba8U LightSteelBlue = 0xB0C4DEFF; 429 | 430 | /// 431 | /// Gets a that has a RGBA value of #FFFFE0FF. 432 | /// 433 | public static readonly Rgba8U LightYellow = 0xFFFFE0FF; 434 | 435 | /// 436 | /// Gets a that has a RGBA value of #00FF00FF. 437 | /// 438 | public static readonly Rgba8U Lime = 0x00FF00FF; 439 | 440 | /// 441 | /// Gets a that has a RGBA value of #32CD32FF. 442 | /// 443 | public static readonly Rgba8U LimeGreen = 0x32CD32FF; 444 | 445 | /// 446 | /// Gets a that has a RGBA value of #FAF0E6FF. 447 | /// 448 | public static readonly Rgba8U Linen = 0xFAF0E6FF; 449 | 450 | /// 451 | /// Gets a that has a RGBA value of #FF00FFFF. 452 | /// 453 | public static readonly Rgba8U Magenta = 0xFF00FFFF; 454 | 455 | /// 456 | /// Gets a that has a RGBA value of #800000FF. 457 | /// 458 | public static readonly Rgba8U Maroon = 0x800000FF; 459 | 460 | /// 461 | /// Gets a that has a RGBA value of #66CDAAFF. 462 | /// 463 | public static readonly Rgba8U MediumAquamarine = 0x66CDAAFF; 464 | 465 | /// 466 | /// Gets a that has a RGBA value of #0000CDFF. 467 | /// 468 | public static readonly Rgba8U MediumBlue = 0x0000CDFF; 469 | 470 | /// 471 | /// Gets a that has a RGBA value of #BA55D3FF. 472 | /// 473 | public static readonly Rgba8U MediumOrchid = 0xBA55D3FF; 474 | 475 | /// 476 | /// Gets a that has a RGBA value of #9370DBFF. 477 | /// 478 | public static readonly Rgba8U MediumPurple = 0x9370DBFF; 479 | 480 | /// 481 | /// Gets a that has a RGBA value of #3CB371FF. 482 | /// 483 | public static readonly Rgba8U MediumSeaGreen = 0x3CB371FF; 484 | 485 | /// 486 | /// Gets a that has a RGBA value of #7B68EEFF. 487 | /// 488 | public static readonly Rgba8U MediumStateBlue = 0x7B68EEFF; 489 | 490 | /// 491 | /// Gets a that has a RGBA value of #00FA9AFF. 492 | /// 493 | public static readonly Rgba8U MediumSpringGreen = 0x00FA9AFF; 494 | 495 | /// 496 | /// Gets a that has a RGBA value of #48D1CCFF. 497 | /// 498 | public static readonly Rgba8U MediumTurquoise = 0x48D1CCFF; 499 | 500 | /// 501 | /// Gets a that has a RGBA value of #C71585FF. 502 | /// 503 | public static readonly Rgba8U MediumVioletRed = 0xC71585FF; 504 | 505 | /// 506 | /// Gets a that has a RGBA value of #191970FF. 507 | /// 508 | public static readonly Rgba8U MidnightBlue = 0x191970FF; 509 | 510 | /// 511 | /// Gets a that has a RGBA value of #F5FFFAFF. 512 | /// 513 | public static readonly Rgba8U MintCream = 0xF5FFFAFF; 514 | 515 | /// 516 | /// Gets a that has a RGBA value of #FFE4E1FF. 517 | /// 518 | public static readonly Rgba8U MistyRose = 0xFFE4E1FF; 519 | 520 | /// 521 | /// Gets a that has a RGBA value of #FFE4B5FF. 522 | /// 523 | public static readonly Rgba8U Moccasin = 0xFFE4B5FF; 524 | 525 | /// 526 | /// Gets a that has a RGBA value of #FFDEADFF. 527 | /// 528 | public static readonly Rgba8U NavajoWhite = 0xFFDEADFF; 529 | 530 | /// 531 | /// Gets a that has a RGBA value of #000080FF. 532 | /// 533 | public static readonly Rgba8U Navy = 0x000080FF; 534 | 535 | /// 536 | /// Gets a that has a RGBA value of #FDF5E6FF. 537 | /// 538 | public static readonly Rgba8U OldLace = 0xFDF5E6FF; 539 | 540 | /// 541 | /// Gets a that has a RGBA value of #808000FF. 542 | /// 543 | public static readonly Rgba8U Olive = 0x808000FF; 544 | 545 | /// 546 | /// Gets a that has a RGBA value of #6B8E23FF. 547 | /// 548 | public static readonly Rgba8U OliveDrab = 0x6B8E23FF; 549 | 550 | /// 551 | /// Gets a that has a RGBA value of #FFA500FF. 552 | /// 553 | public static readonly Rgba8U Orange = 0xFFA500FF; 554 | 555 | /// 556 | /// Gets a that has a RGBA value of #FF4500FF. 557 | /// 558 | public static readonly Rgba8U OrangeRed = 0xFF4500FF; 559 | 560 | /// 561 | /// Gets a that has a RGBA value of #DA70D6FF. 562 | /// 563 | public static readonly Rgba8U Orchid = 0xDA70D6FF; 564 | 565 | /// 566 | /// Gets a that has a RGBA value of #EEE8AAFF. 567 | /// 568 | public static readonly Rgba8U PaleGoldenrod = 0xEEE8AAFF; 569 | 570 | /// 571 | /// Gets a that has a RGBA value of #98FB98FF. 572 | /// 573 | public static readonly Rgba8U PaleGreen = 0x98FB98FF; 574 | 575 | /// 576 | /// Gets a that has a RGBA value of #AFEEEEFF. 577 | /// 578 | public static readonly Rgba8U PaleTurquoise = 0xAFEEEEFF; 579 | 580 | /// 581 | /// Gets a that has a RGBA value of #DB7093FF. 582 | /// 583 | public static readonly Rgba8U PaleVioletRed = 0xDB7093FF; 584 | 585 | /// 586 | /// Gets a that has a RGBA value of #FFEFD5FF. 587 | /// 588 | public static readonly Rgba8U PapayaWhip = 0xFFEFD5FF; 589 | 590 | /// 591 | /// Gets a that has a RGBA value of #FFDAB9FF. 592 | /// 593 | public static readonly Rgba8U PeachPuff = 0xFFDAB9FF; 594 | 595 | /// 596 | /// Gets a that has a RGBA value of #CD853FFF. 597 | /// 598 | public static readonly Rgba8U Peru = 0xCD853FFF; 599 | 600 | /// 601 | /// Gets a that has a RGBA value of #FFC0CBFF. 602 | /// 603 | public static readonly Rgba8U Pink = 0xFFC0CBFF; 604 | 605 | /// 606 | /// Gets a that has a RGBA value of #DDA0DDFF. 607 | /// 608 | public static readonly Rgba8U Plum = 0xDDA0DDFF; 609 | 610 | /// 611 | /// Gets a that has a RGBA value of #B0E0E6FF. 612 | /// 613 | public static readonly Rgba8U PowderBlue = 0xB0E0E6FF; 614 | 615 | /// 616 | /// Gets a that has a RGBA value of #800080FF. 617 | /// 618 | public static readonly Rgba8U Purple = 0x800080FF; 619 | 620 | /// 621 | /// Gets a that has a RGBA value of #FF0000FF. 622 | /// 623 | public static readonly Rgba8U Red = 0xFF0000FF; 624 | 625 | /// 626 | /// Gets a that has a RGBA value of #BC8F8FFF. 627 | /// 628 | public static readonly Rgba8U RosyBrown = 0xBC8F8FFF; 629 | 630 | /// 631 | /// Gets a that has a RGBA value of #4169E1FF. 632 | /// 633 | public static readonly Rgba8U RoyalBlue = 0x4169E1FF; 634 | 635 | /// 636 | /// Gets a that has a RGBA value of #8B4513FF. 637 | /// 638 | public static readonly Rgba8U SaddleBrown = 0x8B4513FF; 639 | 640 | /// 641 | /// Gets a that has a RGBA value of #FA8072FF. 642 | /// 643 | public static readonly Rgba8U Salmon = 0xFA8072FF; 644 | 645 | /// 646 | /// Gets a that has a RGBA value of #F4A460FF. 647 | /// 648 | public static readonly Rgba8U SandyBrown = 0xF4A460FF; 649 | 650 | /// 651 | /// Gets a that has a RGBA value of #2E8B57FF. 652 | /// 653 | public static readonly Rgba8U SeaGreen = 0x2E8B57FF; 654 | 655 | /// 656 | /// Gets a that has a RGBA value of #FFF5EEFF. 657 | /// 658 | public static readonly Rgba8U SeaShell = 0xFFF5EEFF; 659 | 660 | /// 661 | /// Gets a that has a RGBA value of #A0522DFF. 662 | /// 663 | public static readonly Rgba8U Sienna = 0xA0522DFF; 664 | 665 | /// 666 | /// Gets a that has a RGBA value of #C0C0C0FF. 667 | /// 668 | public static readonly Rgba8U Silver = 0xC0C0C0FF; 669 | 670 | /// 671 | /// Gets a that has a RGBA value of #87CEEBFF. 672 | /// 673 | public static readonly Rgba8U SkyBlue = 0x87CEEBFF; 674 | 675 | /// 676 | /// Gets a that has a RGBA value of #6A5ACDFF. 677 | /// 678 | public static readonly Rgba8U SlateBlue = 0x6A5ACDFF; 679 | 680 | /// 681 | /// Gets a that has a RGBA value of #708090FF. 682 | /// 683 | public static readonly Rgba8U SlateGray = 0x708090FF; 684 | 685 | /// 686 | /// Gets a that has a RGBA value of #708090FF. 687 | /// 688 | public static readonly Rgba8U SlateGrey = 0x708090FF; 689 | 690 | /// 691 | /// Gets a that has a RGBA value of #FFFAFAFF. 692 | /// 693 | public static readonly Rgba8U Snow = 0xFFFAFAFF; 694 | 695 | /// 696 | /// Gets a that has a RGBA value of #00FF7FFF. 697 | /// 698 | public static readonly Rgba8U SpringGreen = 0x00FF7FFF; 699 | 700 | /// 701 | /// Gets a that has a RGBA value of #4682B4FF. 702 | /// 703 | public static readonly Rgba8U SteelBlue = 0x4682B4FF; 704 | 705 | /// 706 | /// Gets a that has a RGBA value of #D2B48CFF. 707 | /// 708 | public static readonly Rgba8U Tan = 0xD2B48CFF; 709 | 710 | /// 711 | /// Gets a that has a RGBA value of #008080FF. 712 | /// 713 | public static readonly Rgba8U Teal = 0x008080FF; 714 | 715 | /// 716 | /// Gets a that has a RGBA value of #D8BFD8FF. 717 | /// 718 | public static readonly Rgba8U Thistle = 0xD8BFD8FF; 719 | 720 | /// 721 | /// Gets a that has a RGBA value of #FF6347FF. 722 | /// 723 | public static readonly Rgba8U Tomato = 0xFF6347FF; 724 | 725 | /// 726 | /// Gets a that has a RGBA value of #40E0D0FF. 727 | /// 728 | public static readonly Rgba8U Turquoise = 0x40E0D0FF; 729 | 730 | /// 731 | /// Gets a that has a RGBA value of #EE82EEFF. 732 | /// 733 | public static readonly Rgba8U Violet = 0xEE82EEFF; 734 | 735 | /// 736 | /// Gets a that has a RGBA value of #F5DEB3FF. 737 | /// 738 | public static readonly Rgba8U Wheat = 0xF5DEB3FF; 739 | 740 | /// 741 | /// Gets a that has a RGBA value of #FFFFFFFF. 742 | /// 743 | public static readonly Rgba8U White = 0xFFFFFFFF; 744 | 745 | /// 746 | /// Gets a that has a RGBA value of #F5F5F5FF. 747 | /// 748 | public static readonly Rgba8U WhiteSmoke = 0xF5F5F5FF; 749 | 750 | /// 751 | /// Gets a that has a RGBA value of #FFFF00FF. 752 | /// 753 | public static readonly Rgba8U Yellow = 0xFFFF00FF; 754 | 755 | /// 756 | /// Gets a that has a RGBA value of #9ACD32FF. 757 | /// 758 | public static readonly Rgba8U YellowGreen = 0x9ACD32FF; 759 | } 760 | --------------------------------------------------------------------------------