2016年3月8日 星期二

Week03 呂汶佶

作業一

TRIANGLE_FAN



QUADS


QUAD_STRIP



作業二

1. 程式碼

#include<GL/glut.h>  //標頭檔
void display()
{
    glBegin(GL_POLYGON);
       glColor3f(1,1,0);//顏色
       glVertex3f(0.0,0.0,0.0);//點1
       glVertex3f(1.0,0.0,0.0);//點2
       glVertex3f(1.0,1.0,0.0);//點3
     glEnd();
   //glutSolidTeapot(0.3);
     glutSwapBuffers();
}
int main(int argc,char**argv)
{
    glutInit(&argc, argv);  //引入程式
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);  //雙視窗
    glutCreateWindow("hello 3D");  //視窗名稱
    glutDisplayFunc(display);  //展示
    glutMainLoop();
}


作業三

1.程式碼

#include<GL/glut.h>  //標頭檔
void display()
{
    glClearColor(0.5, 0.5, 1, 1);
    glClear(GL_COLOR_BUFFER_BIT);
    glBegin(GL_POLYGON);

        glColor3f(1,0,0);      glVertex3f(-1.0,0.0,0.0);//點1
        glColor3f(0 ,1,0);     glVertex3f(1.0,-1.0,0.0);//點2
        glColor3f(0 ,0,1);     glVertex3f(1.0,1.0,0.0);//點3


     glEnd();
   //glutSolidTeapot(0.3);
     glutSwapBuffers();
}
int main(int argc,char**argv)
{
    glutInit(&argc, argv);  //引入程式
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);  //雙視窗
    glutCreateWindow("APPLE PIE");  //視窗名稱
    glutDisplayFunc(display);  //展示
    glutMainLoop();
}

2.程式碼

#include<GL/glut.h>  //標頭檔
void display()
{
    glClearColor(144/255.0, 168/255.0, 56/255.0, 1);
    glClear(GL_COLOR_BUFFER_BIT);
    glBegin(GL_POLYGON);
    //glColor3f(192/255.0, 215/255.0, 107/255.0);
      glColor3ub(192, 215, 107);
        glVertex3f(-1.0,0.0,0.0);//點1
        glVertex3f(1.0,-1.0,0.0);//點2
        glVertex3f(1.0,1.0,0.0);//點3


     glEnd();
   //glutSolidTeapot(0.3);
     glutSwapBuffers();
}
int main(int argc,char**argv)
{
    glutInit(&argc, argv);  //引入程式
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);  //雙視窗
    glutCreateWindow("APPLE PIE");  //視窗名稱
    glutDisplayFunc(display);  //展示
    glutMainLoop();
}

作業四

#include<GL/glut.h>  //標頭檔
#include<stdio.h>
void mouse(int button, int state, int x, int y)
{
   if(state==GLUT_DOWN)
    printf("       glVertex3f((%d-100)/100.0,-(%d-100/100.0, 0.0);\n",x,y);
}

void display()
{
    glClearColor(144/255.0, 168/255.0, 56/255.0, 1);
    glClear(GL_COLOR_BUFFER_BIT);
    glBegin(GL_POLYGON);
    //glColor3f(192/255.0, 215/255.0, 107/255.0);
      glColor3ub(192, 215, 107);
        glVertex3f(-1.0,0.0,0.0);//點1
        glVertex3f(1.0,-1.0,0.0);//點2
        glVertex3f(1.0,1.0,0.0);//點3


     glEnd();
   //glutSolidTeapot(0.3);
     glutSwapBuffers();
}
int main(int argc,char**argv)
{
    glutInit(&argc, argv);  //引入程式
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);  //雙視窗
    glutCreateWindow("APPLE PIE");  //視窗名稱
    glutDisplayFunc(display);//展示
    glutMouseFunc(mouse);  //滑鼠
    glutMainLoop();
}



自己做圖形









沒有留言:

張貼留言