Giter Club home page Giter Club logo

dotglfw's Introduction

☕ DotGLFW Nuget

❗ A fully managed .NET wrapper for GLFW with provided binaries to allow for seamless integration in your projects!

❗ Also includes a completely native 1:1 mapping of the GLFW API, if you prefer an unmanaged approach for your project!

Currently targets .NET 6 and .NET 7. Uses the latest version of GLFW (3.3.8).

dotglfw's People

Contributors

dcronqvist avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

dotglfw's Issues

A call to Glfw.GetGamepadState() crashes the program.

good morning, when i call the Glfw.GetGamepadState() function it crashes the program. this is the error message in the console:

Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at DotGLFW.Glfw.GetGamepadState(Joystick joystick, GamepadState& state)

i called this function with a joystick plugged in and without a joystick plugged in, in both cases it crashed.
i checked the source code of Glfw.GetGamepadState() function but couldn't figure out why null reference exception was being thrown. i created a minimal program to demonstrate the issue. this is the link to the repo: https://github.com/apilatosba/DotGLFW.Glfw.GetGamepadState-

Program.cs
using DotGLFW;
using System;

using static DotGL.GL;

namespace Main {
   class Program {
      static void Main() {
         if (!Glfw.Init()) {
            Console.Error.WriteLine("Failed to initialize GLFW");
            Environment.Exit(1);
         }

         Glfw.SetErrorCallback((errorCode, description) => {
            Console.Error.WriteLine($"GLFW Error: {errorCode} - {description}");
         });

         Glfw.WindowHint(Hint.ContextVersionMajor, GetProjectOpenGLVersionMajor());
         Glfw.WindowHint(Hint.ContextVersionMinor, GetProjectOpenGLVersionMinor());
         Glfw.WindowHint(Hint.OpenGLProfile, OpenGLProfile.CoreProfile);
         Glfw.WindowHint(Hint.Samples, 4);

         Window window = Glfw.CreateWindow(640, 480, "FeelsDankMan", Monitor.NULL, Window.NULL);

         if (window == null) {
            Console.Error.WriteLine("Failed to create GLFW window");
            Glfw.Terminate();
            Environment.Exit(1);
         }

         Glfw.MakeContextCurrent(window);
         Import(Glfw.GetProcAddress);

         // This line crashes the program
         Glfw.GetGamepadState(Joystick.Joystick1, out GamepadState state);

         while (!Glfw.WindowShouldClose(window)) {
            Glfw.PollEvents();
            glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
            glClear(GL_COLOR_BUFFER_BIT);

            Glfw.SwapBuffers(window);
         }
      }
   }
}

idk if i am missing something very obvious but i would appreciate any feedback from you.
In case it matters, i am on debian12 with x11 windowing system.

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.