2021年5月31日 星期一

電腦圖學week15

課程內容:
1.step01:利fopen() fprintf() 寫檔案,會寫在執行的工作目錄裡












2.step02:Project.cbp檔裡面的 working_dir改成小數點,看到目錄會改變











#include <stdio.h>
int main(int argc, char** argv)
{
    FILE * fout=NULL;///steep01 檔案指標 file output 變數 steep01
    fout = fopen("檔名.txt","w+");///step01 開啟檔案,檔名.txt, 模式:write+
    printf("Hello World\n");
    fprintf(fout,"Hello World\n");///step01 改裝 printf() 變 fprintf()
}

3.把舊程式註解掉,寫新的程式來fscanf()讀檔












FILE * fin =NULL;
    fin = fopen("檔名.txt","r");///step03 開啟step01/step02的檔案,Read
    char line[100];///step03 宣告一個字串 line
    fscanf(fin,"%s",line);
    printf("現在讀到的是 %s\n", line);
    fscanf(fin,"%s",line);
    printf("現在讀到的是 %s\n", line);

4.複習茶壺











#include <stdio.h>
#include<GL/glut.h>
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glutSolidTeapot(0.3);
        glutSwapBuffers();
}
int main(int argc, char** argv)
{
    glutInit( &argc, argv );
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow( "week15 many angles");

    glutDisplayFunc(display);
    glutMainLoop();
}

5.複習上週的Timer (先不執行)










6.做出一個茶壺手臂











7.做出兩個茶壺手臂


沒有留言:

張貼留言

Week18期末作業(橘貓的跳舞熊熊)

 期末作業(橘貓的跳舞熊熊) 影片: https://youtu.be/R89tptMaQZw 程式碼: #include <opencv/highgui.h> #include <opencv/cv.h> #include <GL/glut.h...