Skip to content

std::function for GLUI callbacks#82

Open
nigels-com wants to merge 1 commit intolibglui:masterfrom
nigels-com:std_function
Open

std::function for GLUI callbacks#82
nigels-com wants to merge 1 commit intolibglui:masterfrom
nigels-com:std_function

Conversation

@nigels-com
Copy link
Collaborator

This change replaces GLUI_CB and the associated IDs and pointers with simply std::function<void(void)>. This allows for using C++ lambdas for GLUI callbacks, including std::bind.

For example:

new GLUI_Button( glui, "Quit", []() { printf("Exit\n"); exit(0); } );

Copy link

@djwebb djwebb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a c++ idiot like me, could you explain how the callbacks work here - for example at lines 243 and 244 of the original code how does "& {printf etc." link to the callback routine.
Also won't these changes require a reqrite of the manual?
David.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments