GLFW 3 GetCursorPos() only zero

Started by
1 comment, last by Imprecision 10 years, 9 months ago

Hey, I'm using GLFW on C# with Pencil.Gaming

My problem is that GetCursorPos only returns 0 (i and j).

My code:


        static void Main(string[] args)
        {
            if (!Glfw.Init()) {
                Console.WriteLine("ERROR");
                return;
            }

            GlfwMonitorPtr monitor = Glfw.GetPrimaryMonitor();

            GlfwWindowPtr window = Glfw.CreateWindow(1280, 720, "SharpFloat", GlfwMonitorPtr.Null, GlfwWindowPtr.Null);
            Glfw.MakeContextCurrent(window);

            int i;
            int j;
            

            while (!Glfw.WindowShouldClose(window)) {
                GL.Clear(ClearBufferMask.ColorBufferBit);

                Glfw.GetCursorPos(window, out i, out j);
                Console.WriteLine(i + " " + j);

                Glfw.SwapBuffers(window);
                Glfw.PollEvents();
            }

            Glfw.Terminate();
        }

Do I read it wrong? Or do I have to do something before I can read it?

Advertisement

If you're using the release version of GLFW 3, it's most likely a problem with the Pencil.Gaming binding. The GLFW API changed a couple of weeks before release such that several functions which previously were declared to take int or int* parameters were changed to double and double* respectively, glfwGetCursorPos included. However, this binding is still using ints. This is likely to result in unexpected behavior. I don't know much about C# and how 'out' parameters relate to pointers on the C side, but that would be the first place I would look for a solution. The glfwSet* functions will particularly cause problems, given they work with values and not pointers.

I already suspected this when I saw the doc example using doubles and I am using int. Yes the "out" Parameters are call-by-reference in C#.

Thanks for your help happy.png I will open a issue on Pencil.Gaming

This topic is closed to new replies.

Advertisement