到www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10
下載windows.zip
data.zip
glut32.dll
windows.zip解壓縮,將data放進windows裡,並且glut32.dll也放進windows裡,這樣就能開啟保時捷進行移動,旋轉,縮放
到freeglut windows下載紅線所圈的
在freeglut的lib裡面複製一個libglut32.a
先把week03所學的用滑鼠移動茶壺程式寫出來
移動茶壺程式碼:
#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_translate");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
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_translate");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
多加了這行程式碼glRotatef(x,0,1,0); 可讓茶壺旋轉
沒有留言:
張貼留言