2020年3月18日 星期三

week03


滑鼠點擊
可以讓茶壺移動
做出形狀來
自己做的codeblocks


#include <GL/glut.h>
#include <stdio.h>
#include <math.h>
void display()
{
    glClearColor(255/255.0, 255/255.0, 255/255.0, 1);

        glBegin(GL_POLYGON);
     glColor3f(0/255.0,0/255.0,0/255.0);
        glVertex2f( (260-150)/150.0, -(38-150)/150.0 );
        glVertex2f( (258-150)/150.0, -(235-150)/150.0 );
        glVertex2f( (48-150)/150.0, -(278-150)/150.0 );
        glVertex2f( (38-150)/150.0, -(30-150)/150.0 );

    glEnd();


    glBegin(GL_POLYGON);
     glColor3f(255/255.0,0/255.0,0/255.0);
        glVertex2f( (55-150)/150.0, -(30-150)/150.0 );
        glVertex2f( (160-150)/150.0, -(31-150)/150.0 );
        glVertex2f( (160-150)/150.0, -(145-150)/150.0 );
        glVertex2f( (59-150)/150.0, -(155-150)/150.0 );

    glEnd();

    glBegin(GL_POLYGON);
     glColor3f(0/255.0,255/255.0,0/255.0);
        glVertex2f( (177-150)/150.0, -(33-150)/150.0 );
        glVertex2f( (266-150)/150.0, -(36-150)/150.0 );
        glVertex2f( (260-150)/150.0, -(135-150)/150.0 );
        glVertex2f( (178-150)/150.0, -(142-150)/150.0 );

    glEnd();

    glBegin(GL_POLYGON);
     glColor3f(0/255.0,0/255.0,255/255.0);
        glVertex2f( (261-150)/150.0, -(148-150)/150.0 );
        glVertex2f( (259-150)/150.0, -(242-150)/150.0 );
        glVertex2f( (180-150)/150.0, -(257-150)/150.0 );
        glVertex2f( (180-150)/150.0, -(204-150)/150.0 );
        glVertex2f( (177-150)/150.0, -(156-150)/150.0 );

    glEnd();

        glBegin(GL_POLYGON);
     glColor3f(255/255.0,255/255.0,0/255.0);
        glVertex2f( (163-150)/150.0, -(260-150)/150.0 );
        glVertex2f( (158-150)/150.0, -(162-150)/150.0 );
        glVertex2f( (60-150)/150.0, -(172-150)/150.0 );
        glVertex2f( (65-150)/150.0, -(280-150)/150.0 );


    glEnd();




    glutSwapBuffers();


}
void mouse(int button, int state, int x, int y){}
int main(int argc, char**argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("Week03");
    glutDisplayFunc(display);
    glutMouseFunc(mouse);
    glutMainLoop();
}

沒有留言:

張貼留言