Rabu, 12 Oktober 2016

TUGAS 1 GRAFIK KOMPUTER MEMBUAT BENTUK DASAR DENGAN OPEN GL

Diposting oleh Unknown di 20.25
Nama Kelompok :
1. Arief Hidayat (51414566)
2. Bentar Adhityajaya Pangestu (52414134)
3. Fajar Tri Suhadi (53414889)
4. Osman Tri Prakoso (58414356)
5. Yuli Marlena (5C414531)

Kelas : 3IA12

Pada tugas  kali ini kami akan membuat bentuk dasar dan bangun ruang menggunakan DevC++ dengan library openGL.
 Disini kami membuat 4 garis :
  • harizontal
  • vertikal
  • diagonal
  • garis bebas
serta kami juga membuat 3 ruang :
  • Segitiga outline dan segitiga full area
  • Segiempat full area  dan segitempat outline
  • polygon full area dan polygon outline
Cara membuatnya pertama-tama kita buka aplikasi DevC++ kemudian kita buka library openGL dan ketikan kodingan dibawah ini :


1. Garis Harizontal


glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
            glClear (GL_COLOR_BUFFER_BIT);
            glPushMatrix ();     
            glBegin (GL_LINES);
            glColor3f (128.0f, 255.0f, 0.0f); 
                                                glVertex2f (-0.8f, 0.0f);
                                                glVertex2f (0.8f, 0.0f);        
            glEnd ();
            glPopMatrix ();
            SwapBuffers (hDC);
            theta += 1.0f;
            Sleep (1);        }
    }

Outputnya :
Output Harizontal


2. Garis Vertikal


glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
            glClear (GL_COLOR_BUFFER_BIT);

            glPushMatrix ();
          
            glBegin (GL_LINES);
            glColor3f (128.0f, 255.0f, .0f); 
                                                glVertex2f (0.0f, -0.7f);
                                                glVertex2f (0.0f, 0.7f);
         
            glEnd ();
            glPopMatrix ();

            SwapBuffers (hDC);

            theta += 1.0f;
            Sleep (1);        }
    }

Outputnya :
Output Vertikal

3. Diagonal

glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
            glClear (GL_COLOR_BUFFER_BIT);
            glPushMatrix ();
            glBegin (GL_LINES);
            glColor3f (128.0f, 255.0f, 0.0f); 
                                                glVertex2f (-0.7f, 0.7f);
                                                glVertex2f (0.7f, -0.7f);
         
            glEnd ();
            glPopMatrix ();

            SwapBuffers (hDC);

            theta += 1.0f;
            Sleep (1);        }
    }

Outputnya :
Output Diagonal


4. Garis bebas


glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
            glClear (GL_COLOR_BUFFER_BIT);
            glPushMatrix ();
            glBegin (GL_LINES);
            glColor3f (128.0f, 255.0f, 0.0f); 
                                                glVertex2f (-0.7f, -0.1f);
                                                glVertex2f (0.7f, 0.3f);
                                              
            glEnd ();
            glPopMatrix ();

            SwapBuffers (hDC);

            theta += 1.0f;
            Sleep (1);        }
    }

Outputnya :
Output Garis Bebas


5.Segitiga Outline


glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
            glClear (GL_COLOR_BUFFER_BIT);

            glPushMatrix ();
          
            glBegin (GL_LINE_LOOP);
            glColor3f (128.0f, 255.0f, 0.0f);   glVertex2f (-0.3f, 0.5f);
            glColor3f (128.0f, 255.0f, 0.0f);   glVertex2f (0.2f, 0.0f);
            glColor3f (128.0f, 255.0f, 0.0f);   glVertex2f (-0.3f, -0.5f);
            glEnd ();
            glPopMatrix ();

            SwapBuffers (hDC);

            theta += 1.0f;
            Sleep (1);
       
                }
    }

Output :
Output Seigitiga Outline


6. Segitiga Fill Area


glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
            glClear (GL_COLOR_BUFFER_BIT);

            glPushMatrix ();
          
            glBegin (GL_TRIANGLES);
            glColor3f (128.0f, 255.0f, 0.0f);   glVertex2f (-0.3f, 0.5f);
            glColor3f (128.0f, 255.0f, 0.0f);   glVertex2f (0.2f, 0.0f);
            glColor3f (128.0f, 255.0f, 0.0f);   glVertex2f (-0.3f, -0.5f);
            glEnd ();
            glPopMatrix ();

            SwapBuffers (hDC);

            theta += 1.0f;
            Sleep (1);
       
                }
    }

Outputnya: 
Output Segitiga Full Area


7. Segiempat Outline


glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
            glClear (GL_COLOR_BUFFER_BIT);

            glPushMatrix ();
          
            glBegin (GL_LINE_LOOP);
            glColor3f (128.0f, 255.0f, 0.0f); 
                                                glVertex2f (-0.8f, -0.8f);
                                                    glVertex2f (-0.8f, 0.8f);
                                                    glVertex2f (0.8f, 0.8f);
                                                   glVertex2f (0.8f, -0.8f);
            glEnd ();
            glPopMatrix ();

            SwapBuffers (hDC);

            theta += 1.0f;
            Sleep (1);        }
    }

Outputnya :


Output Segiempat Outline



8. Segiempat Full Area


glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
            glClear (GL_COLOR_BUFFER_BIT);
            glPushMatrix ();
          
            glBegin (GL_POLYGON);
            glColor3f (128.0f, 255.0f, 0.0f);   glVertex2f (-0.8f, -0.8f);
            glColor3f (128.0f, 255.0f, 0.0f);   glVertex2f (-0.8f, 0.8f);
            glColor3f (128.0f, 255.0f, 0.0f);   glVertex2f (0.8f, 0.8f);
            glColor3f (128.0f, 255.0f, 0.0f);   glVertex2f (0.8f, -0.8f);
                                                glEnd ();
            glPopMatrix ();

            SwapBuffers (hDC);

            theta += 1.0f;
            Sleep (1);        }
    }

Outputnya :
Output Segiempat Full Area


9. Polygon Outline


glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
            glClear (GL_COLOR_BUFFER_BIT);
            glPushMatrix ();
          
            glBegin (GL_LINE_LOOP);
            glColor3f (128.0f, 255.0f, 0.0f); 
                                                glVertex2f (0.0f, 0.8f);
            glVertex2f (-0.7f, 0.3f);
            glVertex2f (-0.4f, -0.7f);
            glVertex2f (0.3f, -0.5f);
            glVertex2f (0.8f, -0.1f);
                                                glEnd ();
            glPopMatrix ();

            SwapBuffers (hDC);

            theta += 1.0f;
            Sleep (1);        }
    }

Outputnya :
Output Polygon Outline



10. Polygon Full Area


glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
            glClear (GL_COLOR_BUFFER_BIT);

            glPushMatrix ();
          
            glBegin (GL_POLYGON);
            glColor3f (128.0f, 255.0f, 0.0f); 
                                                glVertex2f (0.0f, 0.8f);
            glVertex2f (-0.7f, 0.3f);
            glVertex2f (-0.4f, -0.7f);
            glVertex2f (0.3f, -0.5f);
            glVertex2f (0.8f, -0.1f);
                                                glEnd ();
            glPopMatrix ();

            SwapBuffers (hDC);

            theta += 1.0f;
            Sleep (1);        }
    }

Outpuntnya :
Output Polygon Full Area






 


0 komentar:

Posting Komentar

 

Your Life Is Your Choose Template by Ipietoon Blogger Template | Gadget Review