Tampilan yang akan di buat :
scriptnya :
#include
<windows.h> // digunakan oleh
sistem
#include
<iostream>
#include
<gl/Gl.h>
#include
<gl/glut.h>
using
namespace std;
void
myInit(void)
{
glClearColor(1.0,1.0,1.0,0.0); // membuat latar belakang putih
glColor3f(0.0f, 0.0f, 0.f); // membuat warna gambar
hitam
glPointSize(4.0); // ukuran titik 4 x 4
pixel
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glLineWidth(4.0f);
gluOrtho2D(0.0, 500.0, 0.0, 300.0);
}
//<<<<<<<<<<<<<<<<<<<<<<<<
myDisplay >>>>>>>>>>>>>>>>>
void
myDisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT);
// hapus layar
glColor3f(1.3f,0.7f,0.9f);
glBegin(GL_POLYGON);//tembok depan
glVertex2i(100, 100);
glVertex2i(100, 200);
glVertex2i(200, 200);
glVertex2i(200, 100);
glEnd();
glBegin(GL_POLYGON);//tembok gedung
glVertex2i(200, 100);
glVertex2i(200, 200);
glVertex2i(400, 200);
glVertex2i(400, 100);
glEnd();
glColor3f(1.0f,0.7f,0.6f);
glBegin(GL_POLYGON);//pintu
glVertex2i(130, 100);
glVertex2i(130, 150);
glVertex2i(160, 150);
glVertex2i(160, 100);
glEnd();
glColor3f(0.0f,0.0f,0.0f);
glBegin(GL_POINTS);//pintu
glVertex2i(135, 130);
glEnd();
glColor3f(1.0f,0.6f,0.0f);
glBegin(GL_POLYGON);
glVertex2i(100, 200); //atap
depan
glVertex2i(150, 250);
glVertex2i(200, 200);
glEnd();
glColor3f(1.0f,0.4f,0.0f);
glBegin(GL_POLYGON);//atap gedung
glVertex2i(200, 200);
glVertex2i(150, 250);
glVertex2i(350, 250);
glVertex2i(400, 200);
glEnd();
glColor3f(1.0f,1.0f,.0f);
glBegin(GL_POLYGON);
glVertex2i(275, 125); // Jendela kiri bawah
glVertex2i(275, 150);
glVertex2i(300, 150);
glVertex2i(300, 125);
glEnd();
glColor3f(0.0f,0.7f,1.6f);
glBegin(GL_POLYGON);
glVertex2i(275, 150); // Jendela kiri atas
glVertex2i(275, 175);
glVertex2i(300, 175);
glVertex2i(300, 150);
glEnd();
glColor3f(1.0f,0.0f,1.0f);
glBegin(GL_POLYGON);
glVertex2i(250, 125); // Jendela kanan bawah
glVertex2i(250, 150);
glVertex2i(275, 150);
glVertex2i(275, 125);
glEnd();
glColor3f(0.7f,1.0f,0.7f);
glBegin(GL_POLYGON);
glVertex2i(250, 150); // Jendela kanan atas
glVertex2i(250, 175);
glVertex2i(275, 175);
glVertex2i(275, 150);
glEnd();
glColor3f(0.7f,1.5f,0.9f);
glBegin(GL_POLYGON);
glVertex2i(325, 125); // Jendela 2 kiri
glVertex2i(325, 175);
glVertex2i(350, 175);
glVertex2i(350, 125);
glEnd();
glColor3f(1.0f,0.0f,0.6f);
glBegin(GL_POLYGON);
glVertex2i(350, 125);
glVertex2i(350, 175); // Jendela 2 kanan
glVertex2i(375, 175);
glVertex2i(375, 125);
glEnd();
glColor3f(0.0f,0.0f,.0f);
glBegin(GL_LINE_LOOP);
glVertex2i(100, 100); // Garis tembok depan
glVertex2i(100, 200);
glVertex2i(200, 200);
glVertex2i(200, 100);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2i(130, 100); // garis pintu
glVertex2i(130, 150);
glVertex2i(160, 150);
glVertex2i(160, 100);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2i(200, 100); // garis tembok belakang
glVertex2i(200, 200);
glVertex2i(400, 200);
glVertex2i(400, 100);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2i(200, 300); // garis antena
glVertex2i(150, 250);
glVertex2i(100, 300);
glVertex2i(150, 250);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2i(100, 200); // garis Atap depan
glVertex2i(150, 250);
glVertex2i(200, 200);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2i(200, 200); // garis Atap Belakang
glVertex2i(150, 250);
glVertex2i(350, 250);
glVertex2i(400, 200);
glEnd();
//garis jendela di bawah
glColor3f(0.0f,0.0f,0.0f);
glBegin(GL_LINE_LOOP);
glVertex2i(250, 125); // Jendela kiri bawah
glVertex2i(250, 150);
glVertex2i(275, 150);
glVertex2i(275, 125);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2i(250, 150); // Jendela kiri atas
glVertex2i(250, 175);
glVertex2i(275, 175);
glVertex2i(275, 150);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2i(275, 125); // Jendela kanan bawah
glVertex2i(275, 150);
glVertex2i(300, 150);
glVertex2i(300, 125);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2i(275, 150); // Jendela kanan atas
glVertex2i(275, 175);
glVertex2i(300, 175);
glVertex2i(300, 150);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2i(325, 125); // Jendela 2 kiri
glVertex2i(325, 175);
glVertex2i(350, 175);
glVertex2i(350, 125);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2i(350, 125);
glVertex2i(350, 175); // Jendela 2 kanan
glVertex2i(375, 175);
glVertex2i(375, 125);
glEnd();
glFlush(); // mengirim
semua output ke layar
}
//<<<<<<<<<<<<<<<<<<<<<<<<
main
>>>>>>>>>>>>>>>>>>>>>>
int
main(int argc, char** argv)
{
cout <<"KK KKK
LLL PPPPPP 1111 4444"<<endl;
cout <<"KK KKK
LLL PP PP
11 11 44
44"<<endl;
cout <<"KK KKK LLL
PP PP 11 11 44
44"<<endl;
cout <<"KKKKK LLL PPPPPP 11 4444444"<<endl;
cout <<"KK KKK LLL
PP 11 44"<<endl;
cout <<"KK KKK
LLLLLLLLL PP 11 44"<<endl;
cout <<"KK KKK
LLLLLLLLL PP 1111111 44"<<endl;
glutInit(&argc, argv); // inisialisasi toolkit
glutInitDisplayMode(GLUT_SINGLE |
GLUT_RGB); // set modus display
glutInitWindowSize(450,300); // set ukuran window
glutInitWindowPosition(100, 150); // set posisi window di layar
glutCreateWindow("KELOMPOK 14"); // buka screen window
glutDisplayFunc(myDisplay); // registrasi fungsi menggambar
myInit();
glutMainLoop(); // berulang
terus-menerus
}