Files Classes Functions Hierarchy
00001 #include <cassert> 00002 #include <iostream> 00003 00004 #include <GL/glut.h> 00005 #include <GL/gl.h> 00006 00007 #include <cstdlib> 00008 using namespace std; 00009 00010 //#include <zpr.h> 00011 00012 00013 #include <graphmisc.h> 00014 #include <myglutgui.h> 00015 00016 myglutgui* myglutgui::global=0; 00017 00018 00019 void myglutguikeyboard(unsigned char key, int x, int y) 00020 { 00021 myglutgui* g = myglutgui::global; 00022 if (g==0) 00023 { 00024 cout << "error: myglutgui::global==0" << endl; 00025 cout << " Call globalSet(); in derived constructor" << endl << endl; 00026 return; 00027 } 00028 00029 g->keyboard(key,x,y); 00030 } 00031 00032 void myglutguidisplay() 00033 { 00034 myglutgui* g = myglutgui::global; 00035 if (g==0) 00036 { 00037 cout << "error: myglutgui::global==0" << endl; 00038 cout << " Call globalSet(); in derived constructor" << endl << endl; 00039 return; 00040 } 00041 00042 g->display(); 00043 } 00044 00045 00046 void myglutgui::globalSet() 00047 { 00048 myglutgui::global = this; 00049 } 00050 00051 00052 void myglutgui::keyboard(unsigned char key, int x, int y) 00053 { 00054 #ifndef NDEBUG 00055 cout << "Warning - default keyboard handling behaviour." << endl; 00056 cout << "myglutgui::keyboard(unsigned char key, int x, int y)" << endl; 00057 cout << " This is the default behaviour. If you want keys handeled" << endl; 00058 cout << " over ride the virtual keyboard function eg " << endl; 00059 cout << " void keyboard(unsigned char key, int x, int y)" << endl; 00060 cout << " { menu.read(key); }" << endl; 00061 #endif 00062 switch (key) 00063 { 00064 case 27: 00065 exit(0); 00066 break; 00067 } 00068 } 00069 00070 myglutgui::myglutgui 00071 ( 00072 int & argc, 00073 char** & argv, 00074 uintc mode, 00075 uintc x, 00076 uintc y, 00077 string const & title 00078 ) 00079 { 00080 glutInit(&argc,argv); 00081 00082 glutInitDisplayMode(mode); 00083 glutInitWindowSize(x,y); 00084 glutCreateWindow(title.c_str()); 00085 00086 glutDisplayFunc(myglutguidisplay); 00087 glutKeyboardFunc(myglutguikeyboard); 00088 } 00089 00090 myglutgui::~myglutgui() 00091 { 00092 } 00093 00094 00095
1.5.8