Laporan Praktikum Modul Ii

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

LAPORAN PRAKTIKUM MODUL II

GRAFIKA KOMPUTER

Primitive Objects dan Objek 2 Dimensi

Disusun Oleh :

Matheus Dharma Wicaksana 190535646048

UNIVERSITAS NEGERI MALANG


FAKULTAS TEKNIK JURUSAN TEKNIK ELEKTRO
PROGRAM STUDI S1 TEKNIK INFORMATIKA
FEBRUARI 2021
TUGAS ASISTENSI 1

SOURCE CODE

#include <stdlib.h>
#include <GL/glut.h>

void belahketupat(int posx, int posy, int w, int h) {


glBegin(GL_QUAD_STRIP);
glVertex2i(posx, posy);
glVertex2i(posx + (w / 2), posy - (h / 2));
glVertex2i(posx - (w / 2), posy - (h / 2));
glVertex2i(posx, posy - h);
glEnd();
}

void renderScene(void) {
glClear(GL_COLOR_BUFFER_BIT);

belahketupat(60, -60, 60, 60);


glColor3f(0, 0, 1);
belahketupat(-50, -50, 150, -150);
glColor3f(1, 0, 1);
belahketupat(120, -30, 40, -100);
glColor3f(0, 1, 1);
glFlush();

void main(int argc, char** argv) {


glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE | GLUT_RGBA);
glutInitWindowPosition(100, 100);
glutInitWindowSize(640, 480);

glutCreateWindow("BELAH KETUPAT");
glutDisplayFunc(renderScene);
gluOrtho2D(-320., 320., -240., 240.);
glutMainLoop();
}

OUTPUT
TUGAS ASISTENSI 2

SOURCE CODE

#include <stdlib.h>
#include <GL/glut.h>

void layang2(int posx, int posy, int w, int h) {


glBegin(GL_QUADS);
glVertex2i(posx, posy);
glVertex2i(posx + w, posy - h);
glVertex2i(posx, posy - 3 * h);
glVertex2i(posx - w, posy - h);

glEnd();
}

void renderScene(void) {
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1, 0, 1);
layang2(-150, 80, 40, 40);
glColor3f(1, 0, 0);
layang2(-50, 80, 70, 70);
glColor3f(0, 1, 1);
layang2(100, 125, 80, 80);
glFlush();
}

void main(int argc, char** argv) {


glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE | GLUT_RGBA);
glutInitWindowPosition(100, 100);
glutInitWindowSize(640, 480);

glutCreateWindow("Layang-Layang");
glutDisplayFunc(renderScene);
gluOrtho2D(-320., 320., -240., 240.);
glutMainLoop();
}

OUTPUT

You might also like