2019年3月14日 星期四

郁峰的筆記

CASE.1

先到 http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/ 下載

將windows壓縮檔解壓縮 >> glut32.dll 移到windows資料夾
>>data 解壓縮到windows資料夾


點開Transformation .exe>>完成



CASE.2

打開glut >> 修改程式碼>>

#include <GL/glut.h>
void display(){
    glPushMatrix();     ///備份矩陣
        glTranslatef(0.3,0.3,0);    移動茶壺(x,y,z);
        glutSolidTeapot(0.3);
    glPopMatrix();     ///還原矩陣
    glutSwapBuffers();
}
int main(int argc,char**argv){
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
    glutCreateWindow("我是郁峰");
    glutDisplayFunc(display);
    glutMainLoop();

}



延伸: 用滑鼠移動茶壺
#include <GL/glut.h>
float x=0, y=0;
void display(){
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
    glPushMatrix();
        glTranslatef((x-150)/150.0,-(y-150)/150.0,0);   ///小畫家座標
        glutSolidTeapot(0.3);
    glPopMatrix();
    glutSwapBuffers();
}

void motion(int nowX, int nowY){  ///滑鼠motion函式(新的變數)
    x=nowX; y=nowY;
    display(); ///馬上更新display函式
}
int main(int argc,char**argv){
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
    glutCreateWindow("我是郁峰");
    glutDisplayFunc(display);
    glutMotionFunc(motion); ///滑鼠motion>>移動
    glutMainLoop();

}


沒有留言:

張貼留言