Advertisement
gurumutant

Pemrograman Grafik - ZigZag

Aug 2nd, 2017
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <iostream>
  2. #include <GL/glut.h>
  3. using namespace std;
  4. void mydisplay() {
  5.     float x, q = 0.7, y;
  6.     int i = 1;
  7.     glClear(GL_COLOR_BUFFER_BIT); // Menghapus layar
  8.     glBegin(GL_LINE_STRIP);
  9.     for(x=-1;x<=1;x+=0.2) {
  10.         if (i % 2 == 0) y = -q; else y = q;
  11.         i++;
  12.         glVertex2f(x,y);
  13.         printf("p: %0.4f, y: %0.4f\n",x,y);
  14.     }
  15.     glEnd(); glFlush();
  16. }
  17. int main() {
  18.     glutCreateWindow( "Pemrograman Grafik RPL 2017");
  19.     glutDisplayFunc(mydisplay);
  20.     glutMainLoop();
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement