2016年3月14日 星期一

Week04 主題:平移/選轉/縮放

課堂作業一:作業互評票選
選出心中前5好作品(我多選了一張)


課堂作業二:利用上次圖學檔案去試玩Transformation,試著調整平移 旋轉 縮放

課堂作業三: Mouse 操作  是打看看Mouse的程式碼 讓它跑跑看

點及滑鼠左鍵,可以跑出滑鼠所在位置

課堂作業四: 寫程式寫出完美的圓形


程式碼:
#include <GL/glut.h>
#include <stdio.h>
#include <math.h>
void mouse(int button,int state,int x,int y)
{
    if(state==GLUT_DOWN)
    {
        printf("glVertex2F((%d-100)/100),-(%d-100)/100\n",x,y);
    }
}
void display()
{
    glClearColor(180/255.0,100/255.0, 55/255.0, 1);
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3ub(160,190,80);
    glPushMatrix();
    glBegin(GL_POLYGON);
    for(float angle=0;angle<3.14159265357989*2;angle+=0.1)
    {
        glVertex2f(0.2*cos(angle),0.2*sin(angle));
    }
    glEnd();
    glPopMatrix();
    glPushMatrix();

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

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

沒有留言:

張貼留言