You are on page 1of 18

Nama : Syaifullah Abdurrahman

NIM : 17051204052
Kelas : TI 2017 B

TUGAS 2 Grafika Komputer


Menggambar laptop dengan line strip, line loop dan polygon dengan openGL

Line Strip

Code:
void userdrawstrip() {

//for Screen Casing


glColor3f(0, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-100, 150);
glVertex2f(100, 150);
glVertex2f(100, 10);
glVertex2f(-100, 10);
glVertex2f(-100, 150);
glEnd();
//for Screen
glColor3f(0, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-85, 125);
glVertex2f(85, 125);
glVertex2f(85, 35);
glVertex2f(-85, 35);
glVertex2f(-85, 125);
glEnd();

//For Engsel Kiri


glColor3f(0, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-100, 10);
glVertex2f(-90, 10);
glVertex2f(-90, 0);
glVertex2f(-100, 0);
glVertex2f(-100, 10);
glEnd();

//For Engsel Kanan


glColor3f(0, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(100, 10);
glVertex2f(90, 10);
glVertex2f(90, 0);
glVertex2f(100, 0);
glVertex2f(100, 10);
glEnd();

//For Casing
glColor3f(0, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-100, 0);
glVertex2f(100, 0);
glVertex2f(150, -130);
glVertex2f(-150, -130);
glVertex2f(-100, 0);
glEnd();

//For Keyboard
glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-95, -15);
glVertex2f(95, -15);
glVertex2f(110, -65);
glVertex2f(-110, -65);
glVertex2f(-95, -15);
glEnd();

//For Touchpad
glColor3f(0, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-25, -80);
glVertex2f(25, -80);
glVertex2f(30, -120);
glVertex2f(-30, -120);
glVertex2f(-25, -80);
glEnd();

//For L/R Click


glColor3f(0, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-29, -110);
glVertex2f(29, -110);
glEnd();

glColor3f(0, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(0, -110);
glVertex2f(0, -120);
glEnd();

//For Key on Keyboard


//Vertikal
glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(0, -15);
glVertex2f(0, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(85, -15);
glVertex2f(100, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(75, -15);
glVertex2f(90, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(65, -15);
glVertex2f(78, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(55, -15);
glVertex2f(68, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(45, -15);
glVertex2f(56, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(35, -15);
glVertex2f(46, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(25, -15);
glVertex2f(34, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(15, -15);
glVertex2f(24, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(7, -15);
glVertex2f(14, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-85, -15);
glVertex2f(-100, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-75, -15);
glVertex2f(-90, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-65, -15);
glVertex2f(-78, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-55, -15);
glVertex2f(-65, -55);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-45, -15);
glVertex2f(-56, -55);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-35, -15);
glVertex2f(-46, -55);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-25, -15);
glVertex2f(-34, -55);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-15, -15);
glVertex2f(-24, -55);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-7, -15);
glVertex2f(-14, -65);
glEnd();

//Horizontal
glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-98, -25);
glVertex2f(98, -25);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-101, -35);
glVertex2f(101, -35);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-104, -45);
glVertex2f(104, -45);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-107, -55);
glVertex2f(107, -55);
glEnd();

//For MSI
//M
glColor3f(0, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-13, 15);
glVertex2f(-13, 30);
glVertex2f(-8, 20);
glVertex2f(-3, 30);
glVertex2f(-3, 15);
glEnd();

//S
glColor3f(0, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(7, 30);
glVertex2f(0, 30);
glVertex2f(0, 23);
glVertex2f(7, 23);
glVertex2f(7, 15);
glVertex2f(0, 15);
glEnd();

//I
glColor3f(0, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(10, 30);
glVertex2f(10, 15);
glEnd();

//for Windows
glColor3f(0, 0, 1);
glBegin(GL_LINE_STRIP);
glVertex2f(-25, 90);
glVertex2f(25, 95);
glVertex2f(25, 55);
glVertex2f(-25, 60);
glVertex2f(-25, 90);
glEnd();

glColor3f(0, 0, 1);
glBegin(GL_LINE_STRIP);
glVertex2f(0, 93);
glVertex2f(0, 56);
glEnd();

glColor3f(0, 0, 1);
glBegin(GL_LINE_STRIP);
glVertex2f(-25, 75);
glVertex2f(25, 75);
glEnd();
}
Line Loop

Code:
void userdrawloop() {

//for Screen Casing


glColor3f(0, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2f(-100, 150);
glVertex2f(100, 150);
glVertex2f(100, 10);
glVertex2f(-100, 10);
//glVertex2f(-100, 150);
glEnd();

//for Screen
glColor3f(0, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2f(-85, 125);
glVertex2f(85, 125);
glVertex2f(85, 35);
glVertex2f(-85, 35);
//glVertex2f(-85, 125);
glEnd();

//For Engsel Kiri


glColor3f(0, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2f(-100, 10);
glVertex2f(-90, 10);
glVertex2f(-90, 0);
glVertex2f(-100, 0);
//glVertex2f(-100, 10);
glEnd();

//For Engsel Kanan


glColor3f(0, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2f(100, 10);
glVertex2f(90, 10);
glVertex2f(90, 0);
glVertex2f(100, 0);
//glVertex2f(100, 10);
glEnd();

//For Casing
glColor3f(0, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2f(-100, 0);
glVertex2f(100, 0);
glVertex2f(150, -130);
glVertex2f(-150, -130);
//glVertex2f(-100, 0);
glEnd();

//For Keyboard
glColor3f(1, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2f(-95, -15);
glVertex2f(95, -15);
glVertex2f(110, -65);
glVertex2f(-110, -65);
//glVertex2f(-95, -15);
glEnd();

//For Touchpad
glColor3f(0, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2f(-25, -80);
glVertex2f(25, -80);
glVertex2f(30, -120);
glVertex2f(-30, -120);
//glVertex2f(-25, -80);
glEnd();

//For L/R Click


glColor3f(0, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2f(-29, -110);
glVertex2f(29, -110);
glEnd();

glColor3f(0, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2f(0, -110);
glVertex2f(0, -120);
glEnd();

//For Key on Keyboard


//Vertikal
glColor3f(1, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2f(0, -15);
glVertex2f(0, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2f(85, -15);
glVertex2f(100, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2f(75, -15);
glVertex2f(90, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2f(65, -15);
glVertex2f(78, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2f(55, -15);
glVertex2f(68, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2f(45, -15);
glVertex2f(56, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2f(35, -15);
glVertex2f(46, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2f(25, -15);
glVertex2f(34, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2f(15, -15);
glVertex2f(24, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2f(7, -15);
glVertex2f(14, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2f(-85, -15);
glVertex2f(-100, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2f(-75, -15);
glVertex2f(-90, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2f(-65, -15);
glVertex2f(-78, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2f(-55, -15);
glVertex2f(-65, -55);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2f(-45, -15);
glVertex2f(-56, -55);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2f(-35, -15);
glVertex2f(-46, -55);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2f(-25, -15);
glVertex2f(-34, -55);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2f(-15, -15);
glVertex2f(-24, -55);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2f(-7, -15);
glVertex2f(-14, -65);
glEnd();

//Horizontal
glColor3f(1, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2f(-98, -25);
glVertex2f(98, -25);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2f(-101, -35);
glVertex2f(101, -35);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2f(-104, -45);
glVertex2f(104, -45);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2f(-107, -55);
glVertex2f(107, -55);
glEnd();

//For MSI
//M
glColor3f(0, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-13, 15);
glVertex2f(-13, 30);
glVertex2f(-8, 20);
glVertex2f(-3, 30);
glVertex2f(-3, 15);
glEnd();

//S
glColor3f(0, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(7, 30);
glVertex2f(0, 30);
glVertex2f(0, 23);
glVertex2f(7, 23);
glVertex2f(7, 15);
glVertex2f(0, 15);
glEnd();

//I
glColor3f(0, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(10, 30);
glVertex2f(10, 15);
glEnd();
//for Windows
glColor3f(0, 0, 1);
glBegin(GL_LINE_LOOP);
glVertex2f(-25, 90);
glVertex2f(25, 95);
glVertex2f(25, 55);
glVertex2f(-25, 60);
//glVertex2f(-25, 90);
glEnd();

glColor3f(0, 0, 1);
glBegin(GL_LINE_LOOP);
glVertex2f(0, 93);
glVertex2f(0, 56);
glEnd();

glColor3f(0, 0, 1);
glBegin(GL_LINE_LOOP);
glVertex2f(-25, 75);
glVertex2f(25, 75);
glEnd();
}
Polygon

Code:
void userdrawpolygon() {

//for Screen Casing


glColor3f(0, 0, 0);
glBegin(GL_POLYGON);
glVertex2f(-100, 150);
glVertex2f(100, 150);
glVertex2f(100, 10);
glVertex2f(-100, 10);
//glVertex2f(-100, 150);
glEnd();

//for Screen
glColor3f(0, 0, 1);
glBegin(GL_POLYGON);
glVertex2f(-85, 125);
glVertex2f(85, 125);
glVertex2f(85, 35);
glVertex2f(-85, 35);
//glVertex2f(-85, 125);
glEnd();

//For Engsel Kiri


glColor3f(0, 0, 0);
glBegin(GL_POLYGON);
glVertex2f(-100, 10);
glVertex2f(-90, 10);
glVertex2f(-90, 0);
glVertex2f(-100, 0);
//glVertex2f(-100, 10);
glEnd();

//For Engsel Kanan


glColor3f(0, 0, 0);
glBegin(GL_POLYGON);
glVertex2f(100, 10);
glVertex2f(90, 10);
glVertex2f(90, 0);
glVertex2f(100, 0);
//glVertex2f(100, 10);
glEnd();

//For Casing
glColor3f(0, 0, 0);
glBegin(GL_POLYGON);
glVertex2f(-100, 0);
glVertex2f(100, 0);
glVertex2f(150, -130);
glVertex2f(-150, -130);
//glVertex2f(-100, 0);
glEnd();

//For Keyboard
glColor3f(0, 0, 0);
glBegin(GL_POLYGON);
glVertex2f(-95, -15);
glVertex2f(95, -15);
glVertex2f(110, -65);
glVertex2f(-110, -65);
//glVertex2f(-95, -15);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-95, -15);
glVertex2f(95, -15);
glVertex2f(110, -65);
glVertex2f(-110, -65);
glVertex2f(-95, -15);
glEnd();

//For Touchpad
glColor3f(0, 0, 0);
glBegin(GL_POLYGON);
glVertex2f(-25, -80);
glVertex2f(25, -80);
glVertex2f(30, -120);
glVertex2f(-30, -120);
//glVertex2f(-25, -80);
glEnd();

glColor3f(1, 1, 1);
glBegin(GL_LINE_STRIP);
glVertex2f(-25, -80);
glVertex2f(25, -80);
glVertex2f(30, -120);
glVertex2f(-30, -120);
glVertex2f(-25, -80);
glEnd();

//For L/R Click


glColor3f(1, 1, 1);
glBegin(GL_LINE_STRIP);
glVertex2f(-29, -110);
glVertex2f(29, -110);
glEnd();

glColor3f(1, 1, 1);
glBegin(GL_LINE_STRIP);
glVertex2f(0, -110);
glVertex2f(0, -120);
glEnd();

//For Key on Keyboard


//Vertikal
glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(0, -15);
glVertex2f(0, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(85, -15);
glVertex2f(100, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(75, -15);
glVertex2f(90, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(65, -15);
glVertex2f(78, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(55, -15);
glVertex2f(68, -65);
glEnd();
glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(45, -15);
glVertex2f(56, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(35, -15);
glVertex2f(46, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(25, -15);
glVertex2f(34, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(15, -15);
glVertex2f(24, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(7, -15);
glVertex2f(14, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-85, -15);
glVertex2f(-100, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-75, -15);
glVertex2f(-90, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-65, -15);
glVertex2f(-78, -65);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-55, -15);
glVertex2f(-65, -55);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-45, -15);
glVertex2f(-56, -55);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-35, -15);
glVertex2f(-46, -55);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-25, -15);
glVertex2f(-34, -55);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-15, -15);
glVertex2f(-24, -55);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-7, -15);
glVertex2f(-14, -65);
glEnd();

//Horizontal
glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-98, -25);
glVertex2f(98, -25);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-101, -35);
glVertex2f(101, -35);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-104, -45);
glVertex2f(104, -45);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-107, -55);
glVertex2f(107, -55);
glEnd();

//For MSI
//M
glColor3f(1, 1, 1);
glBegin(GL_LINE_STRIP);
glVertex2f(-13, 15);
glVertex2f(-13, 30);
glVertex2f(-8, 20);
glVertex2f(-3, 30);
glVertex2f(-3, 15);
glEnd();

//S
glColor3f(1, 1, 1);
glBegin(GL_LINE_STRIP);
glVertex2f(7, 30);
glVertex2f(0, 30);
glVertex2f(0, 23);
glVertex2f(7, 23);
glVertex2f(7, 15);
glVertex2f(0, 15);
glEnd();

//I
glColor3f(1, 1, 1);
glBegin(GL_LINE_STRIP);
glVertex2f(10, 30);
glVertex2f(10, 15);
glEnd();

//for Windows
glColor3f(1, 1, 1);
glBegin(GL_POLYGON);
glVertex2f(-25, 90);
glVertex2f(25, 95);
glVertex2f(25, 55);
glVertex2f(-25, 60);
//glVertex2f(-25, 90);
glEnd();

glColor3f(0, 0, 1);
glBegin(GL_LINE_STRIP);
glVertex2f(0, 93);
glVertex2f(0, 56);
glEnd();

glColor3f(0, 0, 1);
glBegin(GL_LINE_STRIP);
glVertex2f(-25, 75);
glVertex2f(25, 75);
glEnd();
}

You might also like