Code Monkey home page Code Monkey logo

glfw.net's Introduction

Glfw.Net

Introduction

GLFW is a free, Open Source, multi-platform library for OpenGL, OpenGL ES and Vulkan application development. It provides a simple, platform-independent API for creating windows, contexts and surfaces, reading input, handling events, etc.

Glfw.Net is a set of C# bindings for GLFW. It's fully-documented and comes with all the original functions except for Vulkan-related features. Some functions and delegates have been slightly changed to take advantage of C# features and make it easier to use.

Using Glfw.Net

You'll find most of the original tests in Glfw.Tests, they're considered a good starting place. Below is a port of the example code from the GLFW documentation.

using Glfw3;
using OpenGL;
using System;

class Example
{
    static void Main(string[] args)
    {
        // If the library isn't in the environment path we need to set it
        Glfw.ConfigureNativesDirectory("../../External/");

        // Initialize the library
        if (!Glfw.Init())
            Environment.Exit(-1);

        // Create a windowed mode window and its OpenGL context
        var window = Glfw.CreateWindow(640, 480, "Hello World");
        if (!window)
        {
            Glfw.Terminate();
            Environment.Exit(-1);
        }

        // Make the window's context current
        Glfw.MakeContextCurrent(window);

        // Loop until the user closes the window
        while (!Glfw.WindowShouldClose(window))
        {
            // Render here
            Gl.Clear(ClearBufferMask.ColorBufferBit);

            // Swap front and back buffers
            Glfw.SwapBuffers(window);

            // Poll for and process events
            Glfw.PollEvents();
        }

        Glfw.Terminate();
    }
}

Requirements

Glfw.Net doesn't have any library dependency but I recommend you use the excellent OpenGL.Net bindings. As for platform dependencies, Glfw.Net makes use of C# 6.0 features and has been tested with .Net Framework 4.5.2.

To build tests you'll need OpenGL.Net and CommandLineParser (both can be installed via NuGet).

Acknowledgements

This binding is heavily inspired by the work of others, mainly Chevy Ray Johnston and Robbie Lodico.

License

Like the original library, this work is released under the zlib/libpng license.

glfw.net's People

Contributors

jpalcala avatar chman avatar

Watchers

James Cloos avatar

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.