proj home

Files   Classes   Functions   Hierarchy  

main.cpp

Go to the documentation of this file.
00001 #include <iostream>
00002 
00003 #include <GL/glut.h>
00004 
00005 GLfloat mainspin=0.0;
00006 
00007 void mainInit()
00008 {
00009   glClearColor(0.0,0.0,0.0,0.0);
00010   glShadeModel(GL_FLAT);
00011 }
00012 
00013 void mainDisplay()
00014 {
00015   glClear(GL_COLOR_BUFFER_BIT);
00016   glPushMatrix();
00017 
00018   glRotatef(mainspin,0.0,0.0,1.0);
00019   glColor3f(1.0,0.0,0.0);
00020 
00021   glBegin(GL_TRIANGLES);
00022 
00023   glVertex2f(-0.5,0.0);
00024   glVertex2f(0.0,1.0);
00025   glVertex2f(0.5,0.0);
00026 
00027   glEnd();
00028 
00029   glPopMatrix();
00030   glutSwapBuffers();
00031 }
00032 
00033 void mainReshape(int w, int h)
00034 {
00035   glViewport(0,0,(GLsizei)w,(GLsizei)h);
00036   glMatrixMode(GL_PROJECTION);
00037   glLoadIdentity();
00038   glOrtho(-1.0,1.0,-1.0,1.0,-1.0,1.0);
00039   glMatrixMode(GL_MODELVIEW);
00040   glLoadIdentity();
00041 }
00042 
00043 void mainAnimate()
00044 {
00045   mainspin += 0.1;
00046   if (mainspin >360.0)
00047     mainspin -= 360.0;
00048 
00049   glutPostRedisplay();
00050 }
00051 
00052 
00053 int main( int argc, char** argv)
00054 {
00055   glutInit(&argc,argv);
00056   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
00057   glutInitWindowSize(250,250);
00058 
00059   glutCreateWindow(argv[0]);
00060   mainInit();
00061 
00062   glutDisplayFunc(mainDisplay);
00063   glutReshapeFunc(mainReshape);
00064   glutIdleFunc(mainAnimate);
00065 
00066   glutMainLoop();
00067   return 0;
00068 }
00069 
00070 

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