2018年3月19日 星期一

Week 04 安淇的課堂筆記

1.下載檔案
http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/
下載
windows.zip
data.zip
glut32.dll

2.期中考題:
glPushMatrix();   //備份矩陣
   glTranslatef(x,y,z);   //移動
   glRotatef(angle,x,y,z);   //轉動
   glScalef(x,y,z);   //放大縮小
   glBegin(GL_POLYGON);   //開始畫
      glColor3f(r,g,b);   //顏色
      glVertex3f(x,y,z);   //頂點
   glEnd();   //結束畫  與glBegin()對應
glPopMatrix();   //還原矩陣

3.自動旋轉
#include <GL/glut.h>
float angle=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
        glRotatef(angle,0,0,1);
        glutSolidTeapot(0.3);
    glPopMatrix();
    glutSwapBuffers();
    angle++;
}
int main(int argc, char**argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
    glutCreateWindow("Week04");
    glutIdleFunc(display);
    glutDisplayFunc(display);
    glutMainLoop();
}

沒有留言:

張貼留言