mirror of https://github.com/fltk/fltk
STR 1948: fix glutIdleFunc so that it does not use the deprecated Fl::set_idle method, and does not interact harmfully with other Fl::add/remove_idle() functions.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6525 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
ba2ed82028
commit
cbfba6feca
|
@ -238,7 +238,7 @@ enum {GLUT_LEFT, GLUT_ENTERED};
|
|||
inline void glutVisibilityFunc(void (*f)(int s)) {glut_window->visibility=f;}
|
||||
enum {GLUT_NOT_VISIBLE, GLUT_VISIBLE};
|
||||
|
||||
inline void glutIdleFunc(void (*f)()) {Fl::set_idle(f);}
|
||||
FL_EXPORT void glutIdleFunc(void (*f)());
|
||||
|
||||
// Warning: this cast may not work on all machines:
|
||||
inline void glutTimerFunc(unsigned int msec, void (*f)(int), int value) {
|
||||
|
|
|
@ -49,6 +49,8 @@
|
|||
# define MAXWINDOWS 32
|
||||
static Fl_Glut_Window *windows[MAXWINDOWS+1];
|
||||
|
||||
static void (*glut_idle_func)() = 0; // global glut idle function
|
||||
|
||||
Fl_Glut_Window *glut_window;
|
||||
int glut_menu;
|
||||
void (*glut_menustate_function)(int);
|
||||
|
@ -499,6 +501,20 @@ int glutExtensionSupported( const char* extension )
|
|||
}
|
||||
}
|
||||
|
||||
// Add a mechanism to handle adding/removing the glut idle function
|
||||
// without depending on the (deprecated) set_idle method.
|
||||
void glutIdleFunc(void (*f)())
|
||||
{
|
||||
// no change
|
||||
if(glut_idle_func == f) return;
|
||||
// remove current idle
|
||||
if(glut_idle_func) Fl::remove_idle((void (*)(void *))glut_idle_func);
|
||||
// install new idle func - if one was passed
|
||||
if(f) Fl::add_idle((void (*)(void *))f);
|
||||
// record new idle func - even if it is NULL
|
||||
glut_idle_func = f;
|
||||
} // glutIdleFunc
|
||||
|
||||
#endif // HAVE_GL
|
||||
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue