Advertisement
Guest User

Untitled

a guest
Sep 24th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. #include <windows.h>
  2. #include <stdlib.h>
  3. #include <GL/glut.h>
  4. #include <math.h>
  5.  
  6. int x=0;
  7. int z=0;
  8. int z2=90;
  9.  
  10.  
  11. void drawQuad1(void)
  12. {
  13. glBegin (GL_POLYGON);
  14. glColor3f(0.0,0.0,0.0);
  15. glVertex2i(0,1);
  16. glVertex2i(-100,0);
  17. glColor3f(0.0,0.0,0.0);
  18. glVertex2i(-100,20);
  19. glVertex2i(0,20);
  20. glEnd();
  21. }
  22.  
  23. void botol(void)
  24. {
  25. glBegin (GL_POLYGON);
  26. glColor3f(1.0,0.0,0.0); //R
  27. glVertex2i(0,1);
  28. glColor3f(1.0,0.0,0.0); //Y
  29. glVertex2i(-100,0);
  30. glColor3f(1.0,0.0,0.0); //B
  31. glVertex2i(-100,-100);
  32. glColor3f(1.0,0.0,0.0); //Y
  33. glVertex2i(0,-100);
  34. glEnd();
  35. }
  36.  
  37. void renderScene()
  38. {
  39. glClear(GL_COLOR_BUFFER_BIT);
  40. glClearColor(1,1,1,0);
  41. glLoadIdentity();
  42. botol();
  43. glRotatef(x,0,0,1);
  44. if (z <= 90)
  45. {
  46. x-=1;
  47. z+=1;
  48. }
  49. if (z > 90)
  50. {
  51. x+=1;
  52. z2-=1;
  53. }
  54. if (z2 < 0)
  55. {
  56. x-=1;
  57. z=0;
  58. z2=90;
  59. }
  60. drawQuad1();
  61. glFlush();
  62. }
  63.  
  64. void timer (int value)
  65. {
  66. glutPostRedisplay();
  67. glutTimerFunc(10,timer,0);
  68. }
  69.  
  70. void reshape(int w,int h)
  71. {
  72. glViewport(0,0,(GLsizei)w,(GLsizei)h);
  73. glMatrixMode(GL_PROJECTION);
  74. gluOrtho2D(-320,320.0,-320,320);
  75. glMatrixMode(GL_MODELVIEW);
  76. }
  77.  
  78. int main(int argc, char* argv[])
  79. {
  80. glutInit(&argc,argv);
  81. glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
  82. glutInitWindowSize(1000,1000);
  83. glutInitWindowPosition(0,0);
  84. glutCreateWindow("2110161022 - Animasi Gelas");
  85. glutDisplayFunc(renderScene);
  86. glutReshapeFunc(reshape);
  87. glutTimerFunc(1,timer,0);
  88. glutMainLoop();
  89. return 0;
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement