Advertisement
Rian_TS

Untitled

Jun 18th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. #include <GL/glut.h>
  2. #include <windows.h>
  3. GLfloat xangle=0.0, yangle=0.0;
  4. void init (void) {
  5. glClearColor (1.0, 1.0, 1.0, 0.0);
  6. glLineWidth (1.0);
  7. glColor3f (1.0, 0.0, 0.0);
  8. glMatrixMode (GL_PROJECTION);
  9. glLoadIdentity ();
  10. glOrtho (-6,6, -6,6, -6,6);
  11. }
  12.  
  13. void display (void) {
  14. glClear (GL_COLOR_BUFFER_BIT);
  15. glPushMatrix();
  16.  
  17.  
  18.  
  19. glBegin (GL_LINES);
  20. glVertex2f (-5.5,0.0);
  21.  
  22. glColor3f(1.0, 0.0, 0.0);
  23. glVertex2f (5.5,0.0);
  24. glEnd ();
  25. glBegin (GL_LINES);
  26. glVertex2f (0.0,-5.5);
  27. glColor3f(1.0, 0.0, 0.0);
  28. glVertex2f (0.0, 5.5);
  29. glEnd ();
  30.  
  31. glRotatef(xangle, 1.0, 0.0, 0.0);
  32. glBegin (GL_POLYGON);
  33. glColor3f(-1.0, 0.0, 0.0);
  34. glVertex2f (1.0, 1.0);
  35. glColor3f(-1.0, 0.0, 0.0);
  36. glVertex2f (4.0, 1.0);
  37. glColor3f(0.0, 1.0, 0.0);
  38. glVertex2f (1.0, 5.0);
  39. glEnd ();
  40.  
  41. glPopMatrix();
  42. glutSwapBuffers();
  43. glFlush ();
  44. }
  45.  
  46. void KeyboardAssign (GLubyte key, GLint x, GLint y) { switch (key) {
  47.  
  48. case 'x':
  49. xangle +=10.0;
  50. glColor3f (0.0, 0.0, 1.0);
  51. glutPostRedisplay ();
  52. break;
  53. }
  54. }
  55.  
  56. int main (int argc, char** argv) {
  57. glutInit (&argc, argv);
  58.  
  59. glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB); glutInitWindowPosition (0, 0); glutInitWindowSize (1500, 1500); glutCreateWindow ("Latihan Menggerakkan Objek"); init();
  60.  
  61. glutDisplayFunc (display);
  62. glutKeyboardFunc (KeyboardAssign);
  63. glutMainLoop ();
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement