GRAFIKA KOMPUTER - MEMBUAT ROTASI SUMBU Z BIDANG BANGUN DENGAN DEV C++ OPENGL
Langkah-langkah
Membuat Program :
1.      Buka
Aplikasi Dev C++ yang sudah di Instal
Untuk memulai membuat program pilih File
– New – Project – Ok
2.      Setelah
New Project akan tampil jenis lembar kerja yang akan digunakan, Klik Conole
Application – OK
3.      Setelah
itu Save
Project, Klik Save
4.      Setelah
itu akan muncul tampilan awal, kemudian Klik Kanan pada Bar Project1, lalu
pilih Project Options
5.      Pada
Project Options, Klik Parameters – Linker
Pada
Box Linker ketik -lopengl32, -lfreeglut, -lglu32, lalu klik OK
6.      Pada
Lembar Kerja akan Muncul Scrip seperti ini :
7.      Kosongkan
Script dan Ketikan script dengan projek yang akan dibuat seperti dibawah ini:
Syntak Program :
| 
#include <GL/glut.h> 
#include <windows.h> 
GLfloat xangle=0.0, yangle=0.0; 
void init (void) { 
glClearColor (1.0, 1.0, 1.0, 0.0); 
glLineWidth (1.0); 
glColor3f (1.0, 0.0, 0.0); 
glMatrixMode (GL_PROJECTION); 
glLoadIdentity (); 
glOrtho (-6,6, -6,6, -6,6); 
} 
void display (void) { 
glClear (GL_COLOR_BUFFER_BIT); 
glPushMatrix(); 
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 (); 
glRotatef(xangle, 0.0, 0.0, 1.0); 
glBegin (GL_POLYGON); 
glColor3f(-1.0, 0.0, 0.0); 
glVertex2f (1.0, 1.0); 
glColor3f(-1.0, 0.0, 0.0); 
glVertex2f (4.0, 1.0); 
glColor3f(0.0, 1.0, 0.0); 
glVertex2f (1.0, 5.0); 
glEnd (); 
glPopMatrix(); 
glutSwapBuffers(); 
glFlush (); 
} 
void KeyboardAssign (GLubyte key, GLint
  x, GLint y) { switch (key) { 
case 'n': 
xangle +=10.0; 
glColor3f (0.0, 0.0, 1.0); 
glutPostRedisplay (); 
break; 
} 
} 
int main (int argc, char** argv) { 
glutInit (&argc, argv); 
glutInitDisplayMode (GLUT_DOUBLE |
  GLUT_RGB);  
glutInitWindowPosition (0, 0);  
glutInitWindowSize (500, 500);  
glutCreateWindow ("Rotasi Objek pada
  Sumbu Z");  
init(); 
glutDisplayFunc (display); 
glutKeyboardFunc (KeyboardAssign); 
glutMainLoop (); 
} | 
8.      Setelah
diketik pilih Execute  dan klik Compile
& Run 
9.      Setelah
di Compile dan run setelah itu Save File dan Save
10.  Setelah
itu akan keluar output sebagai berikut :
11.  Press “n” secara berkelanjutan
untuk mendapatkan proses rotasi sebagai berikut :










 
  
  
  
  
 
 
 
Comments
Post a Comment