er

Berbagai Tutorial dan Info Menarik

Belajar, Berjuang, dan Bertaqwa

Friday, 5 December 2014

Acer Iconia W511

Acer Iconia W511: Acer Iconia W511. More just than a tablet this smart device give you access to your data on any of your devices, over a new twist, gives benefits of a tablet with a touch, type, and view experience. This Acer Iconia is lightweight, the battery can keep up until 18 hours.



Find this cool stuff here: http://zocko.it/LHDfs

Black Strap Watch

Black Strap Watch: Men Leather Strap Watch by 24:01. Black watch with unique design, strap made of silicon and metal case, with a date and day feature, watch that can go formal or casual way, this watch will be your next favorite watch.





Find this cool stuff here: http://zocko.it/LHDe8

Wednesday, 3 December 2014

3D Sederhana Dengan OpenGL

Gambar 3D sederhana

Source Code :


#include <stdlib.h> // standard definitions
#include <math.h> // math definitions
#include <stdio.h> // standard I/O
#include <iostream>

// include files are in a slightly different location for MacOS
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif

using namespace std;

GLuint texture[4];
GLint slices=16;
GLint stacks=16;
struct Image {
    unsigned long sizeX;
    unsigned long sizeY;
    char *data;
};
typedef struct Image Image;

static unsigned int getint(FILE *fp)
{
    int c, c1, c2, c3;

    // get 4 bytes
    c = getc(fp);
    c1 = getc(fp);
    c2 = getc(fp);
    c3 = getc(fp);

    return ((unsigned int) c) +
    (((unsigned int) c1) << 8) +
    (((unsigned int) c2) << 16) +
    (((unsigned int) c3) << 24);
}

static unsigned int getshort(FILE *fp)
{
    int c, c1;

    //get 2 bytes
    c = getc(fp);
    c1 = getc(fp);

    return ((unsigned int) c) + (((unsigned int) c1) << 8);
}

int ImageLoad(const char *filename, Image *image) {
    FILE *file;
    unsigned long size;                 // size of the image in bytes.
    unsigned long i;                    // standard counter.
    unsigned short int planes;          // number of planes in image (must be 1)
    unsigned short int bpp;             // number of bits per pixel (must be 24)
    char temp;                          // used to convert bgr to rgb color.

    // make sure the file is there.
    if ((file = fopen(filename, "rb"))==NULL) {
        printf("File Not Found : %s\n",filename);
        return 0;
    }

    // seek through the bmp header, up to the width/height:
    fseek(file, 18, SEEK_CUR);

    // No 100% errorchecking anymore!!!

    // read the width
    image->sizeX = getint (file);
    //printf("Width of %s: %lu\n", filename, image->sizeX);

    // read the height
    image->sizeY = getint (file);
    //printf("Height of %s: %lu\n", filename, image->sizeY);

    // calculate the size (assuming 24 bits or 3 bytes per pixel).
    size = image->sizeX * image->sizeY * 3;

    // read the planes
    planes = getshort(file);
    if (planes != 1) {
        printf("Planes from %s is not 1: %u\n", filename, planes);
        return 0;
    }

    // read the bpp
    bpp = getshort(file);
    if (bpp != 24) {
        printf("Bpp from %s is not 24: %u\n", filename, bpp);
        return 0;
    }

    // seek past the rest of the bitmap header.
    fseek(file, 24, SEEK_CUR);

    // read the data.
    image->data = (char *) malloc(size);
    if (image->data == NULL) {
        printf("Error allocating memory for color-corrected image data");
        return 0;
    }

    if ((i = fread(image->data, size, 1, file)) != 1) {
        printf("Error reading image data from %s.\n", filename);
        return 0;
    }

    for (i=0;i<size;i+=3) { // reverse all of the colors. (bgr -> rgb)
        temp = image->data[i];
        image->data[i] = image->data[i+2];
        image->data[i+2] = temp;
    }

    // we're done.
    return 1;
}
Image * loadTexture(const char *filename)
{
    Image *image1;
    // allocate space for texture
    image1 = (Image *) malloc(sizeof(Image));
    if (image1 == NULL) {
        printf("Error allocating space for image");
        exit(0);
    }
    if (!ImageLoad(filename, image1)) {
        exit(1);
    }
    return image1;
}

