Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. #define GLUT_DISABLE_ATEXIT_HACK
  2. #include <GL/gl.h>
  3. #include <GL/glu.h>
  4. #include <GL/glut.h>
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7.  
  8. int screenWidth = 600;
  9. int screenHeight = 600;
  10.  
  11. int figure = 0;
  12.  
  13. void show(){
  14. switch(figure){
  15. default:
  16. case 0:
  17. glutSolidSphere(100, 50, 50);
  18. break;
  19. case 1:
  20. glutWireSphere(100, 50, 50);
  21. break;
  22. case 2:
  23. glutSolidCube(100);
  24. break;
  25. case 3:
  26. glutWireCube(100);
  27. break;
  28. case 4:
  29. glutSolidCone(100, 100, 50, 50);
  30. break;
  31. case 5:
  32. glutWireCone(100, 100, 50, 50);
  33. break;
  34. case 6:
  35. glutSolidTorus(100, 200, 50, 50);
  36. break;
  37. case 7:
  38. glutWireTorus(100, 200, 50, 50);
  39. break;
  40. case 8:
  41. glutSolidTeapot(100);
  42. break;
  43. case 9:
  44. glutWireTeapot(100);
  45. break;
  46. }
  47. }
  48.  
  49. void display() {
  50. glLoadIdentity();
  51. glClear(GL_COLOR_BUFFER_BIT);
  52. glColor3f(0.0, 1.0, 0.0);
  53. show();
  54. glutPostRedisplay();
  55. glutSwapBuffers();
  56. }
  57.  
  58. void reshape(int w, int h) {
  59. glViewport(0, 0, (GLsizei) w, (GLsizei) h);
  60. glMatrixMode(GL_PROJECTION);
  61. glLoadIdentity();
  62. glOrtho(-(GLdouble) screenWidth, (GLdouble) screenWidth, -(GLdouble) screenHeight, (GLdouble) screenHeight, 100, -100);
  63. glMatrixMode(GL_MODELVIEW);
  64. glLoadIdentity();
  65. }
  66.  
  67. void keyboard(unsigned char key, int x, int y){
  68. switch(key){
  69. default:
  70. figure = key - 48;
  71. break;
  72. case 27 :
  73. case 'q':
  74. exit(0);
  75. break;
  76. }
  77. }
  78.  
  79. int main(int argc, char *argv[]) {
  80. glutInit(&argc, argv);
  81. glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
  82. glutInitWindowSize(screenWidth, screenHeight);
  83. glutCreateWindow(argv[0]);
  84. glutDisplayFunc(display);
  85. glutReshapeFunc(reshape);
  86. glutKeyboardFunc(keyboard);
  87. glutMainLoop();
  88. return 0;
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement