2021年3月22日 星期一

我不想出錢 Week05



[準備上課囉!]   

複習上週的內容Transformation












自轉(自己轉動)

 公轉(跟著中心點轉動)

拆解程式,從下到上讀程式



程式碼:
#include <stdio.h> 
float vx[2000], vy[2000]; ///準備一堆頂點,等一下要畫!!! 介於 -1 ~ +1
int N=0;///有N個頂點
void display()
{///我就是 等一下
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glBegin(GL_LINE_LOOP);
    for(int i=0; i<N; i++)
    {
        glVertex2f( vx[i], vy[i]);
    }
    glEnd();
    glutSwapBuffers();
}
void mouse(int buttin, int state,int x,int y)
{
}
void motion(int x,int y)
{
    printf("%d %d\n",x,y);///把頂點記起來...等一下要畫
    vx[N] = (x-150)/150.0;///很像這樣的寫法, 記錄起來...
    vy[N] = -(y-150)/150.0;
    N++;
    display();
        ///減一半,再除一半,y加負號
}
int main(int argc, char ** argv) 
{
    glutInit(&argc, argv); ///(1) GLUT初始設定
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("Week05 drawing");

    glutDisplayFunc(display);///第2週
    glutMouseFunc(mouse);///第4週 按下去、彈起來
    glutMotionFunc(motion);///第4週 mouse motion 在動(拖曳)/在畫
    glutMainLoop();
}




上傳進度:已上傳 204864 個位元組 (共 204864 個位元組)。








沒有留言:

張貼留言

Week18期末作業(橘貓的跳舞熊熊)

 期末作業(橘貓的跳舞熊熊) 影片: https://youtu.be/R89tptMaQZw 程式碼: #include <opencv/highgui.h> #include <opencv/cv.h> #include <GL/glut.h...