derelict glfw won't set callbacks

Rene Zwanenburg via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat May 24 06:52:30 PDT 2014


On Saturday, 24 May 2014 at 13:31:46 UTC, Vlad Levenfeld wrote:
> 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?

glfwSetErrorCallback returns the previous callback, so it makes 
sense null is returned on the first call.


More information about the Digitalmars-d-learn mailing list