1-1
開啟gitbash,下載2023graphicsb
1-2
新增專案week15-1_gluLookAt
位置改為2023graphicsb的freeglut
新增motion函式,讓畫面藉由滑鼠移動可以從不同視角觀看
從glfrustum改成glOrtho,改成透視的角度,並且調整視角的大小
再來嘗試gluPerspective視角
3-1
開啟新專案week15-3_gluPerspective
#include<GL/glut.h>
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glutSolidTeapot( 0.3 );
glutSwapBuffers();
}
void motion(int x,int y){
glLoadIdentity();
float eyeX=(x-150)/150.0, eyeY=(150-y)/150.0;
eyeX=(x-150)/150.0, eyeY=(150-y)/150.0;
gluLookAt(eyeX,eyeY, 1, 0,0,0, 0,1,0);
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("week15");
glutMotionFunc(motion);
glutDisplayFunc(display);
glutMainLoop();
}
3-2
新增reshape函式,讓茶壺在各種視角都能看到
void reshape(int w,int h)
{
float ar=w/(float)h;
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60, ar, 0.01,1000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0,0, 1, 0,0,0, 0,1,0);
}
3-3
更改angle的參數,變為矩陣
沒有留言:
張貼留言