Isojk.Csglfw
1.0.0-x64
dotnet add package Isojk.Csglfw --version 1.0.0-x64
NuGet\Install-Package Isojk.Csglfw -Version 1.0.0-x64
<PackageReference Include="Isojk.Csglfw" Version="1.0.0-x64" />
<PackageVersion Include="Isojk.Csglfw" Version="1.0.0-x64" />
<PackageReference Include="Isojk.Csglfw" />
paket add Isojk.Csglfw --version 1.0.0-x64
#r "nuget: Isojk.Csglfw, 1.0.0-x64"
#:package Isojk.Csglfw@1.0.0-x64
#addin nuget:?package=Isojk.Csglfw&version=1.0.0-x64&prerelease
#tool nuget:?package=Isojk.Csglfw&version=1.0.0-x64&prerelease
Low-level C# bindings for the GLFW library, version 3.4.
This library utilizes modern language and compiler features (like Function Pointers or P/Invoke source generator) and therefore requires .NET 8 as the minimum target framework version.
All types, constants and methods have exactly the same name as their native counterparts.
Static Linking
This library supports linking native dependencies statically into the target application, enabling to deploy single self-contained native executable.
This feature is available only when the target application is published using Native AOT deployment model in Release configuration.
To enable this feature for a project referencing this library as a PackageReference (e.g. installed with NuGet package manager), a property GLFWEnableStaticBuild with a value set to true must be defined in the project configuration of the target application:
<PropertyGroup>
<GLFWEnableStaticBuild>true</GLFWEnableStaticBuild>
</PropertyGroup>
Everything else should be managed by the package automagically.
If this library is instead referenced as a ProjectReference (as a local project in Visual Studio) two additional steps must be taken:
- An
AdditionalPropertiesattribute must be defined in theProjectReferencein order to propagate theGLFWEnableStaticBuildproperty, like this:<ProjectReference Include="..\..\csglfw\Isojk.Csglfw.csproj" AdditionalProperties="GLFWEnableStaticBuild=$(GLFWEnableStaticBuild)" /> - All required properties and targets from the
buildTransitivedirectory must be imported at the end of the project configuration, like this:<Import Project="..\..\csglfw\buildTransitive\Isojk.Csglfw.props" /> <Import Project="..\..\csglfw\buildTransitive\Isojk.Csglfw.targets" />
Supported Platforms
| System | Processor Architecture | Notes |
|---|---|---|
| Linux | ARM64 | Untested<br>Compiled with arm-linux-gnueabihf-gcc-12 version 12.2.0 (Debian 12.2.0-14) on Debian 12 |
| Linux | x64 | Compiled with x86_64-linux-gnu-gcc-12 version 12.2.0 (Debian 12.2.0-14) on Debian 12 |
| macOS | ARM64 | Untested<br>Copied from the official package with pre-compiled binaries |
| macOS | x64 | Copied from the official package with pre-compiled binaries |
| Windows | ARM64 | Untested<br>Compiled with MSVC 19.43.34810.0<br>Windows SDK version 10.0.22621.0<br>MSVC v143 - VS2022 C++ ARM64/ARM64EC build tools (v14.43-17.13)<br>MSVC v143 - VS2022 C++ ARM64/ARM64EC Spectre-mitigated libs (v14.43-17.13) |
| Windows | x64 | Copied from the official package with pre-compiled binaries |
WSL
If you encounter issues on Windows Subsystem for Linux, try to set the platform to X11 manually as a quick fix, like so:
glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_X11);
if (!glfwInit()) {
return;
}
// ...
Basic Example
using static Isojk.Csglfw.API;
GLFWwindow window = default;
if (!glfwInit()) {
return;
}
try {
window = glfwCreateWindow(1280, 800, "Hello world");
if (!window) {
glfwTerminate();
return;
}
glfwSetKeyCallback(window, (window, key, scancode, action, mods) => {
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) {
glfwSetWindowShouldClose(window, true);
}
});
while (!glfwWindowShouldClose(window)) {
glfwWaitEvents();
}
}
finally {
if (window) {
glfwDestroyWindow(window);
}
glfwTerminate();
}
An Example with Function Pointers
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using static Isojk.Csglfw.API;
GLFWwindow window = default;
if (!glfwInit()) {
return;
}
try {
window = glfwCreateWindow(1280, 800, "Hello world");
if (!window) {
glfwTerminate();
return;
}
unsafe {
Isojk.Csglfw.API.Unsafe.glfwSetKeyCallback(window, &KeyCallback);
}
while (!glfwWindowShouldClose(window)) {
glfwWaitEvents();
}
}
finally {
if (window) {
glfwDestroyWindow(window);
}
glfwTerminate();
}
[UnmanagedCallersOnly(CallConvs = new System.Type[] {typeof(CallConvCdecl)})]
static unsafe void KeyCallback(GLFWwindow window, int key, int scancode, int action, int mods) {
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) {
glfwSetWindowShouldClose(window, true);
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net8.0-windows7.0 is compatible. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net9.0-windows7.0 is compatible. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- No dependencies.
-
net8.0-windows7.0
- No dependencies.
-
net9.0
- No dependencies.
-
net9.0-windows7.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.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-x64 | 253 | 4/21/2025 |
| 1.0.0-arm64 | 203 | 4/21/2025 |