#8 GLUI_Control ptr in callbacks

open
nobody
None
5
2012-07-18
2004-02-03
Billy B
No

For callbacks, GLUI should pass a pointer to the
control that triggered the callback. Currently the
callbacks just give you an int, but that means if you
want to take action that depends on the data in a
control, then you need to have BOTH a callback function
AND a variable somewhere in your code that's accessible
to the function. If GLUI would pass a pointer to the
GLUI_Control in the callback, I wouldn't have to hold
onto that GLUI_EditText myself.

My code is littered with static variables that are
there for the sole purpose of letting me know what the
current string value is in a text field when I get the
callback. There's no reason for GLUI not to pass just
that pointer to me.

And while we're at it, it would be better if the int id
value passed was a void instead so that you could have
the callback pass you any old user data you want.
Yes i know I could cast pointers to ints, but I don't
think C++ guarantees that sizeof(int)==sizeof(void
).

So in summary, I think the glui callback protoptype
should be
typedef void (GLUI_Update_CB) (void data,
GLUI_Controlcontrol);
instead of
typedef void (
GLUI_Update_CB) (int id);

Discussion


Anonymous


Cancel   Add attachments