#include #include "vgl.h" #include "Spiral.h" using namespace std; extern Spiral mySpiral_G; extern bool DisplayHex_G; void SpecialKeypress(int key, int x, int y) { return; } void KeyUp(unsigned char key, int x, int y) { return; } void SpecialUp(int key, int x, int y) { return; } void KeyHelp() { cout << endl; cout << "Keys " << endl; cout << "\tq,Q\tQuit" << endl; cout << "\ta\tStart Animation" << endl; cout << "\tA\tStop Animation" << endl; cout << "\th,?\tHelp" << endl; cout << "\tr,R\tRedisplay" << endl; cout << "\ts\tToggle Spiral display " << endl; cout << "\tt\tToggle Hex display " << endl; cout << endl; return; } void Animate() { mySpiral_G.NextTheta(); glutPostRedisplay(); return; } void StartAnimation() { glutIdleFunc(Animate); return; } void StopAnimation() { glutIdleFunc(NULL); return; } void Keypress(unsigned char key, int x, int y) { static int state = 1; bool redisplay = false; switch (key) { case 'a': StartAnimation(); break; case 'A': StopAnimation(); break; case 's': mySpiral_G.ToggleDisplay(); redisplay = true; break; case 't': DisplayHex_G = !DisplayHex_G; redisplay = true; break; case 'h': case '?': KeyHelp(); break; case 'Q': case 'q': exit(0); case 'r': case 'R': redisplay = true; break; default: cerr << "Unhandled keypress for key '" << key << "'" << endl; } if (redisplay) { glutPostRedisplay(); } return; }