Tampilkan postingan dengan label Multimedia. Tampilkan semua postingan
Tampilkan postingan dengan label Multimedia. Tampilkan semua postingan

Membuat Animasi TV di Visual Studio C++

Nah, ini postingan pertama di blog munan. Belajar Itu Mudah, Berbagi itu Indah

Sahabat belajar, bagaimana kabarnya nih yang suka programming? Ada yang suka nonton TV? Nah, mumpung admin juga lagi belajar programming. Admin kan jurusannya RPL (Rekayasa Perangkat Lunak). Tiap hari harus pusing-pusing dengan sintaks banyak banget. haha.

Pas banget, pak guru ngasih tugas buat animasi TV nih.
Hitung-hitung ingin berbagi juga sih, kaya slogan blog munan ini

Berikut tampilan animasi yang telah admin buat, walaupun dasarnya dari pak guru sih. Cuma edit doang. Hehehe 😄




Berikut script yang admin sudah praktekan di Visual Studio C++ 2010


#include <stdlib.h>
#include <stdio.h>
#include <GL/glut.h>
void dinding(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){ //bagian bawah tipi yang terdapat tombol
glBegin(GL_POLYGON);
glColor3f(1,1,1);
 glVertex2i(x1,y1);
 glVertex2i(x2,y2);
 glVertex2i(x3,y3);
 glVertex2i(x4,y4);
glEnd(); 
}
void bawahtipi(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){ //bagian bawah tipi yang terdapat tombol
glBegin(GL_POLYGON);
glColor3f(1,1,1);
 glVertex2i(x1,y1);
 glVertex2i(x2,y2);
 glVertex2i(x3,y3);
 glVertex2i(x4,y4);
glEnd(); 
}
void tomboltipi(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){ // tombol kotak tipi
glBegin(GL_POLYGON);
glColor3f(1,0,0);
 glVertex2i(x1,y1);
 glVertex2i(x2,y2);
 glVertex2i(x3,y3);
 glVertex2i(x4,y4);
glEnd();
}
void tomboltipibesar(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){ // tombol kotak tipi
glBegin(GL_POLYGON);
glColor3f(0,0,1);
 glVertex2i(x1,y1);
 glVertex2i(x2,y2);
 glVertex2i(x3,y3);
 glVertex2i(x4,y4);
glEnd();
}
void layartipi(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){ // layar tipi
glBegin(GL_POLYGON);
glColor3f(0,0,0);
 glVertex2i(x1,y1);
 glVertex2i(x2,y2);
 glVertex2i(x3,y3);
 glVertex2i(x4,y4);
glEnd();
}
void sisikanantipi(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_POLYGON); // sisi kanan tipi
glColor3f(0,1,0);
 glVertex2i(x1,y1);
 glVertex2i(x2,y2);
 glVertex2i(x3,y3);
 glVertex2i(x4,y4);
glEnd();
}
void sisikiritipi(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_POLYGON); // sisi kiri tipi
glColor3f(0,1,0);
 glVertex2i(x1,y1);
 glVertex2i(x2,y2);
 glVertex2i(x3,y3);
 glVertex2i(x4,y4);
glEnd();
}
void atastipi(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_POLYGON);
glColor3f(0.7,1.0f,0.7f); //atas tipi
 glVertex2i(x1,y1);
 glVertex2i(x2,y2);
 glVertex2i(x3,y3);
 glVertex2i(x4,y4);
glEnd();
}
void atastipibelakang(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_POLYGON);
glColor3f(0,1,0.5); //atas tipi
 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(1,0.8,0);
 glVertex2i(x1,y1);
 glVertex2i(x2,y2);
 glVertex2i(x3,y3);
 glVertex2i(x4,y4);
glEnd();
}
void bawahkotakmeja(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_POLYGON);
glColor3f(1,0.7,0);
 glVertex2i(x1,y1);
 glVertex2i(x2,y2);
 glVertex2i(x3,y3);
 glVertex2i(x4,y4);
