glColor4f、glVertex3f
- 打開https://jsyeh.org/3dcg10/
- 下載data win32
- 解壓縮,將data資料夾放到win32
- 打開Texture
- 調整glColor4f數值調整色彩
- 調整glVertex3f數值調整頂點座標
- 期中考練習網頁 https://jsyeh.org/gl/opengl_10_func.html
OpenCV安裝
- 到桌面或Teams中下載OpenCV 2.1.0
- 安裝過程中,在Install Option選取Add OpenCV to the system PATH for all users或Add OpenCV to the system PATH for current user
- 安裝完成後,重開CodeBlocks
- 打開後,在上面選單找到Setting-Compiler
- 找到search directories-Compiler-Add
- 輸入路徑 C:\OpenCV2.1\include
- 環境建置完成
OpenCV cvLoadImage、cvShowImage
貼圖
- 新增glut 專案
- 到 https://gist.github.com/jsyeh 複製myTexture.cpp中mytexture_sample.cpp程式碼
- 貼上到專案中
- 到google下載可以貼圖得地球地圖
https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.shutterstock.com%2Fsearch%2Fworld-map&psig=AOvVaw2PsW2uCqi8MKWKBHrGfR23&ust=1683027526547000&source=images&cd=vfe&ved=0CBEQjRxqFwoTCIibrp2E1P4CFQAAAAAdAAAAABAE - 另存圖檔到執行目錄C:\Users\ain22\Desktop\freeglut\bin中,並命名為earth.jpg
- 執行程式碼,執行結果
- 在void display()裡,glutSolidTeapot( 0.3 );上方加入下面程式碼
glTexCoord2f(0,0); glVertex2f(-1,-1);
glTexCoord2f(1,0); glVertex2f(1,-1);
glTexCoord2f(1,1); glVertex2f(1,1);
glTexCoord2f(0,1); glVertex2f(-1,1);
- 執行結果發現顛倒了
地球貼圖
- 新增glut檔
- 到 https://gist.github.com/jsyeh 複製 myEarth.cpp程式碼
- 貼上到專案檔,修改main函式中的讀檔檔名為earth.jpg
- 執行結果會看到原本的地球地圖變成一顆球的形狀在旋轉
沒有留言:
張貼留言