載windows.zip和data.zip還有glut32.dll
解壓縮 data和glut丟到windows資料夾
開啟transformation.exe
讓球1轉動 其他變白色
code:
glPushMatrix();
glRotated(a,0,0,1);
glTranslatef(0,1,2-6);
glutSolidSphere(1,slices,stacks);
glPopMatrix();
glColor3f(1,1,1);
讓茶壺傾斜
code:
#include <GL/glut.h>
float angle=0;///Now: 讓茶壼自動轉動的角度
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();///Now:備份矩陣
glRotatef(angle, 0,0,1);///Now:轉動
glTranslatef(0.45,-0.10,0);
glutSolidTeapot(0.3);
glPopMatrix();///Now:還原矩陣
glutSwapBuffers();
}
void motion(int x, int y)
{
angle=x;///Now: 改變角度
glutPostRedisplay();///Now: 請 重畫畫面
}
int main(int argc, char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("Week05 TRT");
glutDisplayFunc(display);
glutMotionFunc(motion);///Now:
glutMainLoop();
}
沒有留言:
張貼留言