Bgfx.Net.Tools
0.4.0
dotnet add package Bgfx.Net.Tools --version 0.4.0
NuGet\Install-Package Bgfx.Net.Tools -Version 0.4.0
<PackageReference Include="Bgfx.Net.Tools" Version="0.4.0"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="Bgfx.Net.Tools" Version="0.4.0" />
<PackageReference Include="Bgfx.Net.Tools"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add Bgfx.Net.Tools --version 0.4.0
#r "nuget: Bgfx.Net.Tools, 0.4.0"
#:package Bgfx.Net.Tools@0.4.0
#addin nuget:?package=Bgfx.Net.Tools&version=0.4.0
#tool nuget:?package=Bgfx.Net.Tools&version=0.4.0
Bgfx.Net
Cross-platform .NET bindings for bgfx, a graphics rendering library that runs on Windows, Linux, macOS, and Android with Direct3D, Vulkan, OpenGL, OpenGL ES, and Metal backends.
Packages
| Package | Purpose |
|---|---|
Bgfx.Net |
Managed bindings + native bgfx shared library for all supported RIDs |
Bgfx.Net.Tools |
MSBuild integration that runs shaderc / texturec / geometryc at build time. Marked developmentDependency, so it doesn't propagate into consumer output. |
Supported RIDs: win-x64, linux-x64, osx-x64, osx-arm64, android-arm64,
android-x64. (linux-arm64 is planned — blocked on upstream bx adding a native
linux-arm64-gcc action.)
On Android the native libbgfx.so is shipped under runtimes/android-arm64/native
and runtimes/android-x64/native; a net*-android app that references the package
gets it bundled into the APK automatically. Two consumer-side notes:
- The app's effective Android
<RuntimeIdentifiers>must include the ABIs you want bundled — Release builds often resolve onlyandroid-arm64, so addandroid-x64if you also need the x86_64 emulator. - Supply bgfx the native window: set
PlatformData.Nwhto theANativeWindow*obtained from the JavaSurfacevia JNI/NDK beforeInit.
Quick start
using Bgfx.Net;
var init = new InitDescription { Type = RendererType.Vulkan };
Bgfx.Init(in init);
while (running)
{
Bgfx.Frame();
}
Bgfx.Shutdown();
Cloning
This repository uses git submodules for bgfx, bx, and bimg:
git clone --recurse-submodules https://github.com/$USER/Bgfx.Net.git
# or, after a normal clone:
git submodule update --init --recursive
# or use the helper:
./build/bootstrap.sh
Building locally
Prerequisites: .NET SDK 10, plus a C++ toolchain for your platform
(MSVC on Windows, gcc/clang on Linux, Xcode CLT on macOS). On Windows the native
build still uses PowerShell (build-native-win.ps1). To cross-build the Android
native lib, install an NDK and run build-native-android.sh android-arm64
(or android-x64) with ANDROID_NDK_ROOT set.
./build/bootstrap.sh # init submodules, fetch genie
./build/build-native-unix.sh # or build-native-win.ps1 on Windows
./build/sync-bindings.sh # copies bgfx.cs into src/Bgfx.Net/Generated/
./build/run-generator.sh # produces bgfx.g.cs
dotnet build Bgfx.Net.sln
Caveats
- Shaders on Linux/macOS:
shaderccan produce GLSL/ESSL/Metal/SPIR-V on all platforms, but Direct3D shader compilation (DXBC viafxc, DXIL viadxc) needs additional Windows-side tooling. - Threading: bgfx uses an API thread + render thread model selected at
Init. See bgfx's docs for the threading contract. - Pinned to a specific bgfx revision: The
Bgfx.Netassembly is built against exactly one bgfx commit. Read the pin at runtime viaBgfx.Net.BgfxBuildInfo.ApiVersionand.Revision(also embedded asBgfxApiVersion/BgfxRevisionassembly metadata). The package version itself is independent wrapper SemVer, not the bgfx revision — see RELEASING.md. Mixing the assembly with a differentbgfx.dllat runtime is unsupported.
License
BSD-2-Clause. See LICENSE for our code and THIRD-PARTY-NOTICES.md for upstream and 3rdparty attributions.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Bundles bgfx API v147. Exact upstream commit recorded in assembly metadata (BgfxRevision).