In this blog post we are going to take a look at the OpenTK.redist.glfw package and why it is a separate package from the “normal” OpenTK.Windowing.GraphicsLibraryFramework package.

In OpenTK 4 all windowing functions are handled through GLFW. To be able to call GLFW functions OpenTK needs two things, C# bindings for the C functions that GLFW exposes, and the topic of this blogpost, a native library containing the actual GLFW code that can be loaded and called. The bindings are handled using standard C# P/Invoke in OpenTK.Windowing.GraphicsLibraryFramework but without a native compiled binary there is no code to call.

That is where OpenTK.redist.glfw comes in. It is a package that contains prebuilt GLFW binaries for Windows, macOS, and Linux for different architectures. This allows the runtime to load the appropriate native binary at startup.

This separation means that the OpenTK version only sets a lower bound on the GLFW version, but users are able to upgrade to newer GLFW releases to get access to bug fixes without changing OpenTK version.

For example OpenTK 4.9.4 only requires OpenTK.redist.glfw >= 3.4.0.44 so it’s possible to manually upgrade to the newer OpenTK.redist.glfw 3.4.0.47 version by explicitly referencing it in your .csproj file like this:

    <PackageReference Include="OpenTK" Version="4.9.4" />
    <PackageReference Include="OpenTK.redist.glfw" Version="3.4.0.47" />

This allowed us to help fix an issue in Vintage Story on linux by lowering the GLIBC requirement that GLFW was built with.