proj home

Files   Classes   Functions   Hierarchy  

menusystemtest01.cpp

Go to the documentation of this file.
00001 #include <cstdlib>
00002 using namespace std;
00003 
00004 #include <graphmisc.h>
00005 #include <menusystemtest01.h>
00006 #include <zpr.h>
00007 
00008 string menusystemtest01::doc[] =
00009 { 
00010   "",
00011   "Display a 1 layer menu (no nesting) and use standard key capture."
00012 };
00013 
00014 bool * menusystemtest01::help = 0;
00015 menusystem * menusystemtest01::messages = 0;
00016 
00017 menusystemtest01::menusystemtest01(int argc, char** argv)
00018 {
00019   glutInit(&argc,argv);
00020   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
00021   glutInitWindowSize(800,600);
00022   glutCreateWindow("");
00023   glutDisplayFunc(display);
00024   glutKeyboardFunc(keyboard);
00025 
00026   OpenGLinitialisation();
00027 
00028   glEnable(GL_DEPTH_TEST);
00029   glEnable(GL_CULL_FACE);
00030   glEnable(GL_NORMALIZE);
00031 
00032   xGraphics.set();
00033 
00034 
00035   gobjpush(new gobjglDisable(GL_LIGHTING));
00036   menusystem * menu = 
00037     new menusystem(point2<GLint>(60,30),10);
00038   menu->fontcolor = point4<float>(218.0/255.0,165.0/255.0,32.0/255.0,0.75);
00039 
00040   menu->addfont12("menusystem Example 01",1);
00041   menu->addfont10(doc[1],2);
00042   
00043   menu->addfont10("[1] Print a message",1);
00044   menu->addfont10("[2] Print doc on menu composition",1);
00045   menu->addfont10("[3] Print doc on menusystem class",1);
00046   menu->addfont10("[h] Toggle the menu",1);
00047   menu->addfont10("[c] Clear",2);
00048 
00049   menu->addfont10("[q] Quit",1);
00050 
00051   menu->lightingdisable();
00052   menu->fontcolorenable();
00053 
00054 
00055   gobjSwitch<> * menuswitch = new gobjSwitch<>(menu,true);
00056   help = & menuswitch->isdrawn;
00057   gobjpush(menuswitch);
00058 
00059   // The messages menu
00060   messages = 
00061     new menusystem(point2<GLint>(60,250),10);
00062   gobjpush(messages);
00063   messages->fontcolor = point4<float>(1.0,0.0,0.0,0.8);
00064   messages->lightingdisable();
00065   
00066   zpr zz;
00067   glutMainLoop();
00068 }
00069 
00070 void menusystemtest01::keyboard(unsigned char key, int x, int y)
00071 {
00072   switch (key)
00073   {
00074     case 'q': exit(0); break;
00075     case 'h': if (help!=0) *help = !*help; break;
00076     case 'c': messages->clear(); break;
00077     case '1': messages->addfont10("a message",1); break;
00078     case '2': messages->addfont10paragraph("There are two menus, the main menu and this message menu. By wrapping the main menu in a switch it can be toggled.",50,1); break; 
00079     case '3': messages->addfont10paragraph("In this exampel the menu system class is only used for display, and the standard keyboard overload is applied.",50,1); break;
00080   }
00081 
00082   glutPostRedisplay();
00083 }
00084 
00085 
00086 void menusystemtest01::display()
00087 {
00088   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
00089 
00090   gobj::global->draw();
00091 
00092 
00093   glerrordisplay();
00094   
00095   glutSwapBuffers();
00096 }
00097 
00098 
00099 
00100 
00101 

Generated on Fri Mar 4 00:49:29 2011 for Chelton Evans Source by  doxygen 1.5.8