extern lpScaleFunc scale;
extern lpCurveFunc curve;
extern lpCheckboxFunc checkbox;
extern lpMenuFunc menu;
extern lpGetTimeFunc get_time;
extern double get_control_d(int ctrl_id);
extern float get_control_f(int ctrl_id);
extern int get_control_i(int ctrl_id);
extern bool get_control_b(int ctrl_id);
The timer function is running through a 20 second loop. Depending on the rate selected, it increments the value every .2, .1, .05, etc and then it wraps at 20 seconds. Your redraw function is called every time the timer is updated while animating.
Although you can't easily change the values it generates, you could use it to drive a timer value of your own. You could increment your own static timer by whatever the get_time increment was and turn it off, reset it, or whatever you want depending on your own code and checkboxes or sliders in the UI.
You can't check directly on whether or not the user has selected animation mode. Redraw just gets called on a regular basis when you are animating.
One option is to just run continuously in animation mode, and have a checkbox or menu item in your UI to enable various sub-modes. For example, a menu could have the following choices: "use sliders for control", "enable timed animation mode 1", "enable timed animation mode 2". Your code then checks the menu and does the appropriate things.
This sort of initialization does not happen in "init". Init is for setting up the User Interface widgets only. The OpenGL window and context do not exist when init is called and so you cannot do the setup there.
An easy solution is to put your initialization code into redraw in an "if" block that is controlled by a static variable. For example:
===============
void redraw(int drawmode) {
...
static bool initialized = false; // set to true the first time redraw is called
...
if (!initialized) {
initialized = true;
printf("Vendor version %s %s\n",glGetString(GL_VENDOR),glGetString(GL_VERSION));
...
}
...
}
===============
This initialization is only for things that happen once when you load the model originally. Actions that should happen every time you redraw should not be part of the if block.
GLenum error_flag;
error_flag = glGetError();
if (error_flag != GL_NO_ERROR) {
printf("Error: %1s (%i) in %1s.\n",gluErrorString(error_flag),error_flag,"redraw");
}
See glClipPlane in the OGL references. Specify a clip plane, enable it, draw the sphere, disable the clip plane.