void setTexture(void)
{
    glClearColor(1., 0.0, 0.5, 0.0);
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LESS);

    Image *image1[4];

    image1[0] = loadTexture("worldmap.bmp");
    image1[1] = loadTexture("rivet_steel_1.bmp");
    image1[2] = loadTexture("test.bmp");
    image1[3] = loadTexture("black.bmp");

    glGenTextures(4, texture);
    for (int i=0; i<4; i++)
    {
        if(image1[0] == NULL)
        {
            printf("Image was not returned from loadTexture\n");
            exit(0);
        }
        glBindTexture(GL_TEXTURE_2D, texture[i]);
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
        glTexImage2D(GL_TEXTURE_2D, 0, 3, image1[i]->sizeX, image1[i]->sizeY, 0,
                     GL_RGB, GL_UNSIGNED_BYTE, image1[i]->data);
        glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    }
    glEnable(GL_TEXTURE_2D);
    glShadeModel(GL_FLAT);
}

void setMaterial()
{
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_NORMALIZE);
    glEnable(GL_COLOR_MATERIAL);

    glColorMaterial ( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ) ;
}

void setLighting()
{
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    // Create light components
    GLfloat ambientLight[] = { 0.5f, 0.5f, 0.5f, 1.0f };
    GLfloat diffuseLight[] = { 1.0f, 1.0f, 1.0f, 1.0f };
    GLfloat specularLight[] = { 1.0f, 1.0f, 1.0f, 1.0f };
    GLfloat position[] = { -2.5f, 2.0f, 3.0f, 1.0f };

    // Assign created components to GL_LIGHT0
    glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight);
    glLightfv(GL_LIGHT0, GL_SPECULAR, specularLight);
    glLightfv(GL_LIGHT0, GL_POSITION, position);
}

void setCamera(){
    // setting proyeksi kamera
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(45.0, 3.0/3.0, 1, 40);

    // setting posisi kamera
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    gluLookAt(2, 2, 2, 0, 0, 0, 0, 1, 0);
}

void drawBox(float x1,float y1,float z1, float x2, float y2, float z2)
{
    glPushMatrix();
    glBegin(GL_QUADS);
    //depan
    glTexCoord2f(0.0, 0.0);glVertex3f(x1,y1,z1);
    glTexCoord2f(1.0, 0.0);glVertex3f(x2,y1,z1);
    glTexCoord2f(1.0, 1.0);glVertex3f(x2,y2,z1);
    glTexCoord2f(0.0, 1.0);glVertex3f(x1,y2,z1);
    //atas
    glTexCoord2f(0.0, 0.0);glVertex3f(x1,y2,z1);
    glTexCoord2f(0.0, 1.0);glVertex3f(x2,y2,z1);
    glTexCoord2f(1.0, 1.0);glVertex3f(x2,y2,z2);
    glTexCoord2f(1.0, 0.0);glVertex3f(x1,y2,z2);
    //belakang
    glTexCoord2f(0.0, 0.0);glVertex3f(x1,y2,z2);
    glTexCoord2f(0.0, 1.0);glVertex3f(x2,y2,z2);
    glTexCoord2f(1.0, 1.0);glVertex3f(x2,y1,z2);
    glTexCoord2f(1.0, 0.0);glVertex3f(x1,y1,z2);
    //bawah
    glTexCoord2f(0.0, 0.0);glVertex3f(x1,y1,z2);
    glTexCoord2f(1.0, 0.0);glVertex3f(x2,y1,z2);
    glTexCoord2f(1.0, 1.0);glVertex3f(x2,y1,z1);
    glTexCoord2f(0.0, 1.0);glVertex3f(x1,y1,z1);
    //samping kiri
    glTexCoord2f(0.0, 0.0);glVertex3f(x1,y1,z1);
    glTexCoord2f(1.0, 0.0);glVertex3f(x1,y2,z1);
    glTexCoord2f(1.0, 1.0);glVertex3f(x1,y2,z2);
    glTexCoord2f(0.0, 1.0);glVertex3f(x1,y1,z2);
    //samping kanan
    glTexCoord2f(0.0, 0.0);glVertex3f(x2,y1,z1);
    glTexCoord2f(1.0, 0.0);glVertex3f(x2,y2,z1);
    glTexCoord2f(1.0, 1.0);glVertex3f(x2,y2,z2);
    glTexCoord2f(0.0, 1.0);glVertex3f(x2,y1,z2);
    glEnd();
    glPopMatrix();
}

