Hey, is there plan for a user pointer that would be passed in to the sapp callback functions? The only other option is to use a global, which I'd rather not do.
Hmm, yeah, probably makes sense. I'll think about it, not sure yet whether to break compatibility, or add a second set of callbacks with a userdata param.
...I think I will add a separate set of callback functions, so the sapp_desc would get new callback pointers with a different function signature (in addition to an void* user_data):
void (*init_userdata_cb)(void*);
void (*frame_userdata_cb)(void*);
void (*cleanup_userdata_cb)(void*);
void (*event_userdata_cb)(const sapp_event*, void*);
void (*fail_userdata_cb)(const char*, void*);
For each callback type, the user code can than either use the version with, or without user_data.
Ah that's clever! I can try implementing it if you're swamped.
Don't worry, I'm currently on sokol_app.h anyway, and it's just a small feature. Will happen in the next couple of days :)
FYI the user_data stuff is tracked in this PR: https://github.com/floooh/sokol/pull/120
Just a bit more testing and then its ready.
May I suggest a similar addition to the stream callback function in sokol_audio?
May I suggest a similar addition to the stream callback function in sokol_audio?
yep, good idea, totally forgot about that
Ok, this is fixed in 77c2b42e2ee26c86541dbf40acf6b99d0529d20d, both sokol_app.h and sokol_audio.h now have an alternative set of callbacks with userdata.
I have changed the noentry-sapp.c and modplay-sapp.c samples as test and demo.
Thanks!
Most helpful comment
Don't worry, I'm currently on sokol_app.h anyway, and it's just a small feature. Will happen in the next couple of days :)