Membuat Bentuk Sepeda Dengan Garis

#include
#include
#define PI 3.1415926

void Display()
{
     glClear(GL_COLOR_BUFFER_BIT);
     glBegin(GL_LINE_STRIP);
     glColor3f(0,0,0);
     glVertex2f(135,95);
     glVertex2f(80,70);
     glVertex2f(115,180);
     glVertex2f(157,121);
     glEnd();

    
     glBegin(GL_LINE_STRIP);
     glColor3f(0,0,0);
     glVertex2f(163,113);
     glVertex2f(224,213);
     glVertex2f(219,225);
     glVertex2f(140,145);
     glEnd();
    
     glBegin(GL_LINE_STRIP);
     glColor3f(0,0,0);
     glVertex2f(250,150);
     glVertex2f(211,245);
     glEnd();
    
     glBegin(GL_LINE_STRIP);
     glColor3f(0,0,0);
     glVertex2f(180,250);
     glVertex2f(243,240);
     glEnd();
    
     glBegin(GL_TRIANGLES);
     glColor3f(0,0,0);
     glVertex2f(100,185);
     glVertex2f(128,180);
     glVertex2f(108,153);
     glEnd();
    
     GLint circle_points=800;
     GLint radius1=40;
     GLint radius2=55;
     GLint radius3=15;
     GLint radius4=24;
     GLint radius5=40;
     GLint radius6=55;
     GLint i;
     GLdouble theta;
     glBegin(GL_LINES);
     for(i=0;i     {
       theta = 2*PI*i/circle_points;
       glVertex2f(80+radius1*cos(theta),70+radius2*sin(theta));
       }
     for(i=0;i     {
       theta = 2*PI*i/circle_points;
       glVertex2f(150+radius3*cos(theta),100+radius4*sin(theta));
       }
     for(i=0;i     {
       theta = 2*PI*i/circle_points;
       glVertex2f(250+radius5*cos(theta),150+radius6*sin(theta));
       }
     glEnd();
     glFlush();
}
void reshape(int w,int h)
{
     glViewport(0,0,(GLsizei)w,(GLsizei)h);
     glMatrixMode(GL_PROJECTION);
     glLoadIdentity();
     gluOrtho2D(0,360,0,360);
     }
void init()
{
     glEnable (GL_LINE_SMOOTH);
     glEnable (GL_BLEND);
     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     glHint(GL_LINE_SMOOTH_HINT | GL_POLYGON_SMOOTH_HINT, GL_DONT_CARE);
     glClearColor(1,1,1,1);
     glLineWidth(2);
     glPointSize(3);
}
int main(int args,char* argv[])
{
    glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
    glutInitWindowSize(560,360);
    glutCreateWindow("Habibul Hakim [12111042]");
    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