void kunci(unsigned char key, int x, int y) {
    switch (key)
    {
        case 27 :
        case 'q':
            exit(0);
        break;
    }
    glutPostRedisplay();
}

void drawPC()
{
    glBindTexture(GL_TEXTURE_2D, texture[2]);
    drawBox(-0.5,0.0,0.5,0.5,0.7,0.45);

    glBindTexture(GL_TEXTURE_2D, texture[3]);
    drawBox(-0.55,-0.05,0.48,0.55,0.75,0.40);
    drawBox(-0.1,-0.1,0.48,0.1,-0.05,0.40);
    drawBox(-0.2,-0.15,0.6,0.2,-0.1,0.30);

       glBindTexture(GL_TEXTURE_2D, texture[2]);
    drawBox(-0.5,0.0,0.5,0.5,0.7,0.45);

    glBindTexture(GL_TEXTURE_2D, texture[3]);
    drawBox(0.55,-0.05,0.48,0.55,0.75,0.40);
    drawBox(0.1,-0.1,0.48,0.1,-0.05,0.40);
    drawBox(0.2,-0.15,0.6,0.2,-0.1,0.30);
}

void renderScene(void){
    glClearColor(1,1,1,0);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glShadeModel(GL_SMOOTH);

    glPushMatrix();
    //glTranslatef(1.0,0.50,0.12);
    glScalef(0.5,0.5,0.5);
    drawPC();
    glPopMatrix();

    /*
    //CONTOH MENGGAMBAR SPHERE
    glEnable(GL_TEXTURE_GEN_S);
    glEnable(GL_TEXTURE_GEN_T);
    glBindTexture(GL_TEXTURE_2D, texture[0]);
    glutSolidSphere(0.5,50,50);
    glDisable(GL_TEXTURE_GEN_S);
    glDisable(GL_TEXTURE_GEN_T);
    */

    // Draw a red x-axis, a green y-axis, and a blue z-axis.
    glBegin(GL_LINES);
    glColor3f(1, 0, 0); glVertex3f(0, 0, 0); glVertex3f(10, 0, 0);
    glColor3f(0, 1, 0); glVertex3f(0, 0, 0); glVertex3f(0, 10, 0);
    glColor3f(0, 0, 1); glVertex3f(0, 0, 0); glVertex3f(0, 0, 10);
    glEnd();

    glutSwapBuffers();
}

void init(){
    //setMaterial();
    setTexture();
    setLighting();
    setCamera();
}


int main(int argc, char *argv[])
{
    glutInit(&argc, argv);
    glutInitWindowSize(600,600);
    glutInitWindowPosition(100,100);
    glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB|GLUT_DEPTH);
    glutCreateWindow("Primitive Object");
    glutDisplayFunc(renderScene);
    glutKeyboardFunc(kunci);
    init();
    glutMainLoop();
    return 0;

}


Screenshot :


Monday, 24 November 2014

Bentuk Sederhana 3D dengan Opengl


Source Code :
#include <Windows.h>
#include <iostream>
#include <gl\GL.h>
#include <gl\GLU.h>
#include <gl\glut.h>
#include <math.h>

void cube()
{
//menggambar kubus dan transformasi tarnslasi ke titik 0.5 0.5 0.5 dan skala 1 1 1
glPushMatrix();
glTranslated(0.7,0.7,0.7);//cube
glScaled(0.5,0.5,0.5);
glutSolidCube(1.0);
glPopMatrix();

glPushMatrix();
glTranslated(0.7,0.7,0.7);//cube
glScaled(0.7,0.2,0.7);
glutSolidCube(1.0);
glPopMatrix();

glPushMatrix();
glTranslated(0.7,0.9,0.7);//cube
glScaled(0.5,1.0,0.5);
glutSolidCube(1.0);
glPopMatrix();



// mobil
    glPushMatrix();
    glPushMatrix();                   // body
    glScalef(2,.5,1);
    glutSolidCube(.5);
    glPopMatrix();
    glTranslatef(0,0,.25);
    glPushMatrix();
    glTranslatef(-.4,-.2,0);
    glutSolidTorus(.05,.1,8,8);       // wheel
    glTranslatef(.8,0,0);
    glutSolidTorus(.05,.1,8,8);       // wheel
    glPopMatrix();
    glTranslatef(0,0,-.5);
    glPushMatrix();
    glTranslatef(-.4,-.2,0);
    glutSolidTorus(.05,.1,8,8);       // wheel
    glTranslatef(.8,0,0);
    glutSolidTorus(.05,.1,8,8);       // wheel
    glPopMatrix();
    glPopMatrix();

    glPopMatrix();

}


void setMaterial()
{
//set properties of surfaces material
GLfloat mat_ambient[] = {0.7f,0.7f,0.7f,1.0f}; // ada 4 jenis material yang dipakai, dengan kombinasi warna tertentu
GLfloat mat_diffuse[] = {0.6f,0.6f,0.6f,1.0f};
GLfloat mat_specular[] = {1.0f,1.0f,1.0f,1.0f};
GLfloat mat_shininess[] = {50.0f};
glMaterialfv(GL_FRONT,GL_AMBIENT,mat_ambient);
glMaterialfv(GL_FRONT,GL_DIFFUSE,mat_diffuse);
glMaterialfv(GL_FRONT,GL_SPECULAR,mat_specular);
glMaterialfv(GL_FRONT,GL_SHININESS,mat_shininess);
}


void setLighting()
{
//set light sources
GLfloat lightIntensity[] = {0.7f,0.7f,0.7f,1.0f};//mensetting pencahayaan
GLfloat light_position[] = {2.0f,6.0f,3.0f,0.0f};
glLightfv(GL_LIGHT0,GL_DIFFUSE,lightIntensity);
glLightfv(GL_LIGHT0,GL_POSITION,light_position);
}


void setViewport()
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
double winHt = 1.0;//half height of the window
glOrtho(-winHt*64/48,winHt*64/48,-winHt,winHt,0.1,100.0);
}


void setCamera()
{
//set the camera
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(9.3,2.3,5.0,0,0.25,0,0.0,3.0,0.0);
}


void displayObject()
{
setMaterial();
setLighting();
setViewport();
setCamera();
//startDrawing
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
cube();//memanggil fungsi menggambar kubus
glFlush();//mengirim smua objek untuk dirender
}


int main(int argc, char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB|GLUT_DEPTH);
glutInitWindowSize(640,480);
glutInitWindowPosition(100,100);
glutCreateWindow("3d grafkom");
glutDisplayFunc(displayObject);//fungsi dari display object yang menggabungkan kubus lighting material dan kamera
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glEnable(GL_NORMALIZE);
glClearColor(1.0f,1.0f,1.0f,0.0f);
glViewport(0,0,640,480);
glutMainLoop();

}


Screenshot :

Gambar Kubus Sederhana 3D dengan Opengl


Source Code :
#include <Windows.h>
#include <iostream>
#include <gl\GL.h>
#include <gl\GLU.h>
#include <gl\glut.h>
#include <math.h>

void cube()
{
//menggambar kubus dan transformasi tarnslasi ke titik 0.5 0.5 0.5 dan skala 1 1 1
glPushMatrix();
glTranslated(0.3,0.3,0.3);//cube
glScaled(0.4,0.4,0.4);
glutSolidCube(1.0);
glPopMatrix();
}
void setMaterial()
{
//set properties of surfaces material
GLfloat mat_ambient[] = {0.7f,0.7f,0.7f,1.0f}; // ada 4 jenis material yang dipakai, dengan kombinasi warna tertentu
GLfloat mat_diffuse[] = {0.6f,0.6f,0.6f,1.0f};
GLfloat mat_specular[] = {1.0f,1.0f,1.0f,1.0f};
GLfloat mat_shininess[] = {50.0f};
glMaterialfv(GL_FRONT,GL_AMBIENT,mat_ambient);
glMaterialfv(GL_FRONT,GL_DIFFUSE,mat_diffuse);
glMaterialfv(GL_FRONT,GL_SPECULAR,mat_specular);
glMaterialfv(GL_FRONT,GL_SHININESS,mat_shininess);
}
void setLighting()
{
//set light sources
GLfloat lightIntensity[] = {0.7f,0.7f,0.7f,1.0f};//mensetting pencahayaan
GLfloat light_position[] = {2.0f,6.0f,3.0f,0.0f};
glLightfv(GL_LIGHT0,GL_DIFFUSE,lightIntensity);
glLightfv(GL_LIGHT0,GL_POSITION,light_position);
}
void setViewport()
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
double winHt = 1.0;//half height of the window
glOrtho(-winHt*64/48,winHt*64/48,-winHt,winHt,0.1,100.0);
}
void setCamera()
{
//set the camera
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(9.3,2.3,5.0,0,0.25,0,0.0,3.0,0.0);
}

