Monday, May 21, 2018

CONTOH CODING ANIMASI 2 D BUAT SEGITIGA DAN PERSEGI PANJANG


#include<GL/glut.h>
#include<GL/gl.h>
#include<windows.h>

void init(void){
            glClearColor(1.0, 1.0, 1.0, 0.0);
            glLineWidth(1.0);
            glColor3f(1.0, 0.0, 0.0);
            glOrtho(-6,6, -6,6, -6,6);
}


void display(void){
            glClear(GL_COLOR_BUFFER_BIT);

glBegin(GL_LINES);
            glVertex2f(-5.5,0.0);
            glColor3f(1.0, 0.0, 0.0);
            glVertex2f(5.5,0.0);
glEnd();

glBegin(GL_LINES);
            glVertex2f(0.0,-5.3);
            glColor3f(1.0, 0.0, 0.0);
            glVertex2f(0.0,5.5);
glEnd();

glBegin(GL_POLYGON);
            glColor3f(-1.0, 0.0, 0.0);
            glVertex2f(-1.0,1.0);               //sebelAH KIRI
            glColor3f(-1.0, 0.0, 0.0);
            glVertex2f(-1.0,4.0);
            glColor3f(0.0, 1.0, 0.0);
            glVertex2f(-5.0,1.0);

glEnd();

glBegin(GL_POLYGON);
            glColor3f(-1.0, 0.0, 0.0);
            glVertex2f(-1.0,-1.0);
            glColor3f(-1.0, 0.0, 0.0);
            glVertex2f(-5.0,-1.0);
            glColor3f(0.0, 1.0, 0.0);
            glVertex2f(-5.0,-5.0);
            glColor3f(0.0, 1.0, 0.0);
            glVertex2f(-1.0,-5.0);

glEnd();

glBegin(GL_POLYGON);
            glColor3f(-1.0, 0.0, 0.0);
            glVertex2f(1.0,1.0);
            glColor3f(-1.0, 0.0, 0.0);
            glVertex2f(1.0,4.0);                            //sebelah kanan
            glColor3f(0.0, 1.0, 0.0);
            glVertex2f(5.0,1.0);

glEnd();

glBegin(GL_POLYGON);
            glColor3f(-1.0, 0.0, 0.0);
            glVertex2f(1.0,-1.0);
            glColor3f(-1.0, 0.0, 0.0);
            glVertex2f(5.0,-1.0);
            glColor3f(0.0, 1.0, 0.0);
            glVertex2f(5.0,-5.0);
            glColor3f(0.0, 1.0, 0.0);
            glVertex2f(1.0,-5.0);

glEnd();

            glutSwapBuffers();

}

void main(int argc,char** argv){
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowPosition(0,0);
glutInitWindowSize(1000,1000);
glutCreateWindow("Latihan 2");


init();
glutDisplayFunc(display);
glutMainLoop();

}




No comments:

Post a Comment

CONTOH CODING LINKED LIST MENGGUNAKAN BORLAND C++

CONTOH CODING LINKED LIST MENGGUNAKAN BORLAND C++ #include<stdlib.h> #include<conio.h> #include<iostream.h> struc...