2020年3月23日 星期一

MEEEEEEEEEEEE HW

我的程式码

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

void display()

{
    glClearColor((0/255.0),(160/255.0),(210/255.0),0.1);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glBegin(GL_POLYGON);
    glColor3f(1.0,1.0,1.0);
    glVertex2f((60-150)/150.0, - (105-150)/150.0);
    glVertex2f((60-150)/150.0, - (215-150)/150.0);
    glVertex2f((150-150)/150.0, - (260-150)/150.0);
    glVertex2f((240-150)/150.0, - (215-150)/150.0);
    glVertex2f((240-150)/150.0, - (105-150)/150.0);
    glVertex2f((150-150)/150.0, - (60-150)/150.0);
    glEnd();

    glBegin(GL_POLYGON);
    glColor3f(1.0,1.0,1.0);
    glVertex2f((150-150)/150.0, - (33-150)/150.0);
    glVertex2f((60-150)/150.0, - (105-150)/150.0);
    glVertex2f((150-150)/150.0, - (60-150)/150.0);
    glEnd();

    glBegin(GL_POLYGON);
    glColor3d((0/255.0),(160/255.0),(210/255.0));
    glVertex2f((100-150)/150.0, - (113-150)/150.0);
    glVertex2f((125-150)/150.0, - (113-150)/150.0);
    glVertex2f((125-150)/150.0, - (213-150)/150.0);
    glVertex2f((100-150)/150.0, - (213-150)/150.0);
    glEnd();

    glBegin(GL_POLYGON);
    glColor3d((0/255.0),(160/255.0),(210/255.0));
    glVertex2f((175-150)/150.0, - (113-150)/150.0);
    glVertex2f((125-150)/150.0, - (163-150)/150.0);
    glVertex2f((160-150)/150.0, - (163-150)/150.0);
    glVertex2f((210-150)/150.0, - (113-150)/150.0);
    glEnd();

    glBegin(GL_POLYGON);
    glColor3d((0/255.0),(160/255.0),(210/255.0));
    glVertex2f((160-150)/150.0, - (163-150)/150.0);
    glVertex2f((125-150)/150.0, - (163-150)/150.0);
    glVertex2f((175-150)/150.0, - (213-150)/150.0);
    glVertex2f((210-150)/150.0, - (213-150)/150.0);
    glEnd();
glutSwapBuffers();
}

void mouse(int button, int state, int x, int y)
{
    if(state==GLUT_DOWN)
    {
    printf("glVertex2f((%d-150)/150.0, - (%d-150)/150.0);\n",x,y);
    }
}

int main(int argc, char**argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("Week03");

    glutDisplayFunc(display);
    glutMouseFunc(mouse);
    glutMainLoop();
}

做出来的图✌

沒有留言:

張貼留言