23 Maret 2015

OPENGL: Tugas 1

Untuk tugas pertama, mata kuliah Grafika Komputer (Computer Graphics) membuat logo origami burung angsa tampak depan, akan tetapi hanya menggunakan fungsi segitiga, jadi untuk pertama, kita harus menentukan bagian-bagian dan membaginya menjadi potongan segitiga-segitiga.. lalu kita menentukan koordinat, dan memetakannya..
begini hasilnya..

Untuk Sourcecode seperti ini..

int main(int argc, char *argv[])
{

    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
    glutInitWindowPosition(100, 100);
    glutInitWindowSize(480, 480);
    glutCreateWindow("Tugas Logo Burung");

    printer();
    glutDisplayFunc(renderScene);

    glutMainLoop();
    return 0;
}

void printer(void)
{
    glClearColor(1,1,1,0);
}

void renderScene(void)
{

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glBegin(GL_TRIANGLES);
    glColor3f(1,0,0);
    //1
    glVertex2f(-0.7f, 0.9f);
    glVertex2f(-0.75f, -0.3f);
    glVertex2f(-0.23f, -0.25f);
    //2
    glVertex2f(0.7f, 0.9f);
    glVertex2f(0.75f, -0.3f);
    glVertex2f(0.23f, -0.25f);
    //3
    glVertex2f(-0.55f, -0.58f);
    glVertex2f(-0.75f, -0.3f);
    glVertex2f(-0.23f, -0.25f);
    //4
    glVertex2f(0.55f, -0.58f);
    glVertex2f(0.75f, -0.3f);
    glVertex2f(0.23f, -0.25f);
    //5
    glVertex2f(-0.53f, -0.6f);
    glVertex2f(-0.2f, -0.27f);
    glVertex2f(-0.23f, -0.88f);
    //6
    glVertex2f(0.53f, -0.6f);
    glVertex2f(0.2f, -0.27f);
    glVertex2f(0.23f, -0.88f);
    //7
    glVertex2f(-0.2f, -0.9f);
    glVertex2f(0.0f, -0.7f);
    glVertex2f(0.0f, 0.35f);
    //8
    glVertex2f(0.2f, -0.9f);
    glVertex2f(0.0f, -0.7f);
    glVertex2f(0.0f, 0.35f);
    //9
    glVertex2f(-0.2f, -0.9f);
    glVertex2f(-0.11f, 0.57f);
    glVertex2f(0.0f, 0.35f);
    //10
    glVertex2f(0.2f, -0.9f);
    glVertex2f(0.11f, 0.57f);
    glVertex2f(0.0f, 0.35f);
    //11
    glVertex2f(-0.1f, 0.6f);
    glVertex2f(0.0f, 0.4f);
    glVertex2f(0.0f, 0.5f);
    //12
    glVertex2f(0.1f, 0.6f);
    glVertex2f(0.0f, 0.4f);
    glVertex2f(0.0f, 0.5f);



    glEnd();

    glutSwapBuffers();
}

Tidak ada komentar: