2017年3月13日 星期一

Week 03 20170313

複習利用簡易程式碼製作茶壺
1.file
2.new
3.project
GLUT project
刪減後程式碼

加入顏色程式碼
glColor3f(149/255.0,100/255.0,20/255.0);


作業一
測試滑鼠按壓
void mouse(int button, int state ,int x, int y)
{
    printf("%d %d %d %d\n",button, state, x, y);
///測試滑鼠按壓
    glColor3f(1,x/300.0,y/300.0); 
    glutPostRedisplay();///變換顏色
}
///滑鼠按壓變換顏色函式

glutMouseFunc(mouse);
///滑鼠按壓宣告函式

測試滑鼠按壓變換顏色


作業二
測試滑鼠拖曳變換顏色
void motion(int x, int y)
{
    printf("%d %d\n",x,y);
///測式滑鼠拖曳
    glColor3f(1,x/300.0,y/300.0);
    glutPostRedisplay();///變換顏色
}
//滑鼠拖曳變換顏色函式

glutMotionFunc(motion);
///滑鼠拖曳宣告函式


作業三

畫出圓形
static void display(void)

{
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glBegin(GL_POLYGON);
        for(float angle=0;angle<3.1415926*2;angle+=0.001)
        {
            glVertex2f(cos(angle),sin(angle));
        }
        glEnd();
        glutSwapBuffers();
}
///圖形函式

沒有留言:

張貼留言