第四上課內容
一.本周主題:移動
二.示範:glTranslate(x,y,z)
再來將[win32]解壓縮,把[data]跟glut32.dll拖入解壓縮後的 [win32]
2.複習上禮拜的程式碼
3.打上可以讓水壺移動的程式碼
#include <GL/glut.h>
float x=0,y=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glTranslatef((x-150)/150.0,-(y-150)/150.0,0);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
void motion(int nowX,int nowY )
{
x=nowX,y=nowY;
display();
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("week04");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
沒有留言:
張貼留言