week03筆記
到 http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/
下載data,win32,,glut32.dll,解壓縮windows,data,把data的資料夾放到windows的資料夾,把glut32.dll複製到windows。
打開windows資料夾裡面的Transformation.exe
打開codeblocks
新增一個新的project 點glut project,去這個網站https://www.transmissionzero.co.uk/software/freeglut-devel/,
然後要下載這個Download freeglut 3.0.0 for MinGW
把freeglut資料夾的lib資料夾裡的libfreeglut.a複製在把名子改成libglut32.a
打開之前week02的程式碼茶壺
#include <GL/glut.h>
void display(){
glutSolidTeapot(0.3);
glutSwapBuffers();
}
int main(int argc, char ** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("06160823");
glutDisplayFunc(display);
glutMainLoop();
}
要將茶壺往右上角移動
glTranslatef(0.2,0.2,0); //多了這一行(x,y,z)
glutSolidTeapot(0.3);
glutSwapBuffers();
但是這樣還是有問題會出現多個茶壺
所以要加上一層保護
glPushMatrix(); //這兩層是保護
glTranslatef(0.2,0.2,0);
glutSolidTeapot(0.3);
glPopMatrix(); //這兩層是保護
glutSwapBuffers();
沒有留言:
張貼留言