glEnd();
}
void mejadepankanan(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_POLYGON); // mejadepankanan
glColor3f(0.6,0.1,0.1);
 glVertex2i(x1,y1);
 glVertex2i(x2,y2);
 glVertex2i(x3,y3);
 glVertex2i(x4,y4);
glEnd();
}
void mejadepankiri(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_POLYGON);
glColor3f(0.6,0.1,0.1);
 glVertex2i(x1,y1);
 glVertex2i(x2,y2);
 glVertex2i(x3,y3);
 glVertex2i(x4,y4);
glEnd();
}
void belakangkanan(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_LINE_LOOP);
glColor3f(1,0,0);
 glVertex2i(x1,y1);
 glVertex2i(x2,y2);
 glVertex2i(x3,y3);
 glVertex2i(x4,y4);
glEnd();
}
void belakangkiri(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_LINE_LOOP);
glColor3f(1,0,0);
 glVertex2i(x1,y1);
 glVertex2i(x2,y2);
 glVertex2i(x3,y3);
 glVertex2i(x4,y4);
glEnd();
}
void kayujendelabelakang(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_POLYGON);
glColor3f(1,0.9,0);
 glVertex2i(x1,y1);
 glVertex2i(x2,y2);
 glVertex2i(x3,y3);
 glVertex2i(x4,y4);
glEnd();
}
void kayujendela(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_POLYGON);
glColor3f(1,1,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,1,1);
 glVertex2i(x1,y1);
 glVertex2i(x2,y2);
 glVertex2i(x3,y3);
 glVertex2i(x4,y4);
glEnd();
}
void Gambarjendela1(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_POLYGON);
glColor3f(1,1,1);
 glVertex2i(x1,y1);
 glVertex2i(x2,y2);
 glVertex2i(x3,y3);
 glVertex2i(x4,y4);
glEnd();
}
void Gambarjendela2(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_POLYGON);
glColor3f(1,1,1);
 glVertex2i(x1,y1);
 glVertex2i(x2,y2);
 glVertex2i(x3,y3);
 glVertex2i(x4,y4);
glEnd();
}
void Gambarjendela3(int x1, int y1,int x2, int y2,int x3, int y3, int x4, int y4){
glBegin(GL_POLYGON);
glColor3f(1,1,1);
 glVertex2i(x1,y1);
 glVertex2i(x2,y2);
 glVertex2i(x3,y3);
 glVertex2i(x4,y4);
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
 dinding(320,-40,320,-320,-320,-320,-320,-40);
 kayujendela(125,215,125,65,315,65,315,215);
 kayujendelabelakang(125,215,130,220,310,220,315,215);
 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);
 Gambarkotakmeja(250,-200,-250,-200,-200,-50,200,-50);
 bawahkotakmeja(250,-200,-250,-200,-230,-210,230,-210);
 //mejadepankanan(120,-200,120,-230,90,-230,90,-200);
 //mejadepankiri(-120,-200,-120,-230,-90,-230,-90,-200);
 //belakangkanan(200,-50,200,-200,170,-200,170,-140);
 //belakangkiri(-200,-50,-200,-200,-170,-200,-170,-140);
 //Gambarkotakmeja(200,-50,150,-200,-150,-200,-200,-50);
bawahtipi(120,-135,120,-160,-120,-160,-120,-135);
tomboltipi(110,-145,110,-150,100,-150,100,-145);
tomboltipibesar(-50,-145,-100,-145,-100,-150,-50,-150);
layartipi(120,-135,120,50,-120,50,-120,-135);
sisikanantipi(120,-160,160,-120,160,100,120,50);
sisikiritipi(-120,-160,-160,-120,-160,100,-120,50);
atastipi(160,100,-160,100,-120,50,120,50);
atastipibelakang(160,100,-160,100,-140,120,140,120);
antena(20,190,0,110,-20,180);
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 ("Arif Munandar || 07 || XII RA");
glClearColor(0,1,1,0);
gluOrtho2D(-320., 320., -240.0, 240.0);
glutIdleFunc(display); 
glutDisplayFunc(display);
int();
glutMainLoop();
return 0;
}


Sahabat belajar, sekian ini postingan pertama admin. Semoga bermanfaat ya. Ditunggu ya komentarnya