Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pengumpulan tugas praktikum 1.1 dan 1.2 #3

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
140 changes: 140 additions & 0 deletions Praktikum 1/24060122120031/tugas1.1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
/*
Nama: Bintang Syafrian Rizal
NIM : 24060122120031
Lab : D1

Tugas 1.1
*/

#include <gl/glut.h>

void starboy(void) {

glClear(GL_COLOR_BUFFER_BIT);

//GL_LINE_STRIP bentuk nadi jantung
glLineWidth(7.0f);

glBegin(GL_LINE_STRIP);
glColor3ub(57,255,30);
glVertex2f(-0.2, 0.7);

glColor3ub(57,255,30);
glVertex2f(-0.2, 0.5);
glVertex2f(0.1, 0.3);

glColor3ub(57,255,30);
glVertex2f(-0.2, 0.1);

glColor3ub(57,255,30);
glVertex2f(-0.2, -0.1);

glColor3ub(57,255,30);
glVertex2f(-0.5, -0.3);

glColor3ub(57,255,30);
glVertex2f(-0.2, -0.5);

glColor3ub(57,255,30);
glVertex2f(-0.2, -0.7);

glEnd();


//GL_LINE_LOOP bentuk busur panah
glLineWidth(8.0f);
glBegin(GL_LINE_LOOP);
glColor3ub(255, 185, 0);
glVertex2f(0.9, -0.15);

glColor3ub(53, 55, 75);
glVertex2f(0.9, -0.3);

glColor3ub(52, 73, 120);
glVertex2f(0.75, -0.45);

glColor3ub(82, 146, 124);
glVertex2f(0.6, -0.5);

glColor3ub(120, 160, 131);
glVertex2f(0.6, -0.5);
glEnd();

//GL_TRIANGLE_FAN Segitiga membentuk kipas
glLineWidth(5.0f);
glBegin(GL_TRIANGLE_FAN);

glColor3ub(255, 146, 133);
glVertex2f(0.0, 0.0);
glVertex2f(0.2, 0.3);
glVertex2f(0.3, 0.2);
glVertex2f(0.35, 0.05);
glVertex2f(0.3, 0.1);
glVertex2f(0.2, 0.2);

glEnd();

//GL_TRIANGLE_STRIP bentuk kotak tiga dimensi
glLineWidth(6.0f);
glBegin(GL_TRIANGLE_STRIP);
glColor3ub(265,55,59);
glVertex2f(-0.90, 0.50);
glVertex2f(-0.60, 0.50);
glVertex2f(-0.60, 0.10);

glColor3ub(123, 179, 255);
glVertex2f(-0.90, 0.20);
glVertex2f(-0.90, 0.50);
glVertex2f(-0.60, 0.50);
glEnd();

//GL_QUADS
glLineWidth(4.0f);

glBegin(GL_QUADS);

glColor3ub(122,17,123);
glVertex2f(0.05, -0.45);
glVertex2f(0.45, -0.45);
glVertex2f(0.45, -0.20);
glVertex2f(0.05, -0.20);

glColor3ub(88,56,124);
glVertex2f(0.20, -0.40);
glColor3ub(103,56,136);
glVertex2f(0.30, -0.40);

glColor3ub(239,79,145);
glVertex2f(0.30, -0.10);
glColor3ub(199,157,215);
glVertex2f(0.20, -0.10);

glEnd();

//GL_QUAD_STRIP warna pink
glBegin(GL_QUAD_STRIP);

glColor3ub(255,89,143);
glVertex2f(0.70, -0.20);
glVertex2f(0.70, 0.20);
glVertex2f(0.60, -0.20);
glVertex2f(0.60, 0.20);
glVertex2f(0.50, -0.30);
glVertex2f(0.50, 0.30);

glEnd();
glFlush();

}

int main(int argc,char *argv[])
{
glutInit(&argc, argv);
glutInitWindowSize(720,640);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
glutCreateWindow("Tugas 1.1");
glutDisplayFunc(starboy);
glClearColor(1.0f,1.0f,1.0f,1.0f);
glutMainLoop();
return 0;
}
Binary file added Praktikum 1/24060122120031/tugas1.1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions Praktikum 1/24060122120031/tugas1.2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
Nama: Bintang Syafrian Rizal
NIM : 24060122120031
Lab : D1

Tugas 1.2
*/

#include <gl/glut.h>

void eightfigure(void)
{
glClear(GL_COLOR_BUFFER_BIT);

glColor3ub(248, 222, 34); // warna kuning
glRectf(-0.1, 0.1, 0.1, -0.1);

glColor3ub(163, 103, 177); // warna ungu
glRectf(-0.35, 0.35, -0.15, 0.15);
glRectf(0.15, 0.35, 0.35, 0.15);

glColor3ub(255, 192, 217); // warna pink
glRectf(-0.1, 0.6, 0.1, 0.4);
glRectf(-0.1, -0.6, 0.1, -0.4);

glColor3ub(255, 0, 77); // warna merah
glRectf(-0.35, -0.35, -0.15, -0.15);
glRectf(0.15, -0.35, 0.35, -0.15);

glFlush();
}


int main(int argc,char *argv[])
{
glutInit(&argc, argv);
glutInitWindowSize(640,480);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
glutCreateWindow("Kubus Eight Figure");
glutDisplayFunc(eightfigure);
glClearColor(1.0f,1.0f,1.0f,1.0f);
glutMainLoop();
return 0;
}
Binary file added Praktikum 1/24060122120031/tugas1.2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.