GRAFIKA KOMPUTER - MEMBUAT 3 GAMBAR BANGUN SEGITIGA DENGAN DEV C++ OPENGL
Langkah-langkah
Membuat Program :
Buka
Aplikasi Dev C++ yang sudah di Instal
Untuk memulai membuat program pilih File
– New – Project – Ok
Setelah
New Project akan tampil jenis lembar kerja yang akan digunakan, Klik Conole
Application – OK
Setelah
itu Save
Project, Klik Save
Setelah
itu akan muncul tampilan awal, kemudian Klik Kanan pada Bar Project1, lalu
pilih Project Options
Pada
Project Options, Klik Parameters – Linker
Pada
Box Linker ketik -lopengl32, -lfreeglut, -lglu32, lalu klik OK
Pada
Lembar Kerja akan Muncul Scrip seperti ini :
Kosongkan
Script dan Ketikan script dengan projek yang akan dibuat seperti dibawah ini:
Syntak Program :
| 
#include <GL/glut.h>           
#include <windows.h> 
void init (void) {     
glClearColor (1.0, 1.0, 1.0, 0.0);         
glLineWidth (1.0);                 
glColor3f (1.0, 0.0, 0.0);                                       
glOrtho (-6,6, -6,6, -6,6);     
}                                                                
void Display (void) {                              
glClear (GL_COLOR_BUFFER_BIT);     
glBegin (GL_LINES);              
glVertex2f (-5.5, 0.0);                           
glColor3f (1.0, 0.0, 0.0); 
glVertex2f (5.5, 0.0);                            
glEnd ();                  
glBegin (GL_LINES);                              
glVertex2f (0.0, -5.5);           
glColor3f (1.0, 0.0, 0.0);       
glVertex2f (0.0, 5.5);                            
glEnd ();                                                                  
glBegin (GL_TRIANGLES);                                     
glColor3f (1.0, 0.0, 0.0);                       
glVertex2f (1.0, 1.0);                            
glColor3f (0.0, 0.0, 1.0);                       
glVertex2f (5.0, 1.0);  
glColor3f (0.0, 1.0, 0.0);  
glVertex2f (3.0, 5.0);  
glEnd (); 
glBegin (GL_TRIANGLES);                                     
glColor3f (1.0, 0.43, 0.78);                  
glVertex2f (-1.0, 1.0);                           
glColor3f (0.0, 1.0, 1.0);                       
glVertex2f (-5.0, 1.0);  
glColor3f (1.0, 1.0, 0.0);  
glVertex2f (-3.0, 5.0);  
glEnd (); 
glBegin (GL_TRIANGLES);                                     
glColor3f (1.0, 0.43, 0.78);                  
glVertex2f (2.0, -1.0);                           
glColor3f (0.0, 1.0, 1.0);                       
glVertex2f (0.0, -5.0);  
glColor3f (1.0, 1.0, 0.0);  
glVertex2f (-2.0, -1.0);  
glEnd (); 
glutSwapBuffers (); 
} 
int main (int argc, char** argv) {        
glutInit (&argc, argv);           
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);       
glutInitWindowPosition (0, 0); 
glutInitWindowSize (500, 500); 
glutCreateWindow ("Bangun 3
  Segitiga");        
init (); 
glutDisplayFunc (Display);  
glutMainLoop (); 
return 0; 
} | 
Setelah
diketik pilih Execute  dan klik Compile
& Run
Setelah
di Compile dan run setelah itu Save File dan Save
Setelah
itu akan keluar output sebagai berikut :










 
 
 
Comments
Post a Comment