2021年3月22日 星期一

周球隊長

 學到如何交換大小跟旋轉

切換公轉和自轉(利用右鍵選取s)
glRotatef為自轉 glTranslatef為公轉
glBegin為車子模型 glScalef為改變大小 glTranslatef為改變左右 glRotatef為繞中心轉
紀錄滑鼠移動的位置 這個程式碼有點厲害
#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();
}
void mouse(int button,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();
}

int main(int argc, char *argv[])
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("Week05 drawing");

    glutDisplayFunc(display);
    glutMouseFunc(mouse);
    glutMotionFunc(motion);
    glutMainLoop();
}
練習期中考考題 要好好準備考試

https://120.125.80.50/GL

 

======























沒有留言:

張貼留言

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

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