void displayObject()
{
setMaterial();
setLighting();
setViewport();
setCamera();
//startDrawing
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
cube();//memanggil fungsi menggambar kubus
glFlush();//mengirim smua objek untuk dirender
}


int main(int argc, char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB|GLUT_DEPTH);
glutInitWindowSize(640,480);
glutInitWindowPosition(100,100);
glutCreateWindow("3d grafkom");
glutDisplayFunc(displayObject);//fungsi dari display object yang menggabungkan kubus lighting material dan kamera
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glEnable(GL_NORMALIZE);
glClearColor(1.0f,1.0f,1.0f,0.0f);
glViewport(0,0,640,480);
glutMainLoop();

}


Screenshot :

Tuesday, 11 November 2014

Gambar Laba-Laba Sederhana dengan OpenGL


source code :

#include <iostream>
#include <GL/glut.h>
#include <math.h>

//LINGKARAN


const double PI = 3.141592653589793;

void drawCircle(float x_tengah,float y_tengah,float radius){
    glBegin(GL_POLYGON);

    int jumlah_titik = 50;

    for (int i=0;i<=360;i++)
    {
        float sudut = i*(2*PI/jumlah_titik);
        float x = x_tengah + radius*cos(sudut);
        float y = y_tengah + radius*sin(sudut);
        glVertex2f(x,y);
    }

    glEnd();

    //sikil kanan tengah
glPushMatrix ();
glLineWidth (1.9f);
glBegin (GL_LINES);
glBegin (GL_POLYGON);
glColor3f (1.0, 1.0, 1.0);

glVertex3f (0.70, 0.00, 0.0);
glVertex3f (0.25, 0.00, 0.0);

glVertex3f (0.25, 0.00, 0.0);
glVertex3f (0.25, 0.02, 0.0);

glVertex3f (0.25, 0.02, 0.0);
glVertex3f (0.70, 0.02, 0.0);

glVertex3f (0.70, 0.02, 0.0);
glVertex3f (0.70, 0.00, 0.0);

glEnd ();

//sikil kanan atas
glPushMatrix ();
glLineWidth (1.9f);
glBegin (GL_LINES);
glBegin (GL_POLYGON);
glColor3f (1.0, 1.0, 1.0);

glVertex3f (0.60, 0.40, 0.0);
glVertex3f (0.05, 0.20, 0.0);

glVertex3f (0.05, 0.20, 0.0);
glVertex3f (0.05, 0.18, 0.0);

glVertex3f (0.05, 0.18, 0.0);
glVertex3f (0.60, 0.38, 0.0);

glVertex3f (0.60, 0.18, 0.0);
glVertex3f (0.60, 0.40, 0.0);

glEnd ();

//sikil kanan bawah
glPushMatrix ();
glLineWidth (1.9f);
glBegin (GL_LINES);
glBegin (GL_POLYGON);
glColor3f (1.0, 1.0, 1.0);

glVertex3f (0.60, -0.45, 0.0);
glVertex3f (0.05, -0.20, 0.0);

glVertex3f (0.05, -0.20, 0.0);
glVertex3f (0.05, -0.18, 0.0);

glVertex3f (0.05, -0.18, 0.0);
glVertex3f (0.60, -0.43, 0.0);

glVertex3f (0.60, -0.18, 0.0);
glVertex3f (0.60, -0.45, 0.0);

glEnd ();


//sikil kiri tengah
glPushMatrix ();
glLineWidth (1.9f);
glBegin (GL_LINES);
glBegin (GL_POLYGON);
glColor3f (1.0, 1.0, 1.0);

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

glVertex3f (-0.25, 0.00, 0.0);
glVertex3f (-0.25, 0.02, 0.0);

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

glVertex3f (-0.70, 0.02, 0.0);
glVertex3f (-0.70, 0.00, 0.0);

glEnd ();

//sikil kiri atas
glPushMatrix ();
glLineWidth (1.9f);
glBegin (GL_LINES);
glBegin (GL_POLYGON);
glColor3f (1.0, 1.0, 1.0);

glVertex3f (-0.60, 0.40, 0.0);
glVertex3f (-0.05, 0.20, 0.0);

glVertex3f (-0.05, 0.20, 0.0);
glVertex3f (-0.05, 0.18, 0.0);

glVertex3f (-0.05, 0.18, 0.0);
glVertex3f (-0.60, 0.38, 0.0);

glVertex3f (-0.60, 0.18, 0.0);
glVertex3f (-0.60, 0.40, 0.0);

glEnd ();

//sikil kiri bawah
glPushMatrix ();
glLineWidth (1.9f);
glBegin (GL_LINES);
glBegin (GL_POLYGON);
glColor3f (1.0, 1.0, 1.0);

glVertex3f (-0.60, -0.45, 0.0);
glVertex3f (-0.05, -0.20, 0.0);

glVertex3f (-0.05, -0.20, 0.0);
glVertex3f (-0.05, -0.18, 0.0);

glVertex3f (-0.05, -0.18, 0.0);
glVertex3f (-0.60, -0.43, 0.0);

glVertex3f (-0.60, -0.18, 0.0);
glVertex3f (-0.60, -0.45, 0.0);

glEnd ();

//jari kanan bawah
glPushMatrix ();
glLineWidth (1.9f);
glBegin (GL_LINES);
glBegin (GL_POLYGON);
glColor3f (1.0, 1.0, 1.0);

glVertex3f (0.60, -0.42, 0.0);
glVertex3f (0.58, -0.42, 0.0);

glVertex3f (0.58, -0.42, 0.0);
glVertex3f (0.58, -0.49, 0.0);

glVertex3f (0.58, -0.49, 0.0);
glVertex3f (0.60, -0.49, 0.0);

glVertex3f (0.60, -0.49, 0.0);
glVertex3f (0.60, -0.42, 0.0);

glEnd ();

//jari kiri bawah
glPushMatrix ();
glLineWidth (1.9f);
glBegin (GL_LINES);
glBegin (GL_POLYGON);
glColor3f (1.0, 1.0, 1.0);

glVertex3f (-0.60, -0.42, 0.0);
glVertex3f (-0.58, -0.42, 0.0);

glVertex3f (-0.58, -0.42, 0.0);
glVertex3f (-0.58, -0.49, 0.0);

glVertex3f (-0.58, -0.49, 0.0);
glVertex3f (-0.60, -0.49, 0.0);

glVertex3f (-0.60, -0.49, 0.0);
glVertex3f (-0.60, -0.42, 0.0);

glEnd ();

//jari kiri atas
glPushMatrix ();
glLineWidth (1.9f);
glBegin (GL_LINES);
glBegin (GL_POLYGON);
glColor3f (1.0, 1.0, 1.0);

glVertex3f (-0.60, 0.30, 0.0);
glVertex3f (-0.58, 0.30, 0.0);

glVertex3f (-0.58, 0.30, 0.0);
glVertex3f (-0.58, 0.39, 0.0);

glVertex3f (-0.58, 0.39, 0.0);
glVertex3f (-0.60, 0.39, 0.0);

glVertex3f (-0.60, 0.39, 0.0);
glVertex3f (-0.60, 0.30, 0.0);

glEnd ();
//jari kanan atas
glPushMatrix ();
glLineWidth (1.9f);
glBegin (GL_LINES);
glBegin (GL_POLYGON);
glColor3f (1.0, 1.0, 1.0);

glVertex3f (0.60, 0.30, 0.0);
glVertex3f (0.58, 0.30, 0.0);

glVertex3f (0.58, 0.30, 0.0);
glVertex3f (0.58, 0.39, 0.0);

glVertex3f (0.58, 0.39, 0.0);
glVertex3f (0.60, 0.39, 0.0);

glVertex3f (0.60, 0.39, 0.0);
glVertex3f (0.60, 0.30, 0.0);

glEnd ();

//jari kanan tengah
glPushMatrix ();
glLineWidth (1.9f);
glBegin (GL_LINES);
glBegin (GL_POLYGON);
glColor3f (1.0, 1.0, 1.0);

glVertex3f (0.70, 0.00, 0.0);
glVertex3f (0.68, 0.00, 0.0);

glVertex3f (0.68, 0.00, 0.0);
glVertex3f (0.68, -0.07, 0.0);

glVertex3f (0.68, -0.07, 0.0);
glVertex3f (0.70, -0.07, 0.0);

glVertex3f (0.70, -0.07, 0.0);
glVertex3f (0.70, 0.00, 0.0);

glEnd ();

//jari kiri tengah
glPushMatrix ();
glLineWidth (1.9f);
glBegin (GL_LINES);
glBegin (GL_POLYGON);
glColor3f (1.0, 1.0, 1.0);

glVertex3f (-0.70, -0.00, 0.0);
glVertex3f (-0.68, -0.00, 0.0);

glVertex3f (-0.68, -0.00, 0.0);
glVertex3f (-0.68, -0.07, 0.0);

glVertex3f (-0.68, -0.07, 0.0);
glVertex3f (-0.70, -0.07, 0.0);

glVertex3f (-0.70, -0.07, 0.0);
glVertex3f (-0.70, -0.00, 0.0);

glEnd ();

//mata kanan
glPushMatrix ();
glLineWidth (1.9f);
glBegin (GL_LINES);
glBegin (GL_POLYGON);
glColor3f (0.4, 0.4, 0.4);

glVertex3f (0.10, 0.43, 0.0);
glVertex3f (0.05, 0.43, 0.0);

glVertex3f (0.05, 0.43, 0.0);
glVertex3f (0.05, 0.45, 0.0);

glVertex3f (0.05, 0.45, 0.0);
glVertex3f (0.10, 0.45, 0.0);

glVertex3f (0.10, 0.45, 0.0);
glVertex3f (0.10, 0.43, 0.0);

glEnd ();

//mata kiri
glPushMatrix ();
glLineWidth (1.9f);
glBegin (GL_LINES);
glBegin (GL_POLYGON);
glColor3f (0.4, 0.4, 0.4);

glVertex3f (-0.10, 0.43, 0.0);
glVertex3f (-0.05, 0.43, 0.0);

glVertex3f (-0.05, 0.43, 0.0);
glVertex3f (-0.05, 0.45, 0.0);

glVertex3f (-0.05, 0.45, 0.0);
glVertex3f (-0.10, 0.45, 0.0);

glVertex3f (-0.10, 0.45, 0.0);
glVertex3f (-0.10, 0.43, 0.0);

glEnd ();

//mulut
glPushMatrix ();
glLineWidth (1.9f);
glBegin (GL_LINES);
glBegin (GL_POLYGON);
glColor3f (0.4, 0.4, 0.4);

glVertex3f (-0.02, 0.35, 0.0);
glVertex3f (0.02, 0.35, 0.0);

glVertex3f (0.02, 0.35, 0.0);
glVertex3f (0.02, 0.37, 0.0);

glVertex3f (0.02, 0.37, 0.0);
glVertex3f (-0.02, 0.37, 0.0);

glVertex3f (-0.02, 0.37, 0.0);
glVertex3f (-0.02, 0.35, 0.0);

glEnd ();
    glFlush();
}



void display() {
drawCircle(0,0,0.3);
glColor3f (255/255, 255/255, 255/255);
drawCircle(0,0.40,0.15);
}


int main(int argc, char **argv){
    glutInit(&argc,argv);
    glutInitWindowSize(800,800);
    glutInitWindowPosition(100,100);//jarak windows dari tepi monitor

    glutCreateWindow("laba-laba");
    glutDisplayFunc(display);
    glutMainLoop();//mulai render
    return 0;
}