1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
#include <stdafx.h>
#include <stdlib.h>
#include <windows.h>
#include <GL/glut.h>
using namespace std;
int a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;
int rumus(int x1, int y1, int x2, int y2, int x){
int y=(x*(y2-y1)+x2*y1-x1*y2)/(x2-x1);
return y;
}
void tampilkan()
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(0,0,0,0);
glLoadIdentity();
glBegin(GL_QUADS);
glColor3f(0.0,0.0,1.0);
glVertex2d(2,2);
glVertex2d(5,2);
glVertex2d(8+c,11);
glVertex2d(7+d,rumus(7,14,2,11,7+d));
glEnd();
glBegin(GL_QUADS);
glVertex2d(7+e,rumus(7,14,5,11,7+e));
glVertex2d(9+f,rumus(9,14,2,11,9+f));
glVertex2d(14+g,rumus(14,2,2,14,14+g));
glVertex2d(11+h,rumus(11,2,5,14,11+h));
glEnd();
glBegin(GL_QUADS);
glVertex2d(6+i,rumus(6,5,5,2,6+i));
glVertex2d(6+j,rumus(6,7,12,2,6+j));
glVertex2d(10+k,rumus(10,7,12,5,10+k));
glVertex2d(10+l,rumus(10,5,5,5,10+l));
glEnd();
glFlush();
Sleep(500);
if(8+c>5){
c-;}
if(7+d>2){
d-;}
if(7+e>5){
e-;}
if(9+f>2){
f-;}
if(14+g>2){
g-;}
if(11+h>5){
h-;}
if(6+i>5){
i-;}
if(6+j<12){
j++;}
if(10+k<12){
k++;}
if(10+l>5){
l-;}
}
void init (void)
{
glMatrixMode(GL_PROJECTION);
gluOrtho2D(0,16,0,16);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
int main(int argc, char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode (GLUT_SINGLE);
glutInitWindowSize (500,500); //Ukuran window
glutCreateWindow ("Morphing_Alifah 09032");
glutDisplayFunc(tampilkan);
init ();
glutIdleFunc(tampilkan);
glutMainLoop();
return 0;
}
i've checked all over and over but it still wrong
|