week03
一
step01-1 打開網頁https://jsyeh.org/3dcg10/ 下載win32.zip 以及data.zip
step01-2 解壓縮 windows至windows資料夾並且將data資料夾放入windows資料夾
step01-3 打開Tranformation.exe 嘗試使用
(右鍵切換模型)(下方可以控制)
step02-1打開上周的程式碼
step02-2
#include<GL/glut.h>
void display()
{
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glTranslatef(0.5,0.5,0);//位置
glColor3f(1,1,0);//色彩
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
int main(int argc,char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("week03移動");
glutDisplayFunc(display);
glutMainLoop();
}
step02-3 執行可看到茶壺在右上角
step02-4更改程式碼為
#include<GL/glut.h>
void myTeapot(float x,float y)
{
glPushMatrix();
glTranslatef(x,y,0);
glColor3f(1,1,0);
glutSolidTeapot(0.3);
glPopMatrix();
}
void display()
{
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
myTeapot(0.5,0.5);//位置
myTeapot(0.5,-0.5);
myTeapot(-0.5,-0.5);
myTeapot(-0.5,0.5);
glutSwapBuffers();
}
int main(int argc,char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("week03移動");
glutDisplayFunc(display);
glutMainLoop();
}
step02-5可看到分別在四角的茶壺
step02-6更改程式
沒有留言:
張貼留言