Kura-Kura 2D Dengan Glut Dev C++


Coding

#include
#include
#define PI 3.1415926

void Display()
{
     GLint circle_points = 15;
     GLint radius = 4;
     GLint i;
     GLdouble theta;
     glClear(GL_COLOR_BUFFER_BIT);
     /*glBegin(GL_POLYGON);
     for(i=0;i     {
       theta = 2*PI*i/circle_points;
       
       glVertex2f(39+radius*cos(theta),60+radius*sin(theta));
     }*/
     glEnd();
      
      //MEMBUAT TEMPURUNG
     glBegin(GL_POLYGON);
     glColor3f(1.5,1,0);
     glVertex2f(80,30);
     glColor3f(1.5,1,0);
     glVertex2f(125,30);
     glColor3f(1.5,1,0);
     glVertex2f(125,90);
     glColor3f(1.5,1,0);
     glVertex2f(80,90);
     
     //MEMBUAT BADAN
     glEnd();
     glBegin(GL_POLYGON);
     glColor3f(0,1,1);
     glVertex2f(75,25);
     glColor3f(0,1,1);
     glVertex2f(130,25);
     glColor3f(0,1,1);
     glVertex2f(130,30);
     glColor3f(0,1,1);
     glVertex2f(75,30);
    
    //MEMBUAT KEPALA
     glEnd();
     glBegin(GL_POLYGON);
     glColor3f(0,1,0.5);
     glVertex2f(40,30);
     glColor3f(0,1,0.5);
     glVertex2f(40,75);
     glColor3f(0,1,0.5);
     glVertex2f(70,75);
     glColor3f(0,1,0.5);
     glVertex2f(70,38);
     glColor3f(0,1,0.5);
     glVertex2f(80,38);
     glColor3f(0,1,0.5);
     glVertex2f(80,30);
     glColor3f(0,1,0.5);
     glVertex2f(50,30);
     glEnd();
     
     glBegin(GL_POLYGON);
     glColor3f(0,1,0.5);
     glVertex2f(110,20);
     glColor3f(0,1,0.5);
     glVertex2f(123,20);
     glColor3f(0,1,0.5);
     glVertex2f(123,25);
     glColor3f(0,1,0.5);
     glVertex2f(110,25);
     glEnd();
     
     glBegin(GL_POLYGON);
     //membuat badan
     glColor3f(0.5,1,0.5);
     glVertex2f(115,18);
     glColor3f(0.5,1,0.5);
     glVertex2f(115,23);
     glColor3f(0.5,1,0.5);
     glVertex2f(121,23);
     glColor3f(0.5,1,0.5);
     glVertex2f(121,25);
     glColor3f(0.5,1,0.5);
     glVertex2f(125,25);
     glColor3f(0.5,1,0.5);
     glVertex2f(125,18);
      glEnd();
     glBegin(GL_POLYGON);
     //membuat badan
     glColor3f(0,1,0.5);
     glVertex2f(72,20);
     glColor3f(0,1,0.5);
     glVertex2f(81,20);
     glColor3f(0,1,0.5);
     glVertex2f(81,25);
     glColor3f(0,1,0.5);
     glVertex2f(72,25);
     
     glEnd(); 
     glBegin(GL_POLYGON);
     glColor3f(0.5,1,0.5);
     glVertex2f(75,18);
     glColor3f(0.5,1,0.5);
     glVertex2f(75,23);
     glColor3f(0.5,1,0.5);
     glVertex2f(81,23);
     glColor3f(0.5,1,0.5);
     glVertex2f(81,25);
     glColor3f(0.5,1,0.5);
     glVertex2f(85,25);
     glColor3f(0.5,1,0.5);
     glVertex2f(85,18);
     
     glEnd();
     glBegin(GL_POLYGON);
     glColor3f(0,1,0.5);
     glVertex2f(125,22);
     glColor3f(0,1,0.5);
     glVertex2f(140,25);
     glColor3f(0,1,0.5);
     glVertex2f(125,25);
     
     glEnd();
     glBegin(GL_POLYGON);
     glColor3f(0,0,0.5);
     glVertex2f(40,40);
     glColor3f(0,0,0.5);
     glVertex2f(40,41);
     glColor3f(0,0,0.5);
     glVertex2f(60,41);
     
     glEnd();
     glBegin(GL_POLYGON);
     glColor3f(1,1,1);
     glVertex2f(37,58);
     glColor3f(1,1,1);
     glVertex2f(37,65);
     glColor3f(1,1,1);
     glVertex2f(44,65);
     glColor3f(1,1,1);
     glVertex2f(44,58);
     
     glEnd();
     glBegin(GL_POLYGON);
     glColor3f(1,1,1);
     glVertex2f(66,58);
     glColor3f(1,1,1);
     glVertex2f(66,65);
     glColor3f(1,1,1);
     glVertex2f(73,65);
     glColor3f(1,1,1);
     glVertex2f(73,58);
     
     glEnd();
     glBegin(GL_POINTS);
     glColor3f(0,0,1);
     glVertex2f(41,61);
     
     glEnd();
     glBegin(GL_POINTS);
     glColor3f(0,0,1);
     glVertex2f(68,61);
     
     glEnd();
     glBegin(GL_POLYGON);
     for(i=0;i     {
       theta = 2*PI*i/circle_points;  
       glVertex2f(90+radius*cos(theta),60+radius*sin(theta));
     }
     
     glEnd();
     glBegin(GL_POLYGON);
     for(i=0;i     {
       theta = 2*PI*i/circle_points;
       glVertex2f(100+radius*cos(theta),65+radius*sin(theta));
       }
       
     glEnd();
     glBegin(GL_POLYGON);
     for(i=0;i     {
       theta = 2*PI*i/circle_points;
       glVertex2f(85+radius*cos(theta),50+radius*sin(theta));
       }
       
     glEnd();
      glBegin(GL_POLYGON);
     for(i=0;i     {
       theta = 2*PI*i/circle_points;
       glVertex2f(110+radius*cos(theta),85+radius*sin(theta));
       }
       
     glEnd();
      glBegin(GL_POLYGON);
      for(i=0;i     {
       theta = 2*PI*i/circle_points;
       glVertex2f(85+radius*cos(theta),85+radius*sin(theta));
       }
       
     glEnd();
      glBegin(GL_POLYGON);
     for(i=0;i     {
       theta = 2*PI*i/circle_points;
       glVertex2f(88+radius*cos(theta),70+radius*sin(theta));
       }
       
     glEnd(); 
     glBegin(GL_POLYGON);
     for(i=0;i     {
       theta = 2*PI*i/circle_points;
       glVertex2f(100+radius*cos(theta),80+radius*sin(theta));
       }
       
     glEnd();
      glBegin(GL_POLYGON);
     for(i=0;i     {
       theta = 2*PI*i/circle_points;
       glVertex2f(115+radius*cos(theta),75+radius*sin(theta));
       }
       
     glEnd();
      glBegin(GL_POLYGON); 
     for(i=0;i     {
       theta = 2*PI*i/circle_points;
       glVertex2f(115+radius*cos(theta),39+radius*sin(theta));
       }
     glEnd();
      glBegin(GL_POLYGON);
     for(i=0;i     {
       theta = 2*PI*i/circle_points;
       glVertex2f(85+radius*cos(theta),35+radius*sin(theta));
       }
       
     glEnd();
      glBegin(GL_POLYGON);
     for(i=0;i     {
       theta = 2*PI*i/circle_points;
       glVertex2f(98+radius*cos(theta),40+radius*sin(theta));
       }
       
     glEnd();
      glBegin(GL_POLYGON);
     for(i=0;i     {
       theta = 2*PI*i/circle_points;
       glVertex2f(110+radius*cos(theta),55+radius*sin(theta));
       }
       
     glEnd();
      glBegin(GL_POLYGON);
     for(i=0;i     {
       theta = 2*PI*i/circle_points;
       glVertex2f(100+radius*cos(theta),50+radius*sin(theta));
       }
       
     glEnd();
      glBegin(GL_POLYGON);
     for(i=0;i     {
       theta = 2*PI*i/circle_points;
       glVertex2f(120+radius*cos(theta),60+radius*sin(theta));
       }
     glEnd();
      glFlush();
     }
     
void reshape(int w,int h)
{
     glViewport(0,0,(GLsizei)w,(GLsizei)h);
     glMatrixMode(GL_PROJECTION);
     glLoadIdentity();
     gluOrtho2D(0,160,0,120);
     }
void init()
{
     glClearColor(1,0,1,0);
     glPointSize(5);
     }
int main(int args,char* argv[])
{
    glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
    glutInitWindowSize(500,500);
    glutCreateWindow("Habibul Hakim");
    init();
    glutDisplayFunc(Display);
    glutReshapeFunc(reshape);
    glutMainLoop();
}

Post a Comment

1. Jangan lupa tinggalkan Likenya ya
2. Berkomentarlah dengan baik dan sopan

[blogger]

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget