Project Grafkom2

12 Jan

eit eitt ketemu lagi ini lanjutan dari project grafkom 1 sekarang project grafkom 2 hasil karya anak2…

langsung saja ya,,

#include <gl/glut.h>
#include <gl/gl.h>
#include <math.h>

void RenderScene (void)
{
glClear (GL_COLOR_BUFFER_BIT); //MENGHAPUS GAMBAR YANG ADA SEBELUMNYA

//Gunung
glPushMatrix();
glLineWidth (5.0f); //MEMBERI KETEBALAN PADA GARIS
glBegin (GL_TRIANGLES); // MEMBUAT SEGITIGA
glColor3f (0.3f, 0.9f, 0.9f);

glVertex3f (-1.0, -0.6, 0.0);
glVertex3f (0.0, 1, 0.0);
glVertex3f (1.0, -0.6, 0.0);

glEnd();
glPopMatrix();

//saljuĀ  pada Gunung
glPushMatrix();
glLineWidth (5.0f);
glBegin (GL_TRIANGLES);
glColor3f (1.0f, 1.0f, 1.0f);

glVertex3f (-0.07 , 0.9 , 0.0);
glVertex3f (0.0 , 1.0 , 0.0);
glVertex3f (0.07 , 0.9, 0.0);

glEnd();
glPopMatrix();

//bikin Tanah Hijau
glPushMatrix();
glColor3f (0.0f, 0.9f, 0.4f);
glRectf (-1, -1 , 1, -0.6);

glEnd();
glPopMatrix();

//bikin jalan
glPushMatrix();

glBegin (GL_POLYGON);
glColor3f (0.0f, 0.0f, 0.0f);

glVertex3f (-0.50, -0.6, 0.0);
glVertex3f (-0.65, -1, 0.0);

glVertex3f (-0.65, -1, 0.0);
glVertex3f (-0.35, -1, 0.0);

glVertex3f (-0.35, -1, 0.0);
glVertex3f (-0.50, -0.6, 0.0);

glEnd();
glPopMatrix();

//garis jalan
glPushMatrix();
glLineWidth (2.0f);
glBegin (GL_LINES);
glColor3f (1.0f, 1.0f, 1.0f);

glVertex3f (-0.50, -0.6, 0.0);
glVertex3f (-0.50, -0.64, 0.0);

glVertex3f (-0.50, -0.68, 0.0);
glVertex3f (-0.50, -0.72, 0.0);

glVertex3f (-0.50, -0.76, 0.0);
glVertex3f (-0.50, -0.80, 0.0);

glVertex3f (-0.50, -0.84, 0.0);
glVertex3f (-0.50, -0.88, 0.0);

glVertex3f (-0.50, -0.92, 0.0);
glVertex3f (-0.50, -0.96, 0.0);

glEnd();
glPopMatrix();

// warnain pohon kanan. bwh 1
glPushMatrix ();
glBegin (GL_POLYGON);
glColor3f (0.0f, 0.7f, 0.0f);

glVertex3f (-0.47, -0.28, 0.0);
glVertex3f (-0.10, -0.28, 0.0);

glVertex3f (-0.10, -0.28, 0.0);
glVertex3f (-0.22, -0.16, 0.0);

glVertex3f (-0.22, -0.16, 0.0);
glVertex3f (-0.34, -0.16, 0.0);

glVertex3f (-0.34, -0.16, 0.0);
glVertex3f (-0.47, -0.28, 0.0);

glEnd ();
glPopMatrix();

// warnain pohon kanan. bwh 2
glPushMatrix ();

glLineWidth (2.0f);
glBegin (GL_POLYGON);
glColor3f (0.0f, 0.7f, 0.0f);

glVertex3f (-0.41, -0.16, 0.0);
glVertex3f (-0.16, -0.16, 0.0);

glVertex3f (-0.16, -0.16, 0.0);
glVertex3f (-0.25, -0.04, 0.0);

glVertex3f (-0.25, -0.04, 0.0);
glVertex3f (-0.31, -0.04, 0.0);

glVertex3f (-0.31, -0.04, 0.0);
glVertex3f (-0.41, -0.16, 0.0);

glEnd ();
glPopMatrix();

//WARNAIN pohon kanan. bwh 3
glPushMatrix ();

glLineWidth (2.0f);
glBegin (GL_POLYGON);
glColor3f (0.0f, 0.7f, 0.0f);

glVertex3f (-0.19, -0.04, 0.0);
glVertex3f (-0.28, 0.2, 0.0);

glVertex3f (-0.28, 0.2, 0.0);
glVertex3f (-0.37, -0.04, 0.0);

glVertex3f (-0.37, -0.04, 0.0);
glVertex3f (-0.19, -0.04, 0.0);

glEnd ();
glPopMatrix();

//daun pohon
glPushMatrix ();
glLineWidth (1.9f);
glBegin (GL_LINES);
glColor3f (0.0f, 0.0f, 0.0f);

glVertex3f (-0.47, -0.28, 0.0);
glVertex3f (-0.10, -0.28, 0.0);

glVertex3f (-0.10, -0.28, 0.0);
glVertex3f (-0.22, -0.16, 0.0);

glVertex3f (-0.22, -0.16, 0.0);
glVertex3f (-0.16, -0.16, 0.0);

glVertex3f (-0.16, -0.16, 0.0);
glVertex3f (-0.25, -0.04, 0.0);

glVertex3f (-0.25, -0.04, 0.0);
glVertex3f (-0.19, -0.04, 0.0);

glVertex3f (-0.19, -0.04, 0.0);
glVertex3f (-0.28, 0.2, 0.0);

glVertex3f (-0.28, 0.2, 0.0);
glVertex3f (-0.37, -0.04, 0.0);

glVertex3f (-0.37, -0.04, 0.0);
glVertex3f (-0.31, -0.04, 0.0);

glVertex3f (-0.31, -0.04, 0.0);
glVertex3f (-0.41, -0.16, 0.0);

glVertex3f (-0.41, -0.16, 0.0);
glVertex3f (-0.34, -0.16, 0.0);

glVertex3f (-0.34, -0.16, 0.0);
glVertex3f (-0.47, -0.28, 0.0);

glEnd ();
glPopMatrix();

glPushMatrix ();
glColor3f (0.7f, 0.6f, 0.4f);
glRectf (-0.31, -0.64, -0.25, -0.28);

glEnd ();
glPopMatrix();

// warnain pohon kiri.bwh 1
glPushMatrix ();
glBegin (GL_POLYGON);
glColor3f (0.0f, 0.7f, 0.0f);

glVertex3f (-0.97, -0.28, 0.0);
glVertex3f (-0.60, -0.28, 0.0);

glVertex3f (-0.60, -0.28, 0.0);
glVertex3f (-0.72, -0.16, 0.0);

glVertex3f (-0.72, -0.16, 0.0);
glVertex3f (-0.84, -0.16, 0.0);

glVertex3f (-0.84, -0.16, 0.0);
glVertex3f (-0.97, -0.28, 0.0);

glEnd ();
glPopMatrix();

// warnain pohon kiri. bwh 2
glPushMatrix ();

glLineWidth (2.0f);
glBegin (GL_POLYGON);
glColor3f (0.0f, 0.7f, 0.0f);

glVertex3f (-0.91, -0.16, 0.0);
glVertex3f (-0.66, -0.16, 0.0);

glVertex3f (-0.66, -0.16, 0.0);
glVertex3f (-0.75, -0.04, 0.0);

glVertex3f (-0.75, -0.04, 0.0);
glVertex3f (-0.81, -0.04, 0.0);

glVertex3f (-0.81, -0.04, 0.0);
glVertex3f (-0.91, -0.16, 0.0);

glEnd ();
glPopMatrix();

//WARNAIN kiri. bwh 3
glPushMatrix ();

glLineWidth (2.0f);
glBegin (GL_POLYGON);
glColor3f (0.0f, 0.7f, 0.0f);

glVertex3f (-0.69, -0.04, 0.0);
glVertex3f (-0.78, 0.2, 0.0);

glVertex3f (-0.78, 0.2, 0.0);
glVertex3f (-0.87, -0.04, 0.0);

glVertex3f (-0.87, -0.04, 0.0);
glVertex3f (-0.69, -0.04, 0.0);

glEnd ();
glPopMatrix();

//daun pohon kiri
glPushMatrix ();
glLineWidth (1.9f);
glBegin (GL_LINES);
glColor3f (0.0f, 0.0f, 0.0f);

glVertex3f (-0.97, -0.28, 0.0);
glVertex3f (-0.60, -0.28, 0.0);

glVertex3f (-0.60, -0.28, 0.0);
glVertex3f (-0.72, -0.16, 0.0);

glVertex3f (-0.72, -0.16, 0.0);
glVertex3f (-0.66, -0.16, 0.0);

glVertex3f (-0.66, -0.16, 0.0);
glVertex3f (-0.75, -0.04, 0.0);

glVertex3f (-0.75, -0.04, 0.0);
glVertex3f (-0.69, -0.04, 0.0);

glVertex3f (-0.69, -0.04, 0.0);
glVertex3f (-0.78, 0.2, 0.0);
//2 atas & bawah buat PALING ATAS JANGAN DIRUBAH
glVertex3f (-0.78, 0.2, 0.0);
glVertex3f (-0.87, -0.04, 0.0);

glVertex3f (-0.87, -0.04, 0.0);
glVertex3f (-0.81, -0.04, 0.0);

glVertex3f (-0.81, -0.04, 0.0);
glVertex3f (-0.91, -0.16, 0.0);

glVertex3f (-0.91, -0.16, 0.0);
glVertex3f (-0.84, -0.16, 0.0);

glVertex3f (-0.84, -0.16, 0.0);
glVertex3f (-0.97, -0.28, 0.0);

glEnd ();
glPopMatrix();

glPopMatrix();

glPushMatrix ();
glColor3f (0.7f, 0.6f, 0.4f);
glRectf (-0.81, -0.64, -0.75, -0.28);

glEnd ();
glPopMatrix();

//batang pohon kiri
glPushMatrix ();
glLineWidth (1.9f);
glBegin (GL_LINES);
glColor3f (0.0f, 0.0f, 0.0f);

glVertex3f (-0.81, -0.28, 0.0);
glVertex3f (-0.75, -0.28, 0.0);

glVertex3f (-0.75, -0.28, 0.0);
glVertex3f (-0.75, -0.64, 0.0);

glVertex3f (-0.75, -0.64, 0.0);
glVertex3f (-0.81, -0.64, 0.0);

glVertex3f (-0.81, -0.64, 0.0);
glVertex3f (-0.81, -0.28, 0.0);

glEnd ();

//kotak rumah
glPushMatrix ();

glColor3f (1.0f, 0.9f, 0.4f);
glRectf (0.05, 0.10, 0.79, -0.64);

glEnd ();
glPopMatrix();

//ATAP
glPushMatrix();

glBegin (GL_POLYGON);
glColor3f (0.9f, 0.3f, 0.0f);
glVertex3f (0.0, 0.10, 0.0);
glVertex3f (0.84, 0.10, 0.0);

glVertex3f (0.84, 0.10, 0.0);
glVertex3f (0.74, 0.30, 0.0);

glVertex3f (0.74, 0.30, 0.0);
glVertex3f (0.10, 0.30, 0.0);

glVertex3f (0.10, 0.30, 0.0);
glVertex3f (0.0, 0.10, 0.0);

glEnd();
glPopMatrix();

//TINGKATNYA
glPushMatrix();
glBegin (GL_POLYGON);
glColor3f (1.0f, 0.9f, 0.4f);

glVertex3f (0.20, 0.30, 0.0);
glVertex3f (0.64, 0.30, 0.0);

glVertex3f (0.64, 0.30, 0.0);
glVertex3f (0.64, 0.51, 0.0);

glVertex3f (0.64, 0.51, 0.0);
glVertex3f (0.20, 0.51, 0.0);

glVertex3f (0.20, 0.51, 0.0);
glVertex3f (0.20, 0.30, 0.0);

glEnd();
glPopMatrix();

//Jendela Atas Tingkat
glPushMatrix();
glLineWidth (1.5f);
glBegin (GL_LINES);
glColor3f (0.0f, 0.0f, 0.0f);

glVertex3f (0.30, 0.35, 0.0);
glVertex3f (0.54, 0.35, 0.0);

glVertex3f (0.54, 0.35, 0.0);
glVertex3f (0.54, 0.46, 0.0);

glVertex3f (0.54, 0.46, 0.0);
glVertex3f (0.30, 0.46, 0.0);

glVertex3f (0.30, 0.46, 0.0);
glVertex3f (0.30, 0.35, 0.0);

glVertex3f (0.38, 0.46, 0.0);
glVertex3f (0.38, 0.35, 0.0);

glVertex3f (0.46, 0.46, 0.0);
glVertex3f (0.46, 0.35, 0.0);

glEnd();
glPopMatrix();

//ATAP tINGKAT
glPushMatrix();
glBegin (GL_TRIANGLES);
glColor3f (0.9f, 0.2f, 0.0f);

glVertex3f (0.15, 0.51, 0.0);
glVertex3f (0.69, 0.51, 0.0);
glVertex3f (0.42, 0.71, 0.0);

glEnd();
glPopMatrix();

//pINTU
glPushMatrix();
glBegin (GL_POLYGON);
glColor3f (0.1f, 1.0f, 0.2f);

glVertex3f (0.10, -0.63, 0.0);
glVertex3f (0.20, -0.63, 0.0);

glVertex3f (0.20, -0.63, 0.0);
glVertex3f (0.20, -0.25, 0.0);

glVertex3f (0.20, -0.25, 0.0);
glVertex3f (0.10, -0.25, 0.0);

glVertex3f (0.10, -0.25, 0.0);
glVertex3f (0.10, -0.63, 0.0);

glEnd();
glPopMatrix();

//garis pINTU
glPushMatrix();
glLineWidth (1.5f);
glBegin (GL_LINES);
glColor3f (0.0f, 0.0f, 0.0f);

glVertex3f (0.10, -0.63, 0.0);
glVertex3f (0.20, -0.63, 0.0);

glVertex3f (0.20, -0.63, 0.0);
glVertex3f (0.20, -0.25, 0.0);

glVertex3f (0.20, -0.25, 0.0);
glVertex3f (0.10, -0.25, 0.0);

glVertex3f (0.10, -0.25, 0.0);
glVertex3f (0.10, -0.63, 0.0);

glEnd();
glPopMatrix();

//POINT pintu
glPushMatrix ();
glPointSize (5.0f);
glBegin (GL_POINTS);
glColor3f (0.0f, 0.0f, 0.0f);

glVertex3f (0.18, -0.40, 0.0);

glEnd ();
glPopMatrix();

//jENDELA 1
glPushMatrix();

glLineWidth (1.5f);
glBegin (GL_LINES);
glColor3f (0.0f, 0.0f, 0.0f);

glVertex3f (0.30, -0.40, 0.0);
glVertex3f (0.30, -0.25, 0.0);

glVertex3f (0.30, -0.25, 0.0);
glVertex3f (0.45, -0.25, 0.0);

glVertex3f (0.45, -0.25, 0.0);
glVertex3f (0.45, -0.40, 0.0);

glVertex3f (0.45, -0.40, 0.0);
glVertex3f (0.30, -0.40, 0.0);

glVertex3f (0.375, -0.40, 0.0);
glVertex3f (0.375, -0.25, 0.0);

glEnd();
glPopMatrix();

//jENDELA 2
glPushMatrix();

glLineWidth (1.5f);
glBegin (GL_LINES);
glColor3f (0.0f, 0.0f, 0.0f);

glVertex3f (0.55, -0.40, 0.0);
glVertex3f (0.55, -0.25, 0.0);

glVertex3f (0.55, -0.25, 0.0);
glVertex3f (0.70, -0.25, 0.0);

glVertex3f (0.70, -0.25, 0.0);
glVertex3f (0.70, -0.40, 0.0);

glVertex3f (0.70, -0.40, 0.0);
glVertex3f (0.55, -0.40, 0.0);

glVertex3f (0.625, -0.40, 0.0);
glVertex3f (0.625, -0.25, 0.0);

glEnd();
glPopMatrix();

//batang pohon kanan
glPushMatrix ();
glTranslatef(0.5, 0.0, 0.0);
glLineWidth (1.9f);
glBegin (GL_LINES);
glColor3f (0.0f, 0.0f, 0.0f);

glVertex3f (-0.31, -0.28, 0.0);
glVertex3f (-0.25, -0.28, 0.0);

glVertex3f (-0.25, -0.28, 0.0);
glVertex3f (-0.25, -0.64, 0.0);

glVertex3f (-0.25, -0.64, 0.0);
glVertex3f (-0.31, -0.64, 0.0);

glVertex3f (-0.31, -0.64, 0.0);
glVertex3f (-0.31, -0.28, 0.0);

glEnd ();
glPopMatrix();

glFlush();
}

int main (int argc, char* argv[])
{
glutInit (&argc,argv);
glutInitWindowSize (1265,700);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGBA);
glutCreateWindow (“Presentasi Kuliah Grafika Komputer”);
glutDisplayFunc (RenderScene);
glClearColor (0.9f, 1.0f, 1.0f, 0.0f);
glutMainLoop ();
return 0;
}

tugas kelompok : rully & devi

semoga bermanfaat ^^

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: