Senin, 13 Oktober 2014
Membuat Tugu UNNES dengan OpenGl C++
Semarang 14 Oktober 2014Selamat Pagi, Siang ataupun Sore :)
satu minggu lalu saya mendapatkan tugas grafika komputer dan kelompok kami disuruh untuk membuat tampilan dengan tema UNNES Konservasi , dan kami berencana untuk membuat replika tugu unnes sebagai tema pembuatan gambar ini .
untuk Membuat Tugu UNNES dengan OpenGl C++ , kita cukup ketikan coding dibawah ini :
#include <windows.h>
#include <GL/gl.h>
#include <GL/glut.h>
void mydisplay()
{
glClear(GL_COLOR_BUFFER_BIT);
//tangga1
glBegin(GL_POLYGON);
glColor3f(200.0/255.0, 195.0/255.0, 145.0/255.0); //make the color Dark Blue
glVertex2f(-0.48, 0.0);
glVertex2f(-0.51, -0.034);
glVertex2f(0.51, -0.034);
glVertex2f(0.48, 0.0);
glEnd();
//tangga2
glBegin(GL_POLYGON);
glColor3f(200.0/255.0, 195.0/255.0, 145.0/255.0); //make the color Dark Blue
glVertex2f(-0.45, 0.0);
glVertex2f(-0.42, 0.025);
glVertex2f(0.42, 0.025);
glVertex2f(0.45, 0.0);
glEnd();
//tangga3
glBegin(GL_POLYGON);
glColor3f(200.0/255.0, 195.0/255.0, 145.0/255.0); //make the color Dark Blue
glVertex2f(-0.41, 0.0);
glVertex2f(-0.37, 0.05);
glVertex2f(0.37, 0.05);
glVertex2f(0.41, 0.0);
glEnd();
//tangga4
glBegin(GL_POLYGON);
glColor3f(200.0/255.0, 195.0/255.0, 145.0/255.0); //make the color Dark Blue
glVertex2f(-0.36, 0.0);
glVertex2f(-0.32, 0.075);
glVertex2f(0.32, 0.075);
glVertex2f(0.36, 0.0);
glEnd();
//pondasi
glBegin(GL_POLYGON);
glColor3f(200.0/255.0, 180.0/255.0, 145.0/255.0); //make the color Dark Blue
glVertex2f(-0.20, 0.075);
glVertex2f(-0.20, 0.17);
glVertex2f(0.20, 0.17);
glVertex2f(0.20, 0.075);
glEnd();
//tiang
glBegin(GL_POLYGON);
glColor3f(200.0/255.0, 195.0/255.0, 145.0/255.0); //make the color Dark Blue
glVertex2f(-0.15, 0.17);
glVertex2f(-0.15, 0.6);
glVertex2f(-0.10, 0.6);
glVertex2f(-0.10, 0.17);
glEnd();
//tiang
glBegin(GL_POLYGON);
glColor3f(200.0/255.0, 195.0/255.0, 145.0/255.0); //make the color Dark Blue
glVertex2f(0.15, 0.17);
glVertex2f(0.15, 0.6);
glVertex2f(0.10, 0.6);
glVertex2f(0.10, 0.17);
glEnd();
//pondasi_atas
glBegin(GL_POLYGON);
glColor3f(1.0, 1.0, 1.0); //make the color Dark Blue
glVertex2f(-0.18, 0.6);
glVertex2f(-0.18, 0.7);
glVertex2f(0.18, 0.7);
glVertex2f(0.18, 0.6);
glEnd();
//kotak di pondasi_atas
glBegin(GL_POLYGON);
glColor3f(0.0, 0.0, 0.0); //make the color Dark Blue
glVertex2f(-0.1, 0.62);
glVertex2f(-0.1, 0.69);
glVertex2f(0.1, 0.69);
glVertex2f(0.1, 0.62);
glEnd();
//kotak unnes
glBegin(GL_POLYGON);
glColor3f(1.0, 1.0, 1.0); //make the color Dark Blue
glVertex2f(-0.14, 0.7);
glVertex2f(-0.14, 0.73);
glVertex2f(0.14, 0.73);
glVertex2f(0.14, 0.7);
glEnd();
//bagian atas
glBegin(GL_POLYGON);
glColor3f(1.0, 1.0, 1.0); //make the color Dark Blue
glVertex2f(-0.06, 0.73);
glVertex2f(-0.04, 0.77);
glVertex2f(0.04, 0.77);
glVertex2f(0.06, 0.73);
glEnd();
//jalan
glBegin(GL_POLYGON);
glColor3f(1.0, 1.0, 1.0); //make the color Dark Blue
glVertex2f(-0.20, -0.034);
glVertex2f(-0.30, -1);
glVertex2f(0.30, -1);
glVertex2f(0.20, -0.034);
glEnd();
//jalan tengah
glBegin(GL_POLYGON);
glColor3f(180.0/255.0, 195.0/255.0, 14.0/255.0); //make the color Dark Blue
glVertex2f(-0.07, -0.045);
glVertex2f(-0.15, -0.8);
glVertex2f(0.15, -0.8);
glVertex2f(0.08, -0.045);
glEnd();
//pohon1
//batang
glBegin(GL_POLYGON);
glColor3f(108.0/255.0, 51.0/255.0, 18.0/255.0); //make the color Dark Blue
glVertex2f(0.33, -0.85);
glVertex2f(0.33, -1);
glVertex2f(0.43, -1);
glVertex2f(0.43, -0.85);
glEnd();
//daun
glBegin(GL_TRIANGLES);
glColor3f(0.0, 1.0, 0.0); //make the color Dark Blue
glVertex2f(0.55, -0.85);
glVertex2f(0.21, -0.85);
glVertex2f(0.38, -0.67);
glEnd();
glBegin(GL_TRIANGLES);
glColor3f(0.0, 1.0, 0.0); //make the color Dark Blue
glVertex2f(0.50, -0.75);
glVertex2f(0.26, -0.75);
glVertex2f(0.38, -0.5);
glEnd();
//pohon2
//batang
glBegin(GL_POLYGON);
glColor3f(108.0/255.0, 51.0/255.0, 18.0/255.0); //make the color Dark Blue
glVertex2f(-0.33, -0.85);
glVertex2f(-0.33, -1);
glVertex2f(-0.43, -1);
glVertex2f(-0.43, -0.85);
glEnd();
//daun
glBegin(GL_TRIANGLES);
glColor3f(0.0, 1.0, 0.0); //make the color Dark Blue
glVertex2f(-0.55, -0.85);
glVertex2f(-0.21, -0.85);
glVertex2f(-0.38, -0.67);
glEnd();
glBegin(GL_TRIANGLES);
glColor3f(0.0, 1.0, 0.0); //make the color Dark Blue
glVertex2f(-0.50, -0.75);
glVertex2f(-0.26, -0.75);
glVertex2f(-0.38, -0.5);
glEnd();
//pohon3
//batang
glBegin(GL_POLYGON);
glColor3f(108.0/255.0, 51.0/255.0, 18.0/255.0); //make the color Dark Blue
glVertex2f(-0.27, -0.33);
glVertex2f(-0.27, -0.48);
glVertex2f(-0.37, -0.48);
glVertex2f(-0.37, -0.33);
glEnd();
//daun
glBegin(GL_TRIANGLES);
glColor3f(0.0, 1.0, 0.0); //make the color Dark Blue
glVertex2f(-0.49, -0.33);
glVertex2f(-0.15 , -0.33);
glVertex2f(-0.32, -0.15);
glEnd();
glBegin(GL_TRIANGLES);
glColor3f(0.0, 1.0, 0.0); //make the color Dark Blue
glVertex2f(-0.44, -0.23);
glVertex2f(-0.2, -0.23);
glVertex2f(-0.32, 0.02);
glEnd();
//pohon4
//batang
glBegin(GL_POLYGON);
glColor3f(108.0/255.0, 51.0/255.0, 18.0/255.0); //make the color Dark Blue
glVertex2f(0.27, -0.33);
glVertex2f(0.27, -0.48);
glVertex2f(0.37, -0.48);
glVertex2f(0.37, -0.33);
glEnd();
//daun
glBegin(GL_TRIANGLES);
glColor3f(0.0, 1.0, 0.0); //make the color Dark Blue
glVertex2f(0.49, -0.33);
glVertex2f(0.15 , -0.33);
glVertex2f(0.32, -0.15);
glEnd();
glBegin(GL_TRIANGLES);
glColor3f(0.0, 1.0, 0.0); //make the color Dark Blue
glVertex2f(0.44, -0.23);
glVertex2f(0.2, -0.23);
glVertex2f(0.32, 0.02);
glEnd();
//coba
//U
glBegin(GL_POLYGON);
glColor3f(1.0f, 1.0f, -1.0f); //make the color Dark Blue
glVertex2f(-0.18, 0.085);
glVertex2f(-0.18, 0.14);
glVertex2f(-0.175, 0.14);
glVertex2f(-0.175, 0.085);
glEnd();
glBegin(GL_POLYGON);
glColor3f(1.0f, 1.0f, -1.0f); //make the color Dark Blue
glVertex2f(-0.13, 0.085);
glVertex2f(-0.13, 0.14);
glVertex2f(-0.125, 0.14);
glVertex2f(-0.125, 0.085);
glEnd();
glBegin(GL_POLYGON);
glColor3f(0.0, 1.0, 0.0); //make the color Dark Blue
glVertex2f(-0.18, 0.095);
glVertex2f(-0.18, 0.085);
glVertex2f(-0.125, 0.085);
glVertex2f(-0.125, 0.095);
glEnd();
//N
glBegin(GL_POLYGON);
glColor3f(0.0, 1.0, 0.0); //make the color Dark Blue
glVertex2f(-0.10, 0.085);
glVertex2f(-0.10, 0.14);
glVertex2f(-0.095, 0.14);
glVertex2f(-0.095, 0.085);
glEnd();
glBegin(GL_POLYGON);
glColor3f(1.0f, 1.0f, -1.0f); //make the color Dark Blue
glVertex2f(-0.05, 0.085);
glVertex2f(-0.10, 0.14);
glVertex2f(-0.055, 0.14);
glVertex2f(-0.055, 0.085);
glEnd();
glBegin(GL_POLYGON);
glColor3f(0.0, 1.0, 0.0); //make the color Dark Blue
glVertex2f(-0.05, 0.085);
glVertex2f(-0.05, 0.14);
glVertex2f(-0.055, 0.14);
glVertex2f(-0.055, 0.085);
glEnd();
//N
glBegin(GL_POLYGON);
glColor3f(0.0, 1.0, 0.0); //make the color Dark Blue
glVertex2f(-0.02, 0.085);
glVertex2f(-0.02, 0.14);
glVertex2f(-0.025, 0.14);
glVertex2f(-0.025, 0.085);
glEnd();
glBegin(GL_POLYGON);
glColor3f(1.0f, 1.0f, -1.0f); //make the color Dark Blue
glVertex2f(0.03, 0.085);
glVertex2f(-0.02, 0.14);
glVertex2f(0.025, 0.14);
glVertex2f(0.025, 0.085);
glEnd();
glBegin(GL_POLYGON);
glColor3f(0.0, 1.0, 0.0); //make the color Dark Blue
glVertex2f(0.03, 0.085);
glVertex2f(0.03, 0.14);
glVertex2f(0.025, 0.14);
glVertex2f(0.025, 0.085);
glEnd();
//E
glBegin(GL_POLYGON);
glColor3f(0.0, 1.0, 0.0); //make the color Dark Blue
glVertex2f(0.055, 0.085);
glVertex2f(0.055, 0.14);
glVertex2f(0.065, 0.14);
glVertex2f(0.065, 0.085);
glEnd();
glBegin(GL_POLYGON);
glColor3f(1.0f, 1.0f, -1.0f); //make the color Dark Blue
glVertex2f(0.06, 0.087);
glVertex2f(0.06, 0.09);
glVertex2f(0.10, 0.09);
glVertex2f(0.10, 0.087);
glEnd();
glBegin(GL_POLYGON);
glColor3f(1.0f, 1.0f, -1.0f); //make the color Dark Blue
glVertex2f(0.06, 0.137);
glVertex2f(0.06, 0.14);
glVertex2f(0.10, 0.14);
glVertex2f(0.10, 0.137);
glEnd();
glBegin(GL_POLYGON);
glColor3f(1.0f, 1.0f, -1.0f); //make the color Dark Blue
glVertex2f(0.06, 0.117);
glVertex2f(0.06, 0.12);
glVertex2f(0.10, 0.12);
glVertex2f(0.10, 0.117);
glEnd();
//S
glBegin(GL_POLYGON);
glColor3f(1.0f, 1.0f, -1.0f); //make the color Dark Blue
glVertex2f(0.13, 0.105);
glVertex2f(0.13, 0.14);
glVertex2f(0.145, 0.14);
glVertex2f(0.145, 0.105);
glEnd();
glBegin(GL_POLYGON);
glColor3f(1.0f, 1.0f, -1.0f); //make the color Dark Blue
glVertex2f(0.16, 0.085);
glVertex2f(0.16, 0.11);
glVertex2f(0.175, 0.11);
glVertex2f(0.175, 0.085);
glEnd();
glBegin(GL_POLYGON);
glColor3f(0.0, 1.0, 0.0); //make the color Dark Blue
glVertex2f(0.13, 0.087);
glVertex2f(0.13, 0.09);
glVertex2f(0.17, 0.09);
glVertex2f(0.17, 0.087);
glEnd();
glBegin(GL_POLYGON);
glColor3f(0.0, 1.0, 0.0); //make the color Dark Blue
glVertex2f(0.13, 0.135);
glVertex2f(0.13, 0.14);
glVertex2f(0.17, 0.14);
glVertex2f(0.17, 0.135);
glEnd();
glBegin(GL_POLYGON);
glColor3f(0.0, 1.0, 0.0); //make the color Dark Blue
glVertex2f(0.13, 0.109);
glVertex2f(0.13, 0.112);
glVertex2f(0.17, 0.112);
glVertex2f(0.17, 0.109);
glEnd();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(700,700);
glutInitWindowPosition(0,0);
glutCreateWindow("unnes konservasi");
glutDisplayFunc(mydisplay);
glutMainLoop();
}
void Draw() {
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_LINES);
glVertex3f(0.2, 0.2, 0.0);
glVertex3f(0.8, 0.2, 0.0);
glVertex3f(0.2, 0.5, 0.0);
glVertex3f(0.8, 0.5, 0.0);
glVertex3f(0.2, 0.8, 0.0);
glVertex3f(0.8, 0.8, 0.0);
glEnd();
glFlush();
}
Output Program :
Author: Mohammad
Mohammad is the founder of STC Network which offers Web Services and Online Business Solutions to clients around the globe. Read More →
Related Posts:
Grafika
Langganan:
Posting Komentar (Atom)
0 komentar: