// by : Wendel H selsily (672011094)
#include <windows.h> // digunakan oleh sistem
#include <gl/Gl.h>
#include <gl/glut.h>
//<<<<<<<<<<<<<<<<<<<<<<< myInit >>>>>>>>>>>>>>>>>>>>
void myInit(void)
{
glClearColor(1.0,1.0,1.0,0.0); // membuat latar belakang putih
glColor3f(0.0f, 0.0f, 0.0f); // membuat warna gambar hitam
glPointSize(4.0); // ukuran titik 4 x 4 pixel
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 640.0, 0.0, 480.0);
}
//<<<<<<<<<<<<<<<<<<<<<<<< myDisplay >>>>>>>>>>>>>>>>>
void myDisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT); // hapus layar
//segitga 1
glBegin(GL_POLYGON);
glColor3f(0.0f, 0.0f, 0.0f);
glVertex2i(320, 410);
glVertex2i(290, 350);
glVertex2i(350, 350);
glEnd();
//segitiga 2
glBegin(GL_POLYGON);
glColor3f(0.0f, 0.0f, 0.0f);
glVertex2i(290, 350);
glVertex2i(320, 290);
glVertex2i(260, 290);
glEnd();
//segitiga 3
glBegin(GL_POLYGON);
glColor3f(0.0f, 0.0f, 0.0f);
glVertex2i(350, 350);
glVertex2i(320, 290);
glVertex2i(380, 290);
glEnd();
//segitiga 4
glBegin(GL_POLYGON);
glColor3f(0.0f, 0.0f, 0.0f);
glVertex2i(350, 230);
glVertex2i(410, 230);
glVertex2i(380, 290);
glEnd();
//segitiga 5
glBegin(GL_POLYGON);
glColor3f(0.0f, 0.0f, 0.0f);
glVertex2i(350, 230);
glVertex2i(290, 230);
glVertex2i(320, 290);
glEnd();
//segitiga 6
glBegin(GL_POLYGON);
glColor3f(0.0f, 0.0f, 0.0f);
glVertex2i(230, 230);
glVertex2i(290, 230);
glVertex2i(260, 290);
glEnd();
glFlush(); // mengirim semua output ke layar
}
//<<<<<<<<<<<<<<<<<<<<<<<< main >>>>>>>>>>>>>>>>>>>>>>
int main(int argc, char** argv)
{
glutInit(&argc, argv); // inisialisasi toolkit
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); // set modus display
glutInitWindowSize(640,480); // set ukuran window
glutInitWindowPosition(100, 150); // set posisi window di layar
//acuan sudut kiri-atas
glutCreateWindow("Segitiga Bertingkat"); // buka screen window
glutDisplayFunc(myDisplay); // registrasi fungsi menggambr
myInit();
glutMainLoop(); // berulang terus-menerus
}
Tidak ada komentar:
Posting Komentar