Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo
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:
And then post a reply in this topic, I would greatly appreciate the help (if
you have it).
The problem is very likely in your code. You should use your debugger to
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.
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.
It sounds like your program is corrupting memory. There are a number of tools
available that can help you find where this is happening.
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.
Do the GLFW tests and examples run?
Also, did you build GLFW yourself, and if so, did you use the GLFW build files
or did you write your own?
If you need to cast a callback function pointer then the function's signature
is incorrect and all bets are off.
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.
It makes no difference to GLFW whether the program using it is in C or C++.
But the implementation WITHIN the program is different, as witnessed by the
fact that "static" is not needed when writing a C program.
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
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.
i have the same problem:
GLFWvidmode mode; // GLFW video mode
// Intialize GLFW
if( !glfwInit() )
// An error occured
fprintf(stderr, "GLFW initialization failed\n");
// Create a window
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");
// Initialize AntTweakBar
// - Directly redirect GLFW mouse button events to AntTweakBar
// - Directly redirect GLFW key events to AntTweakBar
// - Directly redirect GLFW char events to AntTweakBar
// - Directly redirect GLFW mouse wheel events to AntTweakBar
//glfwSetMouseWheelCallback((GLFWmousewheelfun)TwEventMouseWheelGLFW); // crashes
// - Directly redirect GLFW mouse position events to AntTweakBar
glfwSetMousePosCallback((GLFWmouseposfun)TwEventMousePosGLFW); // crashes
I used GLFW 2.7.1 (the binaries for Visual C++ 2010), AntTweakBar 1.15 and
Visual Studio 2012,
and followed the instructions from
Key, Char and MouseButton Callbacks work just fine, just the MouseWheel and
MousePos Callbacks (see above) just result in an access violation….
Are you using GLFW as a DLL or static library?
I guess the problem was that i used the dll? Now that i have linked the static
library (glfw.dll) it works :)
eehm… sry, wrong pc. it does still not work. And I'm using the static library…
Did you define GLFW_CDECL before including the AntTweakBar header?
nope, that #define GLFW_CDECL was missing. Thx :)