Jump to content

glfw-net, a GLFW3 .NET Binding


Recommended Posts

What is GLFW3?


GLFW is an Open Source, multi-platform library for creating windows with OpenGL contexts and receiving input and events. It is easy to integrate into existing applications and does not lay claim to the main loop.

GLFW is written in C and has native support for Windows, OS X and many Unix-like systems using the X Window System, such as Linux and FreeBSD.

Note: This means it's just a windowing system. Creating an OpenGL binding is something I'm also considering doing, but the OpenGL API is far larger and far more difficult to implement a binding for and test to see that every single facet of the binding works.

What is glfw-net?
glfw-net is a .NET binding of only GLFW3 (so no earlier versions) that is meant to mimic the GLFW3 API as close as possible -- types and casing are almost exactly the same. Obviously since GLFW3 supports multiple operating systems the goal of glfw-net is also to support those same systems. Currently due to the limitations of C#, the C# equivalent of C++ API calls need to be prefixed with "GLFW3.", but if my interpretation serves correct, with Roslyn, C# and Mono will support static imports like Java, allowing you to drop the "GLFW3." entirely. With everything being said, glfw-net is not meant to fit the code style of C#, as it is not meant to be a wrapper. It's designed to maximize copy-pasting between C++ and C# code to facilitate easier porting.

Current shortfalls?
Unfortunately at the moment, since the official GLFW3 website does not provide binaries for systems outside of Windows, I have only packaged binaries for x86 and x64 Windows compiled with VC2013 (so potentially will not support older Windows systems). In addition, I've only thoroughly tested the 64-bit version, and the 32-bit version is partially non-functional. Unless someone provides me fixes (via the GitHub repository in the form of a pull request) the 32-bit version will be fixed when I have the time (and the necessary flash of inspiration). Until then it will remain semi-broken since I do not officially support a 32-bit version.

So why have I posted this when it isn't fully functional and tested?
First off, I know some people around here like tinkering with things, and this is something that may pique their interest. Second of all, I can't test for example, the joystick related API calls, since I don't own or know where I can borrow a joystick. Third of all, at the moment I am unable to test OSX or Linux, so I'm hoping someone will compile some binaries for them as well as test API calls to make sure I don't have any stupid bugs that don't show up on Windows.

I haven't tested to see if anything will work right now with glfw-net, but somebody might be able to get glfw-net to work with OpenTK, which would provide a means to use OpenGL with GLFW3 from C#, without using something like Pencil.Gaming (which seems to have a less than desirable GLFW2/3 binding implementation and a bloated implementation). There are OpenGL bindings in C#, just none of them live up to the standard LWJGL3 has set, which from my experience with it and the underlying C/C++ APIs, is really good.

License: MIT (open source, free for commercial use and derivative works so long as the license is packaged with any distributions of the source code, read the license file for more detail)

.NET 4.5 -- if someone wants to see if glfw-net works on an earlier version of .NET and submit an issue to the repository for me to change the version, go ahead, but otherwise it's staying on 4.5
GLFW3 binary files for your system -- obviously if the provided GLFW3 binaries don't work for you (stored in the 'lib' directory tree) you'll need to compile your own (or download the binaries if you're running Windows but can't use the VC2013 binaries that I provided, but I find this unlikely if your version of Windows supports .NET 4.5).

Link to comment
Share on other sites

  • 1 month later...

glfw-net is now in beta development for glfw-net 3.2. This update is to bring it up to spec with GLFW 3.2 and is also marking x86 as obsolete, as unless someone else fixes the issues I was having with it (AccessViolationExceptions on cursors and gamma ramp) it will not be supported, and I have actively removed the x86 build configuration from the solution.

GitHub: glfw-net 3.2 update development branch

I will be testing/correcting the Vulkan API externs I added to the source starting sometime this week when I receive my GTX 1070, as my current GTX 560 Ti was not given Vulkan drivers by nVidia (rendering me incapable of testing it).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...