2021年3月22日 星期一

我是鬼WEEK05

 1.先試Transformation.exe 回憶上周的移動,旋轉


2.下方案右鍵,swap交換2行觀察自轉,公轉的差別

3.解釋每行程式碼
4.-1開啟Codeblock
4-2使用之前的程式碼並加以修改
#include <GL/glut.h> 
#include <stdio.h>
float vx[2000], vy[2000];
int N=0;
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();///交換兩倍的buffers
}
void mouse(int buttin,int state,int x,int y)
{

}
void motion( int x, int y )
{///TODO2: mouse motion 在拖動它
    printf("%d %d\n",x,y);
    vx[N]=(x-150)/150.0;
    vy[N]=-(y-150)/150.0; ///把 vx, vy 的值存起來
    N++;
    display();///邊動mouse motion, 邊畫display()
}
int main(int argc, char ** argv)
{
    glutInit( &argc, argv ); ///(1) GLUT初始設定
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);///(2)顯示模式
    glutCreateWindow("08160011我是神奇的小葉同學");///(3)開窗

    glutDisplayFunc(display);///(4)等一下要顯示的函式
    glutMotionFunc( motion );///TODO2: mouse motion在動哦!!!!
    glutMainLoop();///(5)主要迴圈
}
5.利用gist.github.com可以把程式碼變成網址,貼在blog上就可以找到


=====





沒有留言:

張貼留言

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

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