proj home

Files   Classes   Functions   Hierarchy  

gobjtest.cpp

Go to the documentation of this file.
00001 
00002 #include <cstdlib>
00003 using namespace std;
00004 
00005 #include <gobj.h>
00006 #include <gobjtest.h>
00007 #include <graphmisc.h>
00008 #include <zpr.h>
00009 
00010 string gobjtest::doc[] = 
00011 {
00012   "",
00013   "Display a circle rotated about an axis.",
00014   "",
00015   "Serialize inverse code to opengl example."
00016 };
00017 
00018 void gobjtest::test001(int argc, char** argv)
00019 {
00020   glutInit(&argc,argv);
00021   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
00022   glutInitWindowSize(800,600);
00023   glutCreateWindow("");
00024   glutDisplayFunc(gobjtest::display01);
00025   glutKeyboardFunc(gobjtest::keyboard01);
00026 
00027   OpenGLinitialisation();
00028 
00029   glEnable(GL_DEPTH_TEST);
00030   glEnable(GL_CULL_FACE);
00031   glEnable(GL_NORMALIZE);
00032 
00033   xGraphics.set();
00034 
00035   gobjQuadric * gd = new gobjQuadric();
00036   gd->radius=.02;
00037   gobjpush(gd);
00038 
00039   gobjpush(new gobjglColor3ub(255,0,0));
00040   point3<double> origin(0.0,0.0,0.0);
00041   gobjpush( new gobjMySphereDraw(origin,gd) );
00042 
00043   gobjMyCircle * gc = new gobjMyCircle();
00044   gobjpush(new gobjglColor3ub(127,255,212));
00045   double radius = 1.5;
00046   gobjpush(new gobjMyCircleDraw(radius,origin,*gc));
00047 
00048   gobjpush(new myaxes(1.0));
00049 
00050   gobjpush(new gobjglColor3ub(55,250,0));
00051   point3<double> axis(1.0,0.0,0.0);
00052   gobjpush(new gobjMyCircleDraw(radius,origin,axis,*gc));
00053   
00054   zpr zz;
00055   zz.update();
00056   glutMainLoop();
00057 }
00058 
00059 
00060 void gobjtest::test002(int argc, char** argv)
00061 {
00062   glutInit(&argc,argv);
00063   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
00064   glutInitWindowSize(800,600);
00065   glutCreateWindow("");
00066   glutDisplayFunc(gobjtest::display01);
00067   glutKeyboardFunc(gobjtest::keyboard01);
00068 
00069   OpenGLinitialisation();
00070 
00071   glEnable(GL_DEPTH_TEST);
00072   glEnable(GL_CULL_FACE);
00073   glEnable(GL_NORMALIZE);
00074 
00075   xGraphics.set();
00076 
00077   gobjQuadric * gd = new gobjQuadric();
00078   gd->radius=.02;
00079   gobjpush(gd);
00080 
00081   gobjpush(new gobjglColor3ub(255,0,0));
00082   point3<double> origin(0.0,0.0,0.0);
00083   gobjpush( new gobjMySphereDraw(origin,gd) );
00084 
00085   gobjMyCircle * gc = new gobjMyCircle();
00086   gobjpush(new gobjglColor3ub(127,255,212));
00087   double radius = 1.5;
00088   gobjpush(new gobjMyCircleDraw(radius,origin,*gc));
00089 
00090   gobjpush(new myaxes(1.0));
00091 
00092   gobjpush(new gobjglColor3ub(55,250,0));
00093   point3<double> axis(1.0,0.0,0.0);
00094   gobjpush(new gobjMyCircleDraw(radius,origin,axis,*gc));
00095   
00096   zpr zz;
00097   zz.update();
00098   glutMainLoop();
00099 }
00100 
00101 void gobjtest::test003(int argc, char** argv)
00102 {
00103   glutInit(&argc,argv);
00104   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
00105   glutInitWindowSize(800,600);
00106   glutCreateWindow("");
00107   glutDisplayFunc(gobjtest::display01);
00108   glutKeyboardFunc(gobjtest::keyboard01);
00109 
00110   OpenGLinitialisation();
00111 
00112   glEnable(GL_DEPTH_TEST);
00113   glEnable(GL_CULL_FACE);
00114   glEnable(GL_NORMALIZE);
00115 
00116   xGraphics.set();
00117 
00118 /*
00119 glPushAttrib GL_CURRENT_BIT 
00120 glPushAttrib GL_LIGHTING_BIT 
00121 glDisable GL_LIGHTING 
00122 glBegin GL_LINES 
00123 glColor3f 1.0 0.0 0.0 
00124 glVertex3f 0.0 0.0 0.0 
00125 glVertex3f 1.0 0.0 0.0 
00126 glColor3f 0.0 1.0 0.0 
00127 glVertex3f 0.0 0.0 0.0 
00128 glVertex3f 0.0 1.0 0.0 
00129 glColor3f 0.0 0.0 1.0 
00130 glVertex3f 0.0 0.0 0.0 
00131 glVertex3f 0.0 0.0 1.0 
00132 glEnd  
00133 glPopAttrib  
00134 glPopAttrib
00135 */
00136 
00137   gobjpush(new gobjglPushAttrib("GL_CURRENT_BIT"));
00138   gobjpush(new gobjglPushAttrib("GL_LIGHTING_BIT"));
00139   gobjpush(new gobjglDisable("GL_LIGHTING"));
00140   gobjpush(new gobjglBegin("GL_LINES"));
00141   gobjpush(new gobjglColor3f("1.0 0.0 0.0"));
00142   gobjpush(new gobjglVertex3f("0.0 0.0 0.0"));
00143   gobjpush(new gobjglVertex3f("1.0 0.0 0.0"));
00144   gobjpush(new gobjglColor3f("0.0 1.0 0.0"));
00145   gobjpush(new gobjglVertex3f("0.0 0.0 0.0"));
00146   gobjpush(new gobjglVertex3f("0.0 1.0 0.0"));
00147   gobjpush(new gobjglColor3f("0.0 0.0 1.0"));
00148   gobjpush(new gobjglVertex3f("0.0 0.0 0.0"));
00149   gobjpush(new gobjglVertex3f("0.0 0.0 1.0"));
00150   gobjpush(new gobjglEnd());
00151   gobjpush(new gobjglPopAttrib());
00152   gobjpush(new gobjglPopAttrib());
00153 
00154 
00155   glutPostRedisplay();
00156   
00157   zpr zz;
00158   zz.update();
00159   glutMainLoop();
00160 }
00161 
00162 
00163 
00164 
00165 
00166 
00167 void gobjtest::display01()
00168 {
00169   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
00170 
00171   gobj::global->draw();
00172 
00173   glerrordisplay();
00174   
00175   glutSwapBuffers();
00176 }
00177 
00178 void gobjtest::keyboard01(unsigned char key, int x, int y)
00179 {
00180   switch (key)
00181   {
00182     case 27:
00183       exit(0);
00184       break;
00185   }
00186 }
00187 

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