
Q2:開動的車子在繞著中心轉

課堂作業二
可以用滑鼠轉動得茶壺




#include <GL/glut.h>
float rotX=0;
void display()
{
glClearColor(0,0,1,1);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef(rotX,0,1,0);
glColor3f(1,1,0);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
void motion(int x,int y)
{
rotX=x;
display();
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE |GLUT_DEPTH);
glutCreateWindow("hello3D");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
階程式旋轉

#include <GL/glut.h>
float rotX=0,rotY=0;
void display()
{
glClearColor(0,0,1,1);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef(rotX,0,1,0);
glRotatef(rotY,1,0,0);
glColor3f(1,1,0);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
void motion(int x,int y)
{
rotX=x;
rotY=y;
display();
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE |GLUT_DEPTH);
glutInitWindowSize(600,600); //可以改變視窗大小
glutInitWindowPosition(700,0); //可以改變視窗顯視位置
glutCreateWindow("hello3D");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
課堂作業三
Q1:buffer?
Q2:double?
Q3: push?pop?

沒有留言:
張貼留言