2021年3月18日 星期四

嘎嘎烏拉-(電腦圖學)Week02電腦圖學homework

 #include <GL/glut.h>


#include <math.h>


void display()


{


    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


    glBegin(GL_POLYGON);


        glColor3f(244/255.0, 203/255.0, 87/255.0);


        glVertex2f(  (8-150)/50.0,   -(8-150)/50.0);


        glVertex2f((212-150)/50.0,   -(8-150)/50.0);


        glVertex2f((212-150)/50.0, -(211-150)/50.0);


        glVertex2f(  (8-150)/50.0, -(211-150)/50.0);


    glEnd(); ///¥H¤W¬O­I´º

    glBegin(GL_POLYGON);


        glColor3f(28/255.0, 16/255.0, 12/255.0);


        glVertex2f(  (51-150)/150.0,   -(70-150)/150.0);


        glVertex2f((99-150)/150.0,   -(70-150)/150.0);


        glVertex2f((99-150)/150.0, -(131-150)/150.0);


        glVertex2f(  (51-150)/150.0, -(131-150)/150.0);


    glEnd();

    glBegin(GL_POLYGON);


        glColor3f(28/255.0, 16/255.0, 12/255.0);


        glVertex2f(  (200-150)/150.0,   -(70-150)/150.0);


        glVertex2f((248-150)/150.0,   -(70-150)/150.0);


        glVertex2f((248-150)/150.0, -(131-150)/150.0);


        glVertex2f(  (200-150)/150.0, -(131-150)/150.0);


    glEnd();

    glBegin(GL_POLYGON);


        glColor3f(243/255.0, 243/255.0, 243/255.0);


        glVertex2f(  (211-150)/150.0,   -(74-150)/150.0);


        glVertex2f((231-150)/150.0,   -(74-150)/150.0);


        glVertex2f((231-150)/150.0, -(94-150)/150.0);


        glVertex2f(  (211-150)/150.0, -(94-150)/150.0);


    glEnd();

    glBegin(GL_POLYGON);


        glColor3f(243/255.0, 243/255.0, 243/255.0);


        glVertex2f(  (68-150)/150.0,   -(74-150)/150.0);


        glVertex2f((88-150)/150.0,   -(74-150)/150.0);


        glVertex2f((88-150)/150.0, -(94-150)/150.0);


        glVertex2f(  (68-150)/150.0, -(94-150)/150.0);


    glEnd();

    glBegin(GL_POLYGON);


        glColor3f(77/255.0, 62/255.0, 52/255.0);


        glVertex2f(  (51-150)/150.0,   -(122-150)/150.0);


        glVertex2f((99-150)/150.0,   -(122-150)/150.0);


        glVertex2f((99-150)/150.0, -(130-150)/150.0);


        glVertex2f(  (51-150)/150.0, -(130-150)/150.0);


    glEnd();

    glBegin(GL_POLYGON);


        glColor3f(77/255.0, 62/255.0, 52/255.0);


        glVertex2f(  (200-150)/150.0,   -(122-150)/150.0);


        glVertex2f((248-150)/150.0,   -(122-150)/150.0);


        glVertex2f((248-150)/150.0, -(130-150)/150.0);


        glVertex2f(  (200-150)/150.0, -(130-150)/150.0);


    glEnd();

    glBegin(GL_POLYGON);


        glColor3f(48/255.0, 42/255.0, 36/255.0);


        glVertex2f(  (137-150)/150.0,   -(132-150)/150.0);


        glVertex2f((163-150)/150.0,   -(132-150)/150.0);


        glVertex2f((163-150)/150.0, -(148-150)/150.0);


        glVertex2f(  (137-150)/150.0, -(148-150)/150.0);


    glEnd();

    glBegin(GL_POLYGON);


        glColor3f(255/255.0, 0/255.0, 0/255.0);


        glVertex2f(  (0-150)/150.0,   -(150-150)/150.0);


        glVertex2f((68-150)/150.0,   -(150-150)/150.0);


        glVertex2f((68-150)/150.0, -(230-150)/150.0);


        glVertex2f(  (0-150)/150.0, -(230-150)/150.0);


    glEnd();

    glBegin(GL_POLYGON);


        glColor3f(255/255.0, 0/255.0, 0/255.0);


        glVertex2f(  (233-150)/150.0,   -(150-150)/150.0);


        glVertex2f((300-150)/150.0,   -(150-150)/150.0);


        glVertex2f((300-150)/150.0, -(230-150)/150.0);


        glVertex2f(  (233-150)/150.0, -(230-150)/150.0);


    glEnd();

    glBegin(GL_POLYGON);


        glColor3f(150/255.0, 96/255.0, 109/255.0);


        glVertex2f(  (93-150)/150.0,   -(170-150)/150.0);


        glVertex2f((207-150)/150.0,   -(170-150)/150.0);


        glVertex2f((207-150)/150.0, -(217-150)/150.0);


        glVertex2f(  (93-150)/150.0, -(217-150)/150.0);


    glEnd();

    glBegin(GL_POLYGON);


        glColor3f(212/255.0, 153/255.0, 179/255.0);


        glVertex2f(  (110-150)/150.0,   -(191-150)/150.0);


        glVertex2f((190-150)/150.0,   -(191-150)/150.0);


        glVertex2f((190-150)/150.0, -(217-150)/150.0);


        glVertex2f(  (110-150)/150.0, -(217-150)/150.0);


    glEnd();

    glBegin(GL_POLYGON);


        glColor3f(150/255.0, 96/255.0, 109/255.0);


        glVertex2f(  (136-150)/150.0,   -(170-150)/150.0);


        glVertex2f((150-150)/150.0,   -(156-150)/150.0);


        glVertex2f((163-150)/150.0, -(170-150)/150.0);


    glEnd();




    glutSwapBuffers();


}




int main(int argc,char**argv)


{


    glutInit(&argc,argv);


    glutInitDisplayMode(GLUT_DOUBLE |GLUT_DEPTH);


    glutCreateWindow("08160873");


     glutDisplayFunc(display);


     glutMainLoop();


}


沒有留言:

張貼留言

距地表面160 Week11

 #include "glm.h" GLMmodel* pmodel = NULL; void drawmodel(void) {     if (!pmodel) { pmodel = glmReadOBJ("data/porsche.obj...