2017年3月14日 星期二

week 04 翊帆上課筆記

hw1
作業互評, 上傳3張你覺得最好的圖,統計後加分


hw2
畫正圓
#include <GL/glut.h>
#include <math.h>
void display(void)
{
    glBegin(GL_POLYGON);
    for(float angle=0; angle <= 3.1415926 *2; angle += 0.01)
    {
        glVertex2f(cos(angle),sin(angle));
    }
    glEnd();
    glutSwapBuffers();
}
int main(int argc, char *argv[])
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("GLUT Shapes");
    glutDisplayFunc(display);
    glutMainLoop();
    return EXIT_SUCCESS;
}

hw3

加上Mouse函式

void mouse(int button,int state,int x,int y)
{
    printf("%d %d %d %d\n",button,state,x,y);   
}
點其他位置會變色

hw4

加上Motion函式


加void motion(int x,int y)
{
    glColor3f(1,x/300.0,y/300.0);
    glutPostRedisplay();
}
可以用滑鼠按著拖移來變色


hw5
會動小精靈嘴巴



沒有留言:

張貼留言