Giter Club home page Giter Club logo

dotglfw's Introduction

☕ DotGLFW Nuget Targets Nuget

A 1:1 mapping of the native GLFW API for .NET, with a lightweight managed wrapper for easy integration in your projects! Includes XML docs for all functions and types from the official GLFW documentation. Supports NativeAot, see this example. Ships with pre-compiled binaries for Windows and MacOS.

The library is split into two parts: the unmanaged API and the managed API.

The unmanaged API is automatically generated using DotGLFW.Generator. It parses the official GLFW documentation and generates C# code that matches the native API. Functions and types that would otherwise require runtime marshalling are automatically generated with compile-time marshalling to make the library as fast as possible, and to support native AOT compilation.

The managed API is a (mostly) hand-written wrapper around the unmanaged API to make it easier for you to use in your projects. It handles memory management and marshalling of strings, arrays, and other complex types for you. It also provides a more user-friendly interface for many functions using enums and other types instead of raw integers.

Unmanaged API

The unmanaged API is the static NativeGlfw class, which has exact mappings for all GLFW macros (e.g. GLFW_TRUE) and functions (e.g. glfwInit). Typedefs are also mapped to their equivalents in C#, opaque handles are empty structs, and function pointers are represented as delegates.

Important

The unmanaged API will require you to perform your own marshalling of strings, arrays, and other complex types. Additionally, you will need to manage memory yourself, including keeping references to callbacks alive. If you don't want to have to do this, use the managed API instead.

Managed API

The managed API is the static Glfw class, which wraps the unmanaged API in a more user-friendly and .NET-y way. It provides compile-time marshalling of strings, arrays, and other complex types, handles memory management for you (including keeping references to callbacks alive) and much more. Many functions (e.g. glfwWindowHint) have been overloaded to accept more user-friendly enums and types instead of raw integers.

Take a look in the provided example to see how to use the library with the managed API. It demonstrates how to create a window and set up a very simple rendering loop.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.