derelict glfw won't set callbacks

Vlad Levenfeld via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat May 24 06:31:44 PDT 2014


Any attempt to set callbacks in GLFW returns a null and the 
callback doesn't work.

The first enforcement fails in this example:

DerelictGLFW3.load ();
enforce (glfwSetErrorCallback (&error_callback));
enforce (glfwInit (), "glfwInit failed");
window = glfwCreateWindow (screen_dims.x, screen_dims.y, "sup", 
null, null);
glfwMakeContextCurrent (window);
glfwSwapInterval (0);

If I forget about the callbacks, everything functions normally (I 
can render, etc).
Here is error_callback:

static extern (C) void error_callback (int, const (char)* error) 
nothrow {
	import std.c.stdio: fprintf, stderr;
	fprintf (stderr, "error glfw: %s\n", error);
}

It is a static member function but pulling it out to the module 
scope changes nothing.
It doesn't work when I do it from the main thread or a secondary 
thread.

The load-set_error_callback-glfwInit sequence is recommended 
everywhere I look up D's GLFW bindings, so apparently this works 
for other people and I must be missing something.

And in the event that this can't be solved, I suppose the thing 
to do is to either poll for input events manually or try to get 
that part working in C then call it from D?


More information about the Digitalmars-d-learn mailing list