2020年3月25日 星期三

Week04

▲主題:Transformation

◮ 課前範例
▵網址:http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/

▵下載檔案(紅圈)



▵開啟 Transformation.exe



◮ 茶壺 & Motion函式旋轉

▵程式碼

#include <GL/glut.h>
#include <stdio.h>
float myAngle=0;
void motion(int x,int y)
{
    myAngle=x;
    glutPostRedisplay();
}
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
        glRotatef(myAngle,0,0,1);
        glutSolidTeapot( 0.3 );

    glPopMatrix();
    glutSwapBuffers();
}
int main(int argc, char**argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("week04");

    glutDisplayFunc(display);
    glutMotionFunc(motion);
    glutMainLoop();
}





沒有留言:

張貼留言