Membuat Animasi Loding Windows 8 Dengan OpenGL

Share:

OpenGL
VB6
C++

how to make spiral


 

Loding Windows 8

Lingkaran
 #include “stdlib.h”
 #include “gl/glut.h”
 #include “math.h”
const double PI = 3.141592653589793;
 int i;
void back(){
 glBegin(GL_QUADS);
 glColor3f(1,1,1);
 glVertex2d (-150,150);
 glVertex2d(150,150);
 glVertex2d(150,-150);
 glVertex2d (-150,-150);
 glEnd();
 }
void lingkaran(int radius, int jumlah_titik, int x_tengah, int y_tengah) {
 glBegin(GL_POLYGON);
 for (i=0;i float sudut=i*(2*PI/jumlah_titik);
 float x=x_tengah+radius*cos(sudut);
 float y=y_tengah+radius*sin(sudut);
 glVertex2f(x,y);
 }
 glEnd();
 } 

Belajar OpenGL Membuat Animasi Loding Windows 8. Untuk Pengkodeannya kita menggunakan bahasa pemprongraman C++

Final Kode :


#include <windows.h>
#include <GL/glut.h>
#include <stdio.h>
#include <math.h> 



float a=0;

float b=0;

float x=4;

float y=4;



bool rotate=true;

bool p1=false;    bool p5=false;

bool p2=false;    bool p6=false;

bool p3=false;    bool p7=false;

bool p4=false;    bool p8=false;

bool kiri=false;

bool bawah=false;

bool bkiri=false;

bool bkanan=false;

bool move=true;

const double PI = 3.141592653589793;

int i;

void lingkaran(int jari2, int jumlah_titik, int x_tengah, int y_tengah) {

 glBegin(GL_POLYGON);

 for (i=0;i<=360;i++){

 float sudut=i*(2*PI/jumlah_titik);

 float x=x_tengah+jari2*cos(sudut);

 float y=y_tengah+jari2*sin(sudut);

 glVertex2f(x,y);

 }

 glEnd();

 }

void MeeDun(void){

glClear(GL_COLOR_BUFFER_BIT);

//glBegin(GL_LINES); 

glColor3f(1,0,0);

glVertex2f(0,-300);

glVertex2f(0,300);

glVertex2f(-300,0);

glVertex2f(300,0);

glEnd();



if(move)

{

    if(kiri)

    {

        x-=2;

    }

    if(bkiri){    y-=2,x-=2;}

    if(bawah)

    {

        y-=2;

    }

    if(bkanan){    y+=2, x-=2;}

}

if(y==4 && x==4) 

{

    kiri=true; 

    bkiri=false;

    bawah=false;

    bkanan=false;       

            p1=true; 

            p2=true;

            p3=false; 

            p4=false;

            p5=false;

            p6=false;

            p7=false;

            p8=false;

}

if(y==4 && x==0)

{

    kiri=false; 

    bkiri=true;

    bawah=false;

    bkanan=false;

            p1=true; 

            p2=true;

            p3=true; 

            p4=true;

            p5=false;

            p6=false;

            p7=false;

            p8=true;

}

if(y==0 && x==-4)

{

    kiri=false; 

    bkiri=false;

    bawah=true;

    bkanan=false;       

            p1=true; 

            p2=true;

            p3=true; 

            p4=true;

            p5=true;

            p6=true;

            p7=true;

            p8=false;

}

if(y==-4 && x==-4) 

{

    kiri=false; 

    bkiri=false;

    bawah=false;

    bkanan=true;

            p1=true; 

            p2=true;

            p3=true; 

            p4=true;

            p5=true;

            p6=true;

            p7=true;

            p8=true;

}

if(p1){

    glColor3f(0.0, 0.0, 0.0); 

    lingkaran(30,30,200,0); 

}

if(p2){

    glColor3f(0.0, 0.0, 0.0); 

    lingkaran(30,130,135,135);

}

if(p3){

    glColor3f(0.0, 0.0, 0.0);

    lingkaran(30,130,0,200); 

}

if(p4){

    glColor3f(0.0, 0.0, 0.0); 

    lingkaran(30,130,-135,135); 

}

if(p5){

    glColor3f(0.0, 0.0, 0.0); 

    lingkaran(30,130,-200,0);

}

if(p6){

    glColor3f(0.0, 0.0, 0.0); 

    lingkaran(30,130,-135,-135);

}

if(p7){

    glColor3f(0.0, 0.0, 0.0); 

    lingkaran(30,130,0,-200);

}

if(p8){

    glColor3f(0.0, 0.0, 0.0); 

    lingkaran(30,130,135,-135);

}



Sleep(90); // Kecepatan

if(rotate)

{

    glRotatef(10.0,0,0,-10); // ARAH PERPUTARAN +10 (Arah Kiri) /  -10 (Arah kanan)

}

glutPostRedisplay();

glFlush();

}



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

    glutInit(&argc,argv);

    glutInitWindowPosition(400,100);

    glutInitWindowSize(500,500);

    glutCreateWindow("REFYANDRA-141200014-1SIMB TUGAS KOMPUTER GRAFIS");

    glutDisplayFunc(MeeDun);

    glClearColor(1,1,1,1);

    gluOrtho2D(-300,300,-300,300);

//    rotate=true; 

    glutMainLoop();

    return 0;

}


https://drive.google.com/file/d/0B8xVSaE8sQviZkp4Zk04WTV5b2M/view?usp=sharing https://drive.google.com/file/d/0B8xVSaE8sQviQjJ2REZVbnVKYkU/view?usp=sharing

source:
 3D Game Engine Programming

Sekian trima kasih.
Maaf kalau artikelnya masih amburadul SETIDAKNYA MASIH BISA KEBACA. :)

ads Bottom