Minggu, 13 Juli 2014

MEMBUAT TRUCK MENGGUNAKAN OPEN GL

Malam kawan2, hari yang dingin karna hujan malam ini, hehehe
Saya akan menshare hasil project saya buat tugas UAS komgraf kemaren, berikut source codenya:

download source code nya disini.

#include 
#include 
#include "SOIL.h"

float  z_pos=-50.0f;
float sudut_y=0.0f;
float sudut_x=0.0f;

/*GLUquadricObj *pBumi;

GLuint tex_1;

GLuint texture[1];*/



void resize(int w, int h);    //mengembalikan ukuran (callback reshape)

GLfloat  source_light[]={0.30,0.30,0.30,0.50};   //pencayahaan

void resize(int w, int h)       //mengembalikan ukuran (callback reshape)
{
    if(w >= h)
        glViewport(0, 0, (GLsizei)h, (GLsizei)h);
    else
        glViewport(0, 0, (GLsizei)w, (GLsizei)w);
}

void Mobil(void)
{
 GLfloat mat_specular[]={1.0,1.0,1.0,1.0};
 GLfloat mat_shininess[]={50.0};
 GLfloat light_position[]={1.0,1.0,1.0,1.0};
 GLfloat white_light[]={1.0,1.0,1.0,1.0};

 glClearColor(0.,1.0,1.0,0.0);  //blackground
 glShadeModel(GL_SMOOTH);
 glMaterialfv(GL_FRONT,GL_SPECULAR,mat_specular);
 glMaterialfv(GL_FRONT,GL_SHININESS,mat_shininess);
 glLightfv(GL_LIGHT0,GL_POSITION,light_position);
 glLightfv(GL_LIGHT0,GL_DIFFUSE,white_light);
 glMatrixMode(GL_PROJECTION);
 gluPerspective(50.0,1.5,10.0,1000.0);
 glEnable  (GL_DEPTH_TEST);
 glPolygonMode   (GL_FRONT_AND_BACK,GL_FILL);
 glEnable  (GL_LIGHTING);
 glLightfv  (GL_LIGHT7,GL_DIFFUSE,source_light);     //pencayahaan
 glEnable  (GL_LIGHT7);
 glEnable  (GL_COLOR_MATERIAL);
 glColorMaterial (GL_FRONT_AND_BACK,GL_AMBIENT);

}

void display(void)
{

 glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
 glMatrixMode(GL_MODELVIEW);
 glLoadIdentity();

  glTranslatef(0,0,z_pos);// besar kecilnya mobil
  glRotatef(sudut_y, 0, 1, 0);
  glRotatef(sudut_x, 1, 0, 0);

   glBegin(GL_QUADS);  //ruang

        glColor3f(0.0f, 10.0f, 0.0f);
        glVertex3f(-25.0f, -5.0f, 25.0f);
        glVertex3f( 50.0f, -5.0f, 25.0f);
        glVertex3f( 50.0f, -5.0f, -25.0f);
        glVertex3f(-25.0f, -5.0f, -25.0f);
    glEnd();

   glBegin(GL_QUADS);  //bawah panjang

        glColor3f(0.0f, 0.0f, 0.0f);
        glVertex3f(-1.0f, -2.0f, 1.0f);
        glVertex3f( 25.0f, -2.0f, 1.0f);
        glVertex3f( 25.0f, -2.5f,1.0f);
        glVertex3f(-1.0f, -2.5f, 1.0f);

        glColor3f(0.0f, 0.0f, 0.0f);
        glVertex3f(-1.0f, -2.0f, -3.0f);
        glVertex3f( 25.0f, -2.0f, -3.0f);
        glVertex3f( 25.0f, -2.5f, -3.0f);
        glVertex3f(-1.0f, -2.5f, -3.0f);

        glColor3f(0.0f, 0.0f, 0.0f);
        glVertex3f(-1.0f, -2.5f, 1.0f);
        glVertex3f( 25.0f, -2.5f, 1.0f);
        glVertex3f( 25.0f, -2.5f, -3.0f);
        glVertex3f(-1.0f, -2.5f, -3.0f);

        glColor3f(0.0f, 0.0f, 0.0f);
        glVertex3f(-1.0f, -2.0f, 1.0f);
        glVertex3f( 25.0f, -2.0f, 1.0f);
        glVertex3f( 25.0f, -2.0f, -3.0f);
        glVertex3f(-1.0f, -2.0f, -3.0f);

        glColor3f(0.0f, 0.0f, 0.0f);
        glVertex3f(-1.0f, -2.0f, 1.0f);
        glVertex3f(-1.0f, -2.0f, -3.0f);
        glVertex3f(-1.0f, -2.5f, -3.0f);
        glVertex3f(-1.0f, -2.5f, 1.0f);

        glColor3f(0.0f, 0.0f, 0.0f);
        glVertex3f(25.0f, -2.0f, 1.0f);
        glVertex3f(25.0f, -2.0f, -3.0f);
        glVertex3f(25.0f, -2.5f, -3.0f);
        glVertex3f(25.0f, -2.5f, 1.0f);
    glEnd();

    glBegin(GL_QUADS);  //catokan

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(17.0f, -1.5f, 0.0f);
        glVertex3f( 20.0f, -2.0f,0.0f);
        glVertex3f(17.0f, -2.0f, 0.0f);
        glColor3f(10.0f, 10.0f, 10.0f);
        glVertex3f( 20.0f, -1.5f, 0.0f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(17.0f, -1.5f, -2.0f);
        glVertex3f( 20.0f, -2.0f, -2.0f);
        glVertex3f(17.0f, -2.0f, -2.0f);
        glVertex3f( 20.0f, -1.5f, -2.0f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(17.0f, -2.0f, 0.0f);
        glVertex3f( 20.0f, -2.0f, 0.0f);
        glVertex3f( 20.0f, -2.0f, -2.0f);
        glVertex3f(17.0f, -2.0f, -2.0f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(17.0f, -1.5f, 0.0f);
        glVertex3f( 20.0f, -1.5f, -2.0f);
        glVertex3f(17.0f, -1.5f, -2.0f);
        glColor3f(10.0f, 10.0f, 10.0f);
        glVertex3f( 20.0f, -1.5f, 0.0f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(17.0f, -1.5f, 0.0f);
        glVertex3f(17.0f, -1.5f, -2.0f);
        glVertex3f(17.0f, -2.0f, -2.0f);
        glVertex3f(17.0f, -2.0f, 0.0f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(20.0f, -1.5f, -2.0f);
        glVertex3f(20.0f, -2.0f, -2.0f);
        glVertex3f(20.0f, -2.0f, 0.0f);
        glColor3f(10.0f, 10.0f, 10.0f);
        glVertex3f(20.0f, -1.5f, 0.0f);
    glEnd();

    //glBindTexture(GL_TEXTURE_2D, tex_1);
    glBegin(GL_QUADS);  //moncong

        glColor3f(0.0f, 0.0f, 0.0f);
        glVertex3f(-1.0f, 1.0f, 2.0f);
        glVertex3f(-1.0f, -2.5f, 2.0f);
        glVertex3f(-9.0f, -2.5f, 1.5f);
        glColor3f(10.0f, 0.0f, 0.0f);
        glVertex3f(-9.0f, 0.5f, 1.5f);

        glColor3f(0.0f, 0.0f, 0.0f);
        glVertex3f(-9.0f, 0.5f, -3.5f);
        glVertex3f(-1.0f, 1.0f, -4.0f);
        glVertex3f(-1.0f, -2.5f, -4.0f);
        glVertex3f(-9.0f, -2.5f, -3.5f);

        glColor3f(0.0f, 0.0f, 0.0f);
        glVertex3f(-1.0f, -2.5f, 2.0f);
        glVertex3f( -9.0f, -2.5f, 1.5f);
        glVertex3f( -9.0f, -2.5f, -3.5f);
        glVertex3f(-1.0f, -2.5f, -4.0f);

        glColor3f(0.0f, 0.0f, 0.0f);
        glVertex3f(-1.0f, 1.0f, 2.0f);
        glVertex3f( -9.0f, 0.5f, -3.5f);
        glVertex3f(-1.0f, 1.0f, -4.0f);
        glColor3f(10.0f, 0.0f, 0.0f);
        glVertex3f( -9.0f, 0.5f, 1.5f);

        glColor3f(1.0f, 0.0f, 0.0f);
        glVertex3f( -9.0f, -2.5f, 1.5f);
        glVertex3f( -9.0f, -2.5f, -3.5f);
        glVertex3f(-9.0f, 0.5f, -3.5f);
        glColor3f(5.0f, 0.0f, 0.0f);
        glVertex3f(-9.0f, 0.5f, 1.5f);

        glColor3f(1.0f, 0.0f, 0.0f);
        glVertex3f(-1.0f, 0.5f, 2.0f);
        glVertex3f(-1.0f, -2.5f, 2.0f);
        glVertex3f(-1.0f, -2.5f, -4.0f);
        glVertex3f(-1.0f, 0.5f, -4.0f);
    glEnd();

    glBegin(GL_QUADS);  //lampu

        glColor3f(0.0f, 0.0f, 0.0f);
        glVertex3f(-9.0f, -1.5f, 1.5f);
        glVertex3f(-9.0f, -1.5f, 3.0f);
        glVertex3f(-9.0f, -2.0f, 3.0f);
        glColor3f(10.0f, 10.0f, 10.0f);
        glVertex3f(-9.0f, -2.0f, 1.5f);

        glColor3f(0.0f, 0.0f, 0.0f);
        glVertex3f(-9.0f, -1.5f, -5.0f);
        glVertex3f(-9.0f, -1.5f, -3.5f);
        glVertex3f(-9.0f, -2.0f, -3.5f);
        glColor3f(10.0f, 10.0f, 10.0f);
        glVertex3f(-9.0f, -2.0f, -5.0f);
    glEnd();

    glBegin(GL_QUADS);  //bemper

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(-9.0f, -2.5f, 3.0f);
        glVertex3f(-9.0f, -2.5f, -5.0f);
        glVertex3f(-9.0f, -3.75f, -5.0f);
        glColor3f(10.0f, 10.0f, 10.0f);
        glVertex3f(-9.0f, -3.75f, 3.0f);

        glColor3f(1.0f, 1.0f, 1.0f);   //kiri depan
        glVertex3f(-6.0f, -1.0f, 3.0f);
        glVertex3f(-6.0f, -1.0f, 1.5f);
        glVertex3f(-4.0f, -1.0f,1.5f);
        glVertex3f(-4.0f, -1.0f, 3.0f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(-7.0f, -1.25f, 3.0f);
        glVertex3f(-7.0f, -1.25f, 1.5f);
        glVertex3f(-6.0f, -1.0f,1.5f);
        glVertex3f(-6.0f, -1.0f, 3.0f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(-8.0f, -1.75f, 3.0f);
        glVertex3f(-8.0f, -1.75f, 1.5f);
        glVertex3f(-7.0f, -1.25f,1.5f);
        glVertex3f(-7.0f, -1.25f, 3.0f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(-9.0f, -2.5f, 3.0f);
        glVertex3f(-9.0f, -2.5f, 1.5f);
        glVertex3f(-8.0f, -1.75f,1.5f);
        glVertex3f(-8.0f, -1.75f, 3.0f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(-3.0f, -1.25f, 3.0f);
        glVertex3f(-3.0f, -1.25f, 1.5f);
        glVertex3f(-4.0f, -1.0f,1.5f);
        glVertex3f(-4.0f, -1.0f, 3.0f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(-2.0f, -1.75f, 3.0f);
        glVertex3f(-2.0f, -1.75f, 1.5f);
        glVertex3f(-3.0f, -1.25f,1.5f);
        glVertex3f(-3.0f, -1.25f, 3.0f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(-1.0f, -2.5f, 3.0f);
        glVertex3f(-1.0f, -2.5f, 1.5f);
        glVertex3f(-2.0f, -1.75f,1.5f);
        glVertex3f(-2.0f, -1.75f, 3.0f);

        glColor3f(1.0f, 1.0f, 1.0f);      //kanan depan
        glVertex3f(-6.0f, -1.0f, -5.0f);
        glVertex3f(-6.0f, -1.0f, -3.5f);
        glVertex3f(-4.0f, -1.0f,-3.5f);
        glVertex3f(-4.0f, -1.0f, -5.0f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(-7.0f, -1.25f, -5.0f);
        glVertex3f(-7.0f, -1.25f, -3.5f);
        glVertex3f(-6.0f, -1.0f,-3.5f);
        glVertex3f(-6.0f, -1.0f, -5.0f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(-8.0f, -1.75f, -5.0f);
        glVertex3f(-8.0f, -1.75f, -3.5f);
        glVertex3f(-7.0f, -1.25f,-3.5f);
        glVertex3f(-7.0f, -1.25f, -5.0f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(-9.0f, -2.5f, -5.0f);
        glVertex3f(-9.0f, -2.5f, -3.5f);
        glVertex3f(-8.0f, -1.75f,-3.5f);
        glVertex3f(-8.0f, -1.75f, -5.0f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(-3.0f, -1.25f, -5.0f);
        glVertex3f(-3.0f, -1.25f, -3.5f);
        glVertex3f(-4.0f, -1.0f,-3.5f);
        glVertex3f(-4.0f, -1.0f, -5.0f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(-2.0f, -1.75f, -5.0f);
        glVertex3f(-2.0f, -1.75f, -3.5f);
        glVertex3f(-3.0f, -1.25f,-3.5f);
        glVertex3f(-3.0f, -1.25f, -5.0f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(-1.0f, -2.5f, -5.0f);
        glVertex3f(-1.0f, -2.5f, -3.5f);
        glVertex3f(-2.0f, -1.75f,-3.5f);
        glVertex3f(-2.0f, -1.75f, -5.0f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(25.0f, -2.0f, 3.0f);
        glVertex3f(25.0f, -2.0f, 1.0f);
        glVertex3f(25.0f, -3.75f, 1.0f);
        glVertex3f(25.0f, -3.75f, 3.0f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(25.0f, -2.0f, -3.0f);
        glVertex3f(25.0f, -2.0f, -5.0f);
        glVertex3f(25.0f, -3.75f, -5.0f);
        glVertex3f(25.0f, -3.75f, -3.0f);

        glColor3f(1.0f, 1.0f, 1.0f);   //kiri belakang
        glVertex3f(12.0f, -1.0f, 3.0f);
        glVertex3f(12.0f, -1.0f, 1.0f);
        glVertex3f(22.0f, -1.0f,1.0f);
        glVertex3f(22.0f, -1.0f, 3.0f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(11.0f, -1.25f, 3.0f);
        glVertex3f(11.0f, -1.25f, 1.0f);
        glVertex3f(12.0f, -1.0f,1.0f);
        glVertex3f(12.0f, -1.0f, 3.0f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(10.0f, -1.75f, 3.0f);
        glVertex3f(10.0f, -1.75f, 1.0f);
        glVertex3f(11.0f, -1.25f,1.0f);
        glVertex3f(11.0f, -1.25f, 3.0f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(9.0f, -2.5f, 3.0f);
        glVertex3f(9.0f, -2.5f, 1.0f);
        glVertex3f(10.0f, -1.75f,1.0f);
        glVertex3f(10.0f, -1.75f, 3.0f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(23.0f, -1.25f, 3.0f);
        glVertex3f(23.0f, -1.25f, 1.0f);
        glVertex3f(22.0f, -1.0f,1.0f);
        glVertex3f(22.0f, -1.0f, 3.0f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(24.0f, -1.75f, 3.0f);
        glVertex3f(24.0f, -1.75f, 1.0f);
        glVertex3f(23.0f, -1.25f,1.0f);
        glVertex3f(23.0f, -1.25f, 3.0f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(25.0f, -2.5f, 3.0f);
        glVertex3f(25.0f, -2.5f, 1.0f);
        glVertex3f(24.0f, -1.75f,1.0f);
        glVertex3f(24.0f, -1.75f, 3.0f);

        glColor3f(1.0f, 1.0f, 1.0f);   //kanan belakang
        glVertex3f(12.0f, -1.0f, -5.0f);
        glVertex3f(12.0f, -1.0f, -3.0f);
        glVertex3f(22.0f, -1.0f,-3.0f);
        glVertex3f(22.0f, -1.0f, -5.0f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(11.0f, -1.25f, -5.0f);
        glVertex3f(11.0f, -1.25f, -3.0f);
        glVertex3f(12.0f, -1.0f,-3.0f);
        glVertex3f(12.0f, -1.0f, -5.0f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(10.0f, -1.75f, -5.0f);
        glVertex3f(10.0f, -1.75f, -3.0f);
        glVertex3f(11.0f, -1.25f,-3.0f);
        glVertex3f(11.0f, -1.25f, -5.0f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(9.0f, -2.5f, -5.0f);
        glVertex3f(9.0f, -2.5f, -3.0f);
        glVertex3f(10.0f, -1.75f,-3.0f);
        glVertex3f(10.0f, -1.75f, -5.0f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(23.0f, -1.25f, -5.0f);
        glVertex3f(23.0f, -1.25f, -3.0f);
        glVertex3f(22.0f, -1.0f,-3.0f);
        glVertex3f(22.0f, -1.0f, -5.0f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(24.0f, -1.75f, -5.0f);
        glVertex3f(24.0f, -1.75f, -3.0f);
        glVertex3f(23.0f, -1.25f,-3.0f);
        glVertex3f(23.0f, -1.25f, -5.0f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(25.0f, -2.5f, -5.0f);
        glVertex3f(25.0f, -2.5f, -3.0f);
        glVertex3f(24.0f, -1.75f,-3.0f);
        glVertex3f(24.0f, -1.75f, -5.0f);
    glEnd();

    glBegin(GL_QUADS);  //kabin bawah

        glColor3f(0.0f, 0.0f, 1.0f);
        glVertex3f(-1.0f, 1.0f, 2.0f);
        glVertex3f( 3.0f, 1.0f, 2.0f);
        glVertex3f( 3.0f, -2.0f, 2.0f);
        glVertex3f(-1.0f, -2.0f, 2.0f);

        glColor3f(.0f, 0.0f, 1.0f);
        glVertex3f(-1.0f, 1.0f, -4.0f);
        glVertex3f( 3.0f, 1.0f, -4.0f);
        glVertex3f( 3.0f, -2.0f, -4.0f);
        glVertex3f(-1.0f, -2.0f, -4.0f);

        glColor3f(0.0f, 0.0f, 1.0f);
        glVertex3f(-1.0f, -2.0f, 2.0f);
        glVertex3f( 3.0f, -2.0f, 2.0f);
        glVertex3f( 3.0f, -2.0f, -4.0f);
        glVertex3f(-1.0f, -2.0f, -4.0f);

        glColor3f(0.0f, 0.0f, 1.0f);
        glVertex3f(-1.0f, 1.0f, 2.0f);
        glVertex3f( 3.0f, 1.0f, 2.0f);
        glVertex3f( 3.0f, 1.0f, -4.0f);
        glVertex3f(-1.0f, 1.0f, -4.0f);

        glColor3f(0.0f, 1.0f, 0.0f);
        glVertex3f(-1.0f, 1.0f, 2.0f);
        glVertex3f(-1.0f, 1.0f, -4.0f);
        glVertex3f(-1.0f, -2.0f, -4.0f);
        glVertex3f(-1.0f, -2.0f, 2.0f);

        glColor3f(0.0f, 1.0f, 0.0f);
        glVertex3f(3.0f, 1.0f, 2.0f);
        glVertex3f(3.0f, 1.0f, -4.0f);
        glVertex3f(3.0f, -2.0f, -4.0f);
        glVertex3f(3.0f, -2.0f, 2.0f);
    glEnd();

    glBegin(GL_QUADS);  //pijakan kaki 1

        glColor3f(10.0f, 10.0f, 10.0f);
        glVertex3f(-1.0f, -3.74f, 3.0f);
        glVertex3f( 3.0f, -3.74f, 3.0f);
        glVertex3f( 3.0f, -3.75f, 3.0f);
        glVertex3f(-1.0f, -3.75f, 3.0f);

        glColor3f(10.0f, 10.0f, 10.0f);
        glVertex3f(-1.0f, -3.74f, -5.0f);
        glVertex3f( 3.0f, -3.74f, -5.0f);
        glVertex3f( 3.0f, -3.75f, -5.0f);
        glVertex3f(-1.0f, -3.75f, -5.0f);

        glColor3f(10.0f, 10.0f, 10.0f);
        glVertex3f(-1.0f, -3.75f, 3.0f);
        glVertex3f( 3.0f, -3.75f, 3.0f);
        glVertex3f( 3.0f, -3.75f, -5.0f);
        glVertex3f(-1.0f, -3.75f, -5.0f);

        glColor3f(10.0f, 10.0f, 10.0f);
        glVertex3f(-1.0f, -3.74f, 3.0f);
        glVertex3f( 3.0f, -3.74f, 3.0f);
        glVertex3f( 3.0f, -3.74f, -5.0f);
        glVertex3f(-1.0f, -3.74f, -5.0f);

        glColor3f(10.0f, 10.0f, 10.0f);
        glVertex3f(-1.0f, -3.74f, 3.0f);
        glVertex3f(-1.0f, -3.74f, -5.0f);
        glVertex3f(-1.0f, -3.75f, -5.0f);
        glVertex3f(-1.0f, -3.75f, 3.0f);

        glColor3f(10.0f, 10.0f, 10.0f);
        glVertex3f(3.0f, -3.74f, 3.0f);
        glVertex3f(3.0f, -3.74f, -5.0f);
        glVertex3f(3.0f, -3.75f, -5.0f);
        glVertex3f(3.0f, -3.75f, 3.0f);
    glEnd();

    glBegin(GL_QUADS);  //pijakan kaki 2

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(-1.0f, -3.0f, 2.5f);
        glVertex3f( 3.0f, -3.0f, 2.5f);
        glVertex3f( 3.0f, -3.74f, 2.5f);
        glVertex3f(-1.0f, -3.74f, 2.5f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(-1.0f, -3.0f, -4.5f);
        glVertex3f( 3.0f, -3.0f, -4.5f);
        glVertex3f( 3.0f, -3.74f, -4.5f);
        glVertex3f(-1.0f, -3.74f, -4.5f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(-1.0f, -3.74f, 2.5f);
        glVertex3f( 3.0f, -3.74f, 2.5f);
        glVertex3f( 3.0f, -3.74f, -4.5f);
        glVertex3f(-1.0f, -3.74f, -4.5f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(-1.0f, -3.0f, 2.5f);
        glVertex3f( 3.0f, -3.0f, 2.5f);
        glVertex3f( 3.0f, -3.0f, -4.5f);
        glVertex3f(-1.0f, -3.0f, -4.5f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(-1.0f, -3.0f, 2.5f);
        glVertex3f(-1.0f, -3.0f, -4.5f);
        glVertex3f(-1.0f, -3.74f, -4.5f);
        glVertex3f(-1.0f, -3.74f, 2.5f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(3.0f, -3.0f, 2.5f);
        glVertex3f(3.0f, -3.0f, -4.5f);
        glVertex3f(3.0f, -3.74f, -4.5f);
        glVertex3f(3.0f, -3.74f, 2.5f);
    glEnd();

    glBegin(GL_QUADS);  //kabin atas kiri

        glColor3f(0.0f, 0.0f, 0.0f);
        glVertex3f(-0.5f, 2.0f, 2.0f);
        glVertex3f( 3.0f, 2.5f, 2.0f);
        glVertex3f( 3.0f, 1.0f, 2.0f);
        glColor3f(10.0f, 10.0f, 10.0f);
        glVertex3f(-1.0f, 1.0f, 2.0f);

        glColor3f(1.0f, 1.0f, 0.0f);
        glVertex3f(-1.0f, 2.0f, -1.0f);
        glVertex3f( 3.0f, 2.5f, -1.0f);
        glVertex3f( 3.0f, 1.0f, -1.0f);
        glVertex3f(-1.5f, 1.0f, -1.0f);

        glColor3f(0.0f, 0.0f, 1.0f);
        glVertex3f(-1.0f, 1.0f, 2.0f);
        glVertex3f( 3.0f, 1.0f, 2.0f);
        glVertex3f( 3.0f, 1.0f, -1.0f);
        glVertex3f(-1.5f, 1.0f, -1.0f);

        glColor3f(0.0f, 0.0f, 1.0f);
        glVertex3f(-0.5f, 2.0f, 2.0f);
        glVertex3f( 3.0f, 2.5f, 2.0f);
        glVertex3f( 3.0f, 2.5f, -1.0f);
        glVertex3f(-1.0f, 2.0f, -1.0f);

        glColor3f(0.0f, 0.0f, 0.0f);
        glVertex3f(-0.5f, 2.0f, 2.0f);
        glVertex3f(-1.0f, 2.0f, -1.0f);
        glVertex3f(-1.5f, 1.0f, -1.0f);
        glColor3f(10.0f, 10.0f, 10.0f);
        glVertex3f(-1.0f, 1.0f, 2.0f);

        glColor3f(0.0f, 1.0f, 0.0f);
        glVertex3f(3.0f, 2.5f, 2.0f);
        glVertex3f(3.0f, 2.5f, -1.0f);
        glVertex3f(3.0f, 1.0f, -1.0f);
        glVertex3f(3.0f, 1.0f, 2.0f);
    glEnd();

    glBegin(GL_QUADS);   //spion

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(-0.5f, 2.0f, 2.5f);
        glVertex3f(-0.5f, 1.0f, 2.5f);
        glVertex3f(-0.25f, 1.0f, 3.5f);
        glColor3f(10.0f, 10.0f, 10.0f);
        glVertex3f(-0.25f, 2.0f, 3.5f);

        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(-0.5f, 2.0f, -4.5f);
        glVertex3f(-0.5f, 1.0f, -4.5f);
        glVertex3f(-0.25f, 1.0f, -5.5f);
        glColor3f(10.0f, 10.0f, 10.0f);
        glVertex3f(-0.25f, 2.0f, -5.5f);
    glEnd();

    glBegin(GL_QUADS);  //kabin atas kanan

        glColor3f(0.0f, 0.0f, 0.0f);
        glVertex3f(-0.5f, 2.0f, -4.0f);
        glVertex3f( 3.0f, 2.5f, -4.0f);
        glVertex3f( 3.0f, 1.0f, -4.0f);
        glColor3f(10.0f, 10.0f, 10.0f);
        glVertex3f(-1.0f, 1.0f, -4.0f);

        glColor3f(1.0f, 1.0f, 0.0f);
        glVertex3f(-1.0f, 2.0f, -1.0f);
        glVertex3f( 3.0f, 2.5f, -1.0f);
        glVertex3f( 3.0f, 1.0f, -1.0f);
        glVertex3f(-1.5f, 1.0f, -1.0f);

        glColor3f(1.0f, 0.0f, 1.0f);
        glVertex3f(3.0f, 1.0f, -1.0f);
        glVertex3f(-1.5f, 1.0f, -1.0f);
        glVertex3f(-1.0f, 1.0f, -4.0f);
        glVertex3f(3.0f, 1.0f, -4.0f);

        glColor3f(0.0f, 0.0f, 1.0f);
        glVertex3f(-1.0f, 2.0f, -1.0f);
        glVertex3f( 3.0f, 2.5f, -1.0f);
        glVertex3f( 3.0f, 2.5f, -4.0f);
        glVertex3f(-0.5f, 2.0f, -4.0f);

        glColor3f(0.0f, 0.0f, 0.0f);
        glVertex3f(-0.5f, 2.0f, -4.0f);
        glVertex3f(-1.0f, 2.0f, -1.0f);
        glVertex3f(-1.5f, 1.0f, -1.0f);
        glColor3f(10.0f, 10.0f, 10.0f);
        glVertex3f(-1.0f, 1.0f, -4.0f);

        glColor3f(0.0f, 1.0f, 0.0f);
        glVertex3f(3.0f, 2.5f, -1.0f);
        glVertex3f(3.0f, 2.5f, -4.0f);
        glVertex3f(3.0f, 1.0f, -4.0f);
        glVertex3f(3.0f, 1.0f, -1.0f);
    glEnd();

     glBegin(GL_QUADS);  //kabin belakang

        glColor3f(1.0f, 0.0f, 0.0f);
        glVertex3f(3.0f, 2.5f, 3.0f);
        glVertex3f(9.0f, 2.5f, 3.0f);
        glVertex3f(9.0f, -2.0f, 3.0f);
        glVertex3f(3.0f, -2.0f, 3.0f);

        glColor3f(1.0f, 0.0f, 0.0f);
        glVertex3f(3.0f, 2.5f, -5.0f);
        glVertex3f(9.0f, 2.5f, -5.0f);
        glVertex3f(9.0f, -2.0f, -5.0f);
        glVertex3f(3.0f, -2.0f, -5.0f);

        glColor3f(0.0f, 0.0f, 1.0f);
        glVertex3f(3.0f, -2.0f, 3.0f);
        glVertex3f(9.0f, -2.0f, 3.0f);
        glVertex3f(9.0f, -2.0f, -5.0f);
        glVertex3f(3.0f, -2.0f, -5.0f);

        glColor3f(0.0f, 0.0f, 1.0f);
        glVertex3f(3.0f, 2.5f, 3.0f);
        glVertex3f(9.0f, 2.5f, 3.0f);
        glVertex3f(9.0f, 2.5f, -5.0f);
        glVertex3f(3.0f, 2.5f, -5.0f);

        glColor3f(1.0f, 0.0f, 0.0f);
        glVertex3f(3.0f, 2.5f, 3.0f);
        glVertex3f(3.0f, 2.5f, -5.0f);
        glVertex3f(3.0f, -2.0f, -5.0f);
        glVertex3f(3.0f, -2.0f, 3.0f);

        glColor3f(1.0f, 0.0f, 0.0f);
        glVertex3f(9.0f, 2.5f, 3.0f);
        glVertex3f(9.0f, 2.5f, -5.0f);
        glVertex3f(9.0f, -2.0f, -5.0f);
        glVertex3f(9.0f, -2.0f, 3.0f);
    glEnd();

    glBegin(GL_QUADS);  //kabin belakang atas

        glColor3f(1.0f, 0.0f, 0.0f);
        glVertex3f(9.0f, 3.5f, 3.0f);
        glVertex3f(9.0f, 2.5f, 3.0f);
        glVertex3f(3.0f, 2.5f, 3.0f);
        glColor3f(10.0f, 10.0f, 10.0f);
        glVertex3f(3.5f, 3.0f, 3.0f);

        glColor3f(1.0f, 0.0f, 0.0f);
        glVertex3f(3.5f, 3.0f, -5.0f);
        glVertex3f(9.0f, 3.5f, -5.0f);
        glVertex3f(9.0f, 2.5f, -5.0f);
        glVertex3f(3.0f, 2.5f, -5.0f);

        glColor3f(1.0f, 0.0f, .0f);
        glVertex3f(3.0f, 2.5f, 3.0f);
        glVertex3f(9.0f, 2.5f, 3.0f);
        glVertex3f(9.0f, 2.5f, -5.0f);
        glVertex3f(3.0f, 2.5f, -5.0f);

        glColor3f(1.0f, 0.0f, 0.0f);
        glVertex3f(9.0f, 3.5f, 3.0f);
        glVertex3f(9.0f, 3.5f, -5.0f);
        glVertex3f(3.5f, 3.0f, -5.0f);
        glColor3f(10.0f, 10.0f, 10.0f);
        glVertex3f(3.5f, 3.0f, 3.0f);

        glColor3f(1.0f, 0.0f, 0.0f);
        glVertex3f(3.5f, 3.0f, -5.0f);
        glVertex3f(3.0f, 2.5f, -5.0f);
        glVertex3f(3.0f, 2.5f, 3.0f);
        glColor3f(10.0f, 10.0f, 10.0f);
        glVertex3f(3.5f, 3.0f, 3.0f);

        glColor3f(1.0f, 0.0f, 0.0f);
        glVertex3f(9.0f, 3.5f, 3.0f);
        glVertex3f(9.0f, 3.5f, -5.0f);
        glVertex3f(9.0f, 2.5f, -5.0f);
        glVertex3f(9.0f, 2.5f, 3.0f);
    glEnd();

 glFlush();
 glutSwapBuffers();

}

void myTimeOut(int  id)
{
  // called if timer event
  // ...advance the state of animation incrementally...

 glutPostRedisplay();    // request redisplay
 glutTimerFunc(100, myTimeOut, 0);  // request next timer event
}

void myKeyboard(unsigned char key, int  x, int  y)
{
  if((key=='-')||(key=='_')) z_pos-= 1.0f;
  if((key=='=')||(key=='+')) z_pos+= 1.0f;

  if((key=='a')||(key=='A'))sudut_y+=5.0f;
  if((key=='d')||(key=='D'))sudut_y-=5.0f;

  if((key=='w')||(key=='W'))sudut_x+=5.0f;
  if((key=='s')||(key=='S'))sudut_x-=5.0f;
}

void tampil()
{
 display();
}

int main(int argc,char *argv[])
{
 glutInit(&argc,argv);
 glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA|GLUT_DEPTH);
 glutInitWindowPosition(0,0);
 glutInitWindowSize(700,700);
 glutCreateWindow("Project UAS");
 glutDisplayFunc(display);
 glutKeyboardFunc(myKeyboard);
 glutTimerFunc(100,myTimeOut, 0);
 glutReshapeFunc(resize);      //mengembalikan ukuran (callback reshape)
 Mobil();
 glutMainLoop();
 return(0);
}

/*GLuint LoadGLTexture(const char *filename)
{
    // load an image file directly as a new OpenGL texture
    GLuint tex;
    tex = SOIL_load_OGL_texture(filename, SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID,SOIL_FLAG_INVERT_Y);

    // check for an error during the load process
    if(tex == 0) {
        printf("SOIL loading error: '%s'\n", SOIL_last_result());
    }
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    return tex;
}

void init(void)
{
    tex_1 = LoadGLTexture("moncongdepan.png");

    glEnable(GL_TEXTURE_2D);
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LEQUAL);
    glShadeModel(GL_SMOOTH);

    glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
    glClearDepth(1.0f);

    pBumi = gluNewQuadric();
    gluQuadricNormals(pBumi, GLU_SMOOTH);
    gluQuadricTexture(pBumi, GL_TRUE);

}*/