Friday, May 11, 2018

D. Tutorial Pembuatan Bangun-Bangun Dasar Grafik pada Dev C++

berikut merupakan tutorial pembuatan bangun dasar grafik pada Dev C++

1. Berikut coding untuk membuat bangun-bangun dasar grafik pada Dev C++ :


  1. #include <GL/glut.h>           
  2. #include <windows.h>   
  3. #include <GL/gl.h>
  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. glOrtho (-6,6, -6,6, -6,6);
  9. }              
  10. void Display (void) {      
  11. glClear (GL_COLOR_BUFFER_BIT); 
  12. glBegin (GL_LINES);
  13. glVertex2f (-5.5, 0.0);    
  14. glColor3f (1.0, 0.0, 0.0);
  15. glVertex2f (5.5, 0.0);     
  16. glEnd ();      
  17. glBegin (GL_LINES);    
  18. glVertex2f (0.0, -5.5);
  19. glColor3f (1.0, 0.0, 0.0); 
  20. glVertex2f (0.0, 5.5);     
  21. glEnd ();      
  22.            
  23.            
  24. glBegin (GL_LINE_LOOP);        
  25. glColor3f (-1.0, 0.0, 0.0);    
  26. glVertex2f (1.0, 1.0);     
  27. glColor3f (-1.0, 0.0, 0.0);    
  28. glVertex2f (4.0, 1.0);
  29. glColor3f (0.0, 1.0, 0.0);
  30. glVertex2f (1.0, 5.0);
  31. glEnd ();
  32. glutSwapBuffers ();
  33. }
  34. int main (int argc, char** argv) { 
  35. glutInit (&argc, argv);
  36. glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);  
  37. glutInitWindowPosition (0, 0);
  38. glutInitWindowSize (1500, 1500);
  39. glutCreateWindow ("bangun dasar grafik");  
  40. init ();
  41. glutDisplayFunc (Display);
  42. glutMainLoop ();
  43. return 0;
  44. }



2. Jika coding sudah diketikkan maka jalankan dengan cara Execute > Compile & Run






Semoga Bermanfaat ^^

No comments:

Post a Comment