Menu

#11 GLFW3 support

1.x
open
nobody
None
2015-10-09
2013-10-22
fenbf
No

AntTewakBar has support for old version of GLFW. GLFW3 version 3 brought several breaking changes so small upgrade to AntTweakBar is needed.

http://www.glfw.org/docs/3.0/moving.html

The main problems is with mouse/keyboard input.

Discussion

  • eigenaar

    eigenaar - 2013-10-29

    I haven't tested this thoroughly, but to patch the mouse/keyboard issues, you can replace

    glfwSetMouseButtonCallback((GLFWmousebuttonfun)TwEventMouseButtonGLFW);
    glfwSetMousePosCallback((GLFWmouseposfun)TwEventMousePosGLFW);
    glfwSetMouseWheelCallback((GLFWmousewheelfun)TwEventMouseWheelGLFW);
    glfwSetKeyCallback((GLFWkeyfun)TwEventKeyGLFW);
    glfwSetCharCallback((GLFWcharfun)TwEventCharGLFW);

    by

    glfwSetMouseButtonCallback(mainWindow, (GLFWmousebuttonfun)TwEventMouseButtonGLFW3);
    glfwSetCursorPosCallback(mainWindow, (GLFWcursorposfun)TwEventMousePosGLFW3);
    glfwSetScrollCallback(mainWindow, (GLFWscrollfun)TwEventMouseWheelGLFW3);
    glfwSetKeyCallback(mainWindow, (GLFWkeyfun)TwEventKeyGLFW3);
    glfwSetCharCallback(mainWindow, (GLFWcharfun)TwEventCharGLFW3);

    where "mainWindow" is the GLFWwindow* handle of the current window. Use the following declarations in a header somewhere :

    inline void TwEventMouseButtonGLFW3(GLFWwindow* window, int button, int action, int mods){TwEventMouseButtonGLFW(button, action);}

    inline void TwEventMousePosGLFW3(GLFWwindow* window, double xpos, double ypos){TwMouseMotion(int(xpos), int(ypos));}

    inline void TwEventMouseWheelGLFW3(GLFWwindow* window, double xoffset, double yoffset){TwEventMouseWheelGLFW(yoffset);}

    inline void TwEventKeyGLFW3(GLFWwindow* window, int key, int scancode, int action, int mods){TwEventKeyGLFW(key, action);}

    inline void TwEventCharGLFW3(GLFWwindow* window, int codepoint){TwEventCharGLFW(codepoint, GLFW_PRESS);}

     
    • Andrej Mitrovic

      Andrej Mitrovic - 2014-03-09

      That's close but not enough, GLFW2 and GLFW3 have different values for the keys, e.g. GLFW2 has GLFW_KEY_LCTRL which equals 289, but GLFW3 has GLFW_KEY_LEFT_CONTROL which equals 341. So you'd likely have to use a large switch statement to convert the key maps from GLFW2 to GLFW3.

      But ideally AntTweakBar would implement GLFW3 callbacks instead.

       
  • Joachim Fenkes

    Joachim Fenkes - 2015-03-29

    I went ahead and implemented the necessary callbacks, including what I think were the necessary changes to all build files. Tested on Release/win32 only. git-style patch attached.

    Hope it helps and will make it into the next ATB release ;)

     

    Last edit: Joachim Fenkes 2015-03-29
  • Rupesh Mandke

    Rupesh Mandke - 2015-09-27

    Hi Joachim,

    Would it be possible to share the changed files rather than git patch? Would be helpful too.

    Thanks.

     
    • Joachim Fenkes

      Joachim Fenkes - 2015-09-28

      There are a couple clones of ATB already on GitHub. I forked one of them and added my GLFW3 changes, so here you go: https://github.com/dop3j0e/anttweakbar
      I can't give you any build support, but if you make any changes, feel free to send a pull request to the guy I forked from: https://github.com/kypp/anttweakbar - I will ask him to pull my changes as well (and probably delete my repo once he merged, so if my repo disappears, check kypp's).

       

      Last edit: Joachim Fenkes 2015-09-28
      • Rupesh Mandke

        Rupesh Mandke - 2015-09-30

        Hi Johachim,

        Thanks a million for this updated source repo. I will give it shot tonight.

        Regards,
        Rupesh.

         
        • Rupesh Mandke

          Rupesh Mandke - 2015-09-30

          Hi Johachim,

          I confirm that it works! I tried 64bit version. Thanks for this wonderful addition. I just hope it gets added to official branch asap.

          Regards,
          Rupesh.

           

          Last edit: Rupesh Mandke 2015-09-30
  • Anshul Soni

    Anshul Soni - 2015-10-09

    Doesnt work, after doing everything, if I create the callbacks it crashes.