Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Posting in this forum

Using GLFW
Malkierian
2012-07-24
2012-11-08
  • Malkierian
    Malkierian
    2012-07-24

    Is ridiculously hard, and I'm hoping that this can get through.

    I tried posting this to the forum earlier, but had to post it in the bug
    tracker instead because of the stupid spam filter on here. However, I think I
    would have a better chance of getting an answer if I had it on the forum, so
    if you would please go here:

    http://sourceforge.net/tracker/?func=detail&aid=3547428&group_id=72569&atid=
    534938

    And then post a reply in this topic, I would greatly appreciate the help (if
    you have it).

     
  • Camilla Löwy
    Camilla Löwy
    2012-07-24

    The problem is very likely in your code. You should use your debugger to
    investigate.

     
  • Camilla Löwy
    Camilla Löwy
    2012-07-24

    I'm sorry about the spam filter. SourceForge has been hit with an avalanche of
    spam in the past couple of years. I guess they got tired of it.

     
  • Malkierian
    Malkierian
    2012-07-24

    How am I supposed to use the debugger when the only thing it does is produce
    that access violation at your function? And that's the only one that doesn't
    work, as far as I can tell, except that GetMousePos doesn't actually seem to
    get the mouse position… Even if I move the callback functions to just after
    the glfwInit and OpenWindow, it still only gives that stupid access violation,
    and there's no stack trace.

     
  • Camilla Löwy
    Camilla Löwy
    2012-07-24

    It sounds like your program is corrupting memory. There are a number of tools
    available that can help you find where this is happening.

     
  • Malkierian
    Malkierian
    2012-07-24

    My program isn't DOING anything except glfw initialization and opening a
    window. And then registering those callbacks. If I'm not doing the functions
    right, then please let me know. Anything other than a static declaration
    doesn't let me compile even. It's corrupting memory when trying to REGISTER
    that callback function.

     
  • Camilla Löwy
    Camilla Löwy
    2012-07-24

    Do the GLFW tests and examples run?

     
  • Camilla Löwy
    Camilla Löwy
    2012-07-24

    Also, did you build GLFW yourself, and if so, did you use the GLFW build files
    or did you write your own?

     
  • Camilla Löwy
    Camilla Löwy
    2012-07-24

    If you need to cast a callback function pointer then the function's signature
    is incorrect and all bets are off.

     
  • Malkierian
    Malkierian
    2012-07-24

    When I used GLFW3, I built it, but I didn't try any of the tests or examples.
    I will download 2.7.6 source and try them, but I will emphasize (if not
    again) that I am using strict C++, and so, since the examples are all C, they
    are pretty much useless to me.

    I suppose I could try converting my code over to C to see if it has any
    problems, but that would be tedious, and I would guess it would work just fine
    since you test it with C programs.

     
  • Camilla Löwy
    Camilla Löwy
    2012-07-24

    It makes no difference to GLFW whether the program using it is in C or C++.

     
  • Malkierian
    Malkierian
    2012-07-24

    But the implementation WITHIN the program is different, as witnessed by the
    fact that "static" is not needed when writing a C program.

     
  • Malkierian
    Malkierian
    2012-07-24

    I also wanted to let you know that I went back and fixed my
    SetWindowCloseCallback function so that it didn't need the cast. The whole
    program still compiles just fine (GLFW recognizes the MousePosCallback
    function I have), but on running, it still has the access violation on
    glfwSetMousePosCallback.

     
  • Camilla Löwy
    Camilla Löwy
    2012-07-24

    I don't know what more I can say. I've given my best guesses as to what's
    wrong, suggested tools that may help you and asked questions that could have
    helped you towards a solution.

    I am, however, fairly certain that glfwSetMousePosCallback didn't cause an
    access violation on its own, based partly on it only using global data and
    partly on the thousands of people who use it every day without this issue.
    You're welcome to read the few lines involved and verify this for yourself.

     
  • kabuuu
    kabuuu
    2012-08-24

    Hi,

    i have the same problem:

    int main(){
       GLFWvidmode mode;   // GLFW video mode
        // Intialize GLFW
        if( !glfwInit() )
        {
            // An error occured
            fprintf(stderr, "GLFW initialization failed\n");
            return 1;
        }
        // Create a window
        glfwGetDesktopMode(&mode);
        if( !glfwOpenWindow(mode.Width/2, mode.Height/2, mode.RedBits, mode.GreenBits, mode.BlueBits,
                            0, 16, 0, GLFW_WINDOW /* or GLFW_FULLSCREEN*/ ) )
        {
            // A fatal error occured
            fprintf(stderr, "Cannot open GLFW window\n");
            glfwTerminate();
            return 1;
        }
        glfwEnable(GLFW_MOUSE_CURSOR);
        // Initialize AntTweakBar
        TwInit(TW_OPENGL, NULL);
        // - Directly redirect GLFW mouse button events to AntTweakBar
        glfwSetMouseButtonCallback((GLFWmousebuttonfun)TwEventMouseButtonGLFW);
        // - Directly redirect GLFW key events to AntTweakBar
        glfwSetKeyCallback((GLFWkeyfun)TwEventKeyGLFW);
        // - Directly redirect GLFW char events to AntTweakBar
        glfwSetCharCallback((GLFWcharfun)TwEventCharGLFW);
        // - Directly redirect GLFW mouse wheel events to AntTweakBar
        //glfwSetMouseWheelCallback((GLFWmousewheelfun)TwEventMouseWheelGLFW); // crashes
        // - Directly redirect GLFW mouse position events to AntTweakBar
        glfwSetMousePosCallback((GLFWmouseposfun)TwEventMousePosGLFW); // crashes
        return 0;
    }
    

    I used GLFW 2.7.1 (the binaries for Visual C++ 2010), AntTweakBar 1.15 and
    Visual Studio 2012,
    and followed the instructions from
    http://www.antisphere.com/Wiki/tools:anttweakbar:howto?s=mouse

    Key, Char and MouseButton Callbacks work just fine, just the MouseWheel and
    MousePos Callbacks (see above) just result in an access violation….

     
  • Camilla Löwy
    Camilla Löwy
    2012-08-26

    Are you using GLFW as a DLL or static library?

     
  • kabuuu
    kabuuu
    2012-08-27

    I guess the problem was that i used the dll? Now that i have linked the static
    library (glfw.dll) it works :)

     
  • kabuuu
    kabuuu
    2012-08-27

    eehm… sry, wrong pc. it does still not work. And I'm using the static library…

     
  • Camilla Löwy
    Camilla Löwy
    2012-08-27

    Did you define GLFW_CDECL before including the AntTweakBar header?

     
  • kabuuu
    kabuuu
    2012-08-27

    nope, that #define GLFW_CDECL was missing. Thx :)