0. 安裝 桌面
1.1 File-New-
1.2 GItHub
2. mouse()函式
#include <GL/glut.h>
#include <stdio.h>
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutSolidTeapot(0.3);
glutSwapBuffers();
}
void mouse(int button,int state,int x,int y)
{
printf("botton:%d state:%d x:%d y:%d\n",button,state,x,y);
}
int main(int argc,char ** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("08163034");
glutDisplayFunc(display);
glutMouseFunc(mouse);
glutMainLoop();
}
3.motion()函式
#include <GL/glut.h>
int N=0,vx[3000],vy[3000];
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBegin(GL_LINE_LOOP);
for(int i=0;i<N;i++){
glVertex2f((vx[i]-150)/150.0,-(vy[i]-150)/150.0);
}
glEnd();
glutSwapBuffers();
}
void motion(int x,int y)
{
vx[N]=x;vy[N]=y;
N++;
display();
}
int main(int argc,char ** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("08163034");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
4. 在2021裡測試 Transformation
glScalef-X(寬度) Y(高度) Z(長度)
glRotatef-角度
glTranslatef-XYZ視角
物體旋轉的方向=Y軸向上的方向(安培右手)
Y=1.00
物體旋轉的方向=Y軸向下的方向(安培右手)
Y= -1.00
物體旋轉的方向=箭頭方向(安培右手)
X=1.00,Y= 1.00






沒有留言:
張貼留言