2021年3月22日 星期一

week05 ###

 

swap1、2行 ,觀察自轉及公轉軸的差異👀






使用滑鼠游標畫畫

(程式碼如下)
#include <GL/glut.h>
#include <stdio.h>
float vx[2000],vy[2000];
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 button,int state,int x,int y)///Mouse
{
}
void motion(int x,int y)///Mouse
{
    printf("%d %d\n",x,y);
    vx[N]=(x-150)/150.0;
    vy[N]=-(y-150)/150.0;
    N++;
    display();
}
int main(int argc,char ** argv)

{

    glutInit( &argc , argv);

    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);

    glutCreateWindow("week05 -08160050");

    glutDisplayFunc(display);
    glutMouseFunc(mouse);
    glutMotionFunc(motion);///mouse

    glutMainLoop();
}





沒有留言:

張貼留言

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

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