電腦圖學 week05
任務一:
旋轉範例,去感受右手定則,你的右手可以拯救世界.
任務二:
程式碼:
#include <GL/glut.h>
float angle=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotated(angle,0,1,0);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
angle+=3;
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("06160451 week05");
glutDisplayFunc(display);
glutIdleFunc(display);
glutMainLoop();
}
會旋轉的茶壺,當你寫入程式碼可以使茶壺像地球一樣自轉時,你就會用世界(zawarudo)了.
任務三:
程式碼:
#include <GL/glut.h>
float angle=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotated(angle,0,1,0);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
///angle+=3;
}
void motion(int x,int y)
{
angle=x;
display();
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("06160451 week05");
glutDisplayFunc(display);
glutIdleFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
程式碼:
#include <GL/glut.h>
#include <stdio.h>
float angle=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotated(angle,0,1,0);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
///angle+=3;
}
void motion(int x,int y)
{
angle=x;
display();
}void mouse(int buttom,int state,int x,int y)
{
printf("%d %d %d %d\n",buttom,state,x,y);
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("06160451 week05");
glutDisplayFunc(display);
glutIdleFunc(display);
glutMotionFunc(motion);
glutMouseFunc(mouse);
glutMainLoop();
}
印出滑鼠座標,耕者老師的程式碼打.
程式碼:
float angle=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotated(angle,0,1,0);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
///angle+=3;
}
void motion(int x,int y)
{
angle=x;
display();
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("06160451 week05");
glutDisplayFunc(display);
glutIdleFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
程式碼:
#include <GL/glut.h>
#include <stdio.h>
float angle=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotated(angle,0,1,0);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
///angle+=3;
}
void motion(int x,int y)
{
angle=x;
display();
}void mouse(int buttom,int state,int x,int y)
{
printf("%d %d %d %d\n",buttom,state,x,y);
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("06160451 week05");
glutDisplayFunc(display);
glutIdleFunc(display);
glutMotionFunc(motion);
glutMouseFunc(mouse);
glutMainLoop();
}
印出滑鼠座標,耕者老師的程式碼打.
沒有留言:
張貼留言