Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <GL/gl.h>
- #include <GL/glu.h>
- #include <GL/glut.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <windows.h>
- switch(state)
- {
- case 0:
- break;
- case 1:
- glPushMatrix();
- glTranslatef(-1,0,0);
- rectangle(0,0,1,2);
- glPopMatrix();
- break;
- case 2:
- glPushMatrix();
- glRotatef(rot,0,0);
- triangle();
- glPopMatrix();
- break;
- case 3:
- glPushMatrix();
- glTranslatef(-0.5,-0.5,-2);
- glRotatef(-45,1,0,0);
- glRotatef(45,1,0,1);
- glTranslatef(0.5,0.5,0.5);
- glRotatef(rot*0.1,1,1,1);
- glTranslatef(-0.5,-0.5,-0.5);
- cube(1.0);
- glPopMatrix();
- break;
- }
- glFlush();
- glutSwapBuffers();
- void myKeyboardFunc(unsigned char key, int x, int y)
- {
- switch(key)
- {
- case '0':
- state=0;
- break;
- case '1':
- state=1;
- case '2':
- state=2;
- flagRotate=true;
- rot=0;
- break;
- case '3':
- state=3;
- flagRotate=true;
- rot=0;
- break;
- case 's':
- flagRotate=false;
- break;
- case 27:
- exit(1);
- }
- glutPostRedisplay();
- }
- void animate()
- {
- if (flagRotate == true)
- {
- rot=(rot+1);
- }
- glutPostRedisplay();
- }
- int main(int argc, char **argv)
- {
- glutInit(&argc,argv);
- glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB|GLUT_DEPTH);
- glutInitWindowPosition(100,100);
- glutInitWindowSize(windowWidth,windowHeight);
- glutCreateWindow('Assignment 1');
- glShadeModel(GL_SMOOTH);
- glEnable(GL_DEPTH_TEST);
- glutDisplayFunc(display);
- glutKeyboardFunc(myKeyboardFunc);
- glutIdleFunc(animate);
- glutMainLoop();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement