Step 1 :打開上次下載的windows裡的Transformation
Step 3 :點擊ToDraw即可開始畫圖 2.將myDrawObject(0);移動到下面glTranslatef(0,0,0); 3.滑鼠點擊右上角的angle,並按下空白鍵,圖形就會進行旋轉 4.將myDrawObject(0);移動到glTranslatef(0,0,0); 5.點擊glTranslatef(0,0,0);就可以拖曳移動圖形位置
Step 3-2 :做旋轉的茶壺
程式碼:#include <GL/glut.h>
float angle=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(angle , 0, 0, 1);
glTranslatef(0.4,-0.07,0);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
angle+=0.1;
}
int main(int argc,char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("week12 TRT");
glutIdleFunc(display);
glutDisplayFunc(display);
glutMainLoop();
}
程式碼:
#include <GL/glut.h>
float angle=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1,1,1);
glutSolidTeapot(0.3);
glPushMatrix();
glTranslatef(0.3,0,0);
glRotatef( angle,0,0,1);
glTranslatef(0.2,0,0);
glColor3f(1,0,0);
glutSolidTeapot(0.2);
glPopMatrix();
glutSwapBuffers();
angle+=0.1;
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("week12 TRT");
glutIdleFunc(display);
glutDisplayFunc(display);
glutMainLoop();
}
程式碼:
#include <GL/glut.h>
float angle=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1,1,1);
glutSolidTeapot(0.3);
glPushMatrix();
glTranslatef(0.3,0,0);
glRotatef( angle,0,0,1);
glTranslatef(0.2,0,0);
glColor3f(1,0,0);
glutSolidTeapot(0.2);
glPushMatrix();
glTranslatef(0.2,0,0);
glRotatef( angle,0,0,1);
glTranslatef(0.2,0,0);
glColor3f(1,0,0);
glutSolidTeapot(0.2);
glPopMatrix();
glPopMatrix();
glutSwapBuffers();
angle+=0.1;
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("week12 TRT");
glutIdleFunc(display);
glutDisplayFunc(display);
glutMainLoop();
}



沒有留言:
張貼留言