Assalamuallaikum Wr Wb
Selamat malam teman
Para sahabat bocahkecilts.
Dikesempatan ini saya ada sedikit coding program tentang cara membuat Animasi Televisi lewat Visual Studio C++. Emang sih ini postingan pertama saya. Tapi mudah mudahan baik.. Aminnnn
Langsung saja...
#include <stdlib.h>
#include <stdio.h>
#include <glut.h>
/*MembuatGambarTelevisi */
void Gambarkotak1(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_POLYGON);
glColor3f(0,1,0);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glEnd();
glBegin(GL_LINE_LOOP);
glColor3f(0,0,0);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glEnd();
}
void Gambarkotak1_2(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_POLYGON);
glColor3f(0,0,0);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glEnd();
}
void Gambarkotak1_3(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_POLYGON);
glColor3f(0,0,0);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glEnd();
}
void GambarPintuAsli(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_POLYGON);
glColor3f(0,0,0);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glEnd();
glBegin(GL_LINE_LOOP);
glColor3f(1,1,1);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glEnd();
}
void Gambarpintu2(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_POLYGON);
glColor3f(0,0,0);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glEnd();
glBegin(GL_LINE_LOOP);
glColor3f(0,0,0);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glEnd();
}
void Gambarkotak2(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_POLYGON);
glColor3f(0,0,0);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glEnd();
glBegin(GL_LINE_LOOP);
glColor3f(0,0,0);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glEnd();
}
void Gambarkotak3(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_POLYGON);
glColor3f(1.0f,0.6f,0.0f);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glEnd();
glBegin(GL_LINE_LOOP);
glColor3f(0,0,0);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glEnd();
}
void Gambarkotak4(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_POLYGON);
glColor3f(1.0f,0.6f,0.0f);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glEnd();
glBegin(GL_LINE_LOOP);
glColor3f(0,0,0);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glEnd();
}
void Gambarkotak5(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_POLYGON);
glColor3f(0,1,0);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glEnd();
}
void Gambarkotakmeja(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_POLYGON);
glColor3f(0.5,0.3,0);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glEnd();
glBegin(GL_LINE_LOOP);
glColor3f(0,0,0);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glEnd();
}
void Gambarkotakkaki1(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_POLYGON);
glColor3f(0.7,0.3,0);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glEnd();
glBegin(GL_LINE_LOOP);
glColor3f(0,0,0);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glEnd();
}
void Gambarkotakkaki2(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_POLYGON);
glColor3f(0.7,0.3,0);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glEnd();
glBegin(GL_LINE_LOOP);
glColor3f(0,0,0);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glEnd();
}
void Gambarkotakkaki3(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_POLYGON);
glColor3f(0.7,0.3,0);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glEnd();
glBegin(GL_LINE_LOOP);
glColor3f(0,0,0);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glEnd();
}
void Gambarkotakkaki4(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_POLYGON);
glColor3f(0.7,0.3,0);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glEnd();
glBegin(GL_LINE_LOOP);
glColor3f(0,0,0);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glEnd();
}
void GambarPINTU(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_POLYGON);
glColor3f(0,0,0);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glEnd();
glBegin(GL_LINE_LOOP);
glColor3f(1,1,1);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glEnd();
}
void GambarKarpet(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_POLYGON);
glColor3f(0.6,0,0);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glEnd();
}
void Gambarjendela(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_POLYGON);
glColor3f(1,0,0.2);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glBegin(GL_LINE_LOOP);
glColor3f(1,1,1);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glEnd();
glEnd();
}
void Gambarjendela1(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_POLYGON);
glColor3f(1,0,0.2);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glBegin(GL_LINE_LOOP);
glColor3f(1,1,1);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glEnd();
glEnd();
}
void Gambarjendela2(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_POLYGON);
glColor3f(1,0,0.2);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glBegin(GL_LINE_LOOP);
glColor3f(1,1,1);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glEnd();
glEnd();
}
void Gambarjendela3(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_POLYGON);
glColor3f(1,0,0.2);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glBegin(GL_LINE_LOOP);
glColor3f(1,1,1);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glEnd();
glEnd();
}
void antena (int x1, int y1,int x2, int y2,int x3, int y3){
glBegin(GL_LINE_STRIP);
glColor3f(0,0,0);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
}
void userdraw(void) {
// Disini tempat untuk menggambar
GambarPINTU(120,220,120,60,320,60,320,220);
GambarPintuAsli(-270,190,-270,-120,-80,-120,-80,190);
GambarKarpet(320,-100,320,-300,-320,-320,-320,-100);
Gambarjendela(300,200,300,150,230,150,230,200);
Gambarjendela1(210,200,210,150,140,150,140,200);
Gambarjendela2(300,130,300,80,230,80,230,130);
Gambarjendela3(210,130,210,80,140,80,140,130);
Gambarkotakkaki1(120,-200,120,-230,90,-230,90,-200);
Gambarkotakkaki2(-120,-200,-120,-230,-90,-230,-90,-200);
Gambarkotakkaki3(200,-50,200,-200,170,-200,170,-140);
Gambarkotakkaki4(-200,-50,-200,-200,-170,-200,-170,-140);
Gambarkotakmeja(200,-50,150,-200,-150,-200,-200,-50);
Gambarkotak1(120,-135,120,-160,-120,-160,-120,-135);
Gambarkotak1_2(110,-145,110,-150,100,-150,100,-145);
Gambarkotak1_3(-110,-145,-110,-150,-30,-150,-30,-145);
Gambarkotak2(120,-135,120,50,-120,50,-120,-135);
Gambarkotak3(120,-160,160,-120,160,100,120,50);
Gambarkotak4(-120,-160,-160,-120,-160,100,-120,50);
Gambarkotak5(160,100,-160,100,-120,50,120,50);
antena(20,190,0,100,-20,190);
glEnd();
}
void display(void) {
glClear( GL_COLOR_BUFFER_BIT);
userdraw();
glutSwapBuffers();
}
int main(int argc, char **argv){
glutInit(&argc,argv);
glutInitDisplayMode ( GLUT_DOUBLE | GLUT_RGB );
glutInitWindowPosition(100,100);
glutInitWindowSize(640,480);
glutCreateWindow ("FIRHAM | CREATIVE | STUDEN");
glClearColor(0.6,0.6,0,0);
gluOrtho2D(-320., 320., -240.0, 240.0);
glutIdleFunc(display);
glutDisplayFunc(display);
int();
glutMainLoop();
return 0;
}
Sekian dulu dipostingan pertama saya. Tunggu postingan selanjutnya..
Selamat malam.. Wassalamuallaikum wr wb
0 komentar:
Posting Komentar