2019年3月14日 星期四

Hans杜芬舒斯的邪惡圖學_week04

1.首先到小葉老師的網站下載(http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/)
2.Examples: [data]、[win32]、glut32.dll>將[win32]解壓縮> 把[data]、glut32.dll、放進[win32]資料夾 > 打開範例Transformation.exe
<glut>
step
1.在瀏覽器搜尋freeglut windows 找到mingw下載
2.在lib內找到libfreeglut.a複製一個新的改成libglut32.a
3.打開codeblocks>file>new>project>glut project
4.在視窗輸入project title設定位置為C:\Users\user\Desktop\freeglut>finish
5.點擊management窗格的檔案main.cpp,執行build and run
<滑鼠移動茶壺範例程式碼>
#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)
{
    x=nowX; y=nowY;
    display();
}
int main(int argc, char**argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("week04");
    glutDisplayFunc(display);
    glutMotionFunc(motion);

    glutMainLoop();
}

沒有留言:

張貼留言