2019年3月15日 星期五

week04

http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/

下載三個檔案:[data] [win32] [glut32.dll]




⏩解壓縮windows
   資料夾呈現如圖
   開啟Transformation







⏩ 開啟Transformation
    試調整glRotatef
    ( 角度 , x , y , z )














進入網頁
下載Download freeglut 3.0.0 for MinGW






<X軸旋轉>

  











<Y軸旋轉>

















<Z軸旋轉>




#include <GL/glut.h>
float x=0, y=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
        glRotatef(x,0,0,1); //滑鼠在x軸移動,利用後面xyz數值可造成不同旋轉效果
      //  glTranslatef((x-150)/150.0,-(y-150)/150.0,0);
      //  glutSolidTeapot(0.3);
      //  glVertex2f((x-100)/100.0,-(y-100)/100.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();
 }下

沒有留言:

張貼留言