這倉儲包含了從基礎圖形界面到進階 OpenGL 渲染的多個實驗專案,涵蓋了 winBGIm、SFML 以及現代 OpenGL 的應用。
- 01_winBGIm_DVD
- 使用 winBGIm 實現經典的DVD標誌碰撞反彈模擬
- 02_winBGIm_Snake
- 使用 winBGIm 採用 遺傳演算法 (GA) 與線性回歸 (LR) 訓練的 AI 貪食蛇
- 狀態:開發中,目前模型尚未完全收斂
- 03_SFML_Snake
- 使用 SFML框架 重製 02_winBGIm_Snake 的 AI 貪食蛇遊戲
- 04_openGL_playground
- 使用 OpenGL 基礎開發的 3D 渲染環境,包含木箱渲染與自由移動相機
- 05_openGL_robot
- 機器人控制系統,整合模型載入、 ImGui UI 界面與16軸關節根據使用者拖拉角度顯示實時模型姿勢
- 注意:由於
model_Robot3D 模型非本人原創,基於版權考量,本倉儲不提供模型檔案
- 06_openGL_car
- 車載機械手臂控制系統,整合模型載入、 ImGui UI 界面與4軸關節根據使用者拖拉角度顯示實時模型姿勢
- 注意:由於
model_Robot3D 模型非本人原創,基於版權考量,本倉儲不提供模型檔案
01_winBGIm_DVD |
02 & 03_AI_Snake |
04_openGL_playground |
05_openGL_robot |
06_openGL_car |
本專案主要使用 MinGW-w64 (winlibs) 工具鏈、makefile 與 Ninja 進行編譯
建議下載 winlibs MinGW (UCRT 版本),內含 GCC、Make 與 Ninja
curl -L -O https://github.com/brechtsanders/winlibs_mingw/releases/download/15.2.0posix-14.0.0-ucrt-r7/winlibs-x86_64-posix-seh-gcc-15.2.0-mingw-w64ucrt-14.0.0-r7.zip注意: 下載後請解壓縮並將 bin 目錄加入系統的環境變數 PATH 中。
- 需安裝 Visual Studio 2022 或更高版本
- 安裝時請勾選 「使用 C++ 的桌面開發」 (Desktop development with C++),以取得 MSVC 編譯器、Windows SDK 及 CMake 工具
GLAD 需要 Python 環境來生成 OpenGL 載入器。
- 快速安裝:開啟 PowerShell 並輸入:
winget install Python.Python.3 - 手動安裝:前往 Python 官網 下載安裝檔。
- 重要設定:安裝時請務必勾選 "Add Python to PATH",否則無法在終端機直接執行
pip或python指令。
本專案已在以下環境測試通過,建議使用相同或更高版本:
| 工具 | 測試版本 | 備註 |
|---|---|---|
| Operating System | Windows 11 (64-bit) | - |
| MinGW-w64 | GCC 15.2.0 (winlibs) | 支援最新 C++ 標準 |
| Visual Studio | VS 2022 (v17.14.7) | 用於 Project 03, 05, 06 |
| Python | 3.12.2 | 用於 GLAD2 生成器 |
請先在專案根目錄建立 lib 資料夾,所有的第三方庫將存放於此:
mkdir -p ./lib-
winBGIm64 (01_winBGIm_DVD/02_winBGIm_Snake)
cd computer-graphics/lib git clone https://github.com/ki9gpin/WinBGIm-64 cd WinBGIm-64 cmake -G Ninja cmake --build .
-
SFML (03_SFML_Snake)
cd computer-graphics/lib curl -L -O https://github.com/SFML/SFML/releases/download/3.0.2/SFML-3.0.2-Windows.MinGW.x64.zip tar -xf SFML-3.0.2-Windows.MinGW.x64.zip
-
GLAD
cd computer-graphics/lib pip install glad2 python -m glad --api "gl:core=3.3" --extensions "" --out-path ./glad c --loader
-
GLFW
cd computer-graphics/lib curl -L -O https://github.com/glfw/glfw/releases/download/3.4/glfw-3.4.bin.WIN64.zip tar -xf glfw-3.4.bin.WIN64.zip -
Eigen
cd computer-graphics/lib git clone https://gitlab.com/libeigen/eigen.git -
GLM
cd computer-graphics/lib git clone https://github.com/g-truc/glm.git cd glm cmake -G Ninja -DGLM_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF -B build . cmake --build build -- all
-
Assimp
cd computer-graphics/lib git clone https://github.com/assimp/assimp cd assimp cmake -G Ninja -DASSIMP_BUILD_TESTS=off -DASSIMP_INSTALL=off -S . -B build cd build ninja
-
stb-image
cd computer-graphics/lib git clone https://github.com/nothings/stb.git
-
ImGui
cd computer-graphics/lib git clone https://github.com/ocornut/imgui.git
cd ./01_winBGIm_DVD
makecd ./02_winBGIm_Snake
makecd ./03_SFML_Snake
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
msbuild /p:Configuration=Release /p:Platform=x64
.\03_SFML_Snake\x64\Release\Snake_vs.exe本專案為學習現代 OpenGL 的基礎練習,主要參考以下教學清單進行實作:
cd ./04_openGL_playground
makecd computer-graphics
# 建立目標目錄
mkdir -p ./05_openGL_robot/RobotControlSystem/LIB
# 複製 stb_image
cp ./lib/stb/stb_image.h ./05_openGL_robot/RobotControlSystem/LIB/
# 複製 ImGui 核心檔案
cp ./lib/imgui/*.h ./05_openGL_robot/RobotControlSystem/LIB/
cp ./lib/imgui/*.cpp ./05_openGL_robot/RobotControlSystem/LIB/
# 複製 ImGui Backends (GLFW & OpenGL3)
cp ./lib/imgui/backends/imgui_impl_glfw.cpp ./05_openGL_robot/RobotControlSystem/LIB/
cp ./lib/imgui/backends/imgui_impl_glfw.h ./05_openGL_robot/RobotControlSystem/LIB/
cp ./lib/imgui/backends/imgui_impl_opengl3.cpp ./05_openGL_robot/RobotControlSystem/LIB/
cp ./lib/imgui/backends/imgui_impl_opengl3.h ./05_openGL_robot/RobotControlSystem/LIB/
cp ./lib/imgui/backends/imgui_impl_opengl3_loader.h ./05_openGL_robot/RobotControlSystem/LIB/
## 編譯專案
cd 05_openGL_robot
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
msbuild /p:Configuration=Release /p:Platform=x64
cp -r ./RobotControlSystem/Shader ./x64/Release
cp -r ./RobotControlSystem/model_Robot ./x64/Release
cd ./x64/Release
.\RobotControlSystem.execd computer-graphics
# 建立目標目錄
mkdir -p ./06_openGL_car/RobotControlSystem/LIB
# 複製 stb_image
cp ./lib/stb/stb_image.h ./06_openGL_car/RobotControlSystem/LIB/
# 複製 ImGui 核心檔案
cp ./lib/imgui/*.h ./06_openGL_car/RobotControlSystem/LIB/
cp ./lib/imgui/*.cpp ./06_openGL_car/RobotControlSystem/LIB/
# 複製 ImGui Backends (GLFW & OpenGL3)
cp ./lib/imgui/backends/imgui_impl_glfw.cpp ./06_openGL_car/RobotControlSystem/LIB/
cp ./lib/imgui/backends/imgui_impl_glfw.h ./06_openGL_car/RobotControlSystem/LIB/
cp ./lib/imgui/backends/imgui_impl_opengl3.cpp ./06_openGL_car/RobotControlSystem/LIB/
cp ./lib/imgui/backends/imgui_impl_opengl3.h ./06_openGL_car/RobotControlSystem/LIB/
cp ./lib/imgui/backends/imgui_impl_opengl3_loader.h ./06_openGL_car/RobotControlSystem/LIB/
## 編譯專案
cd 06_openGL_car
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
msbuild /p:Configuration=Release /p:Platform=x64
cp -r ./RobotControlSystem/Shader ./x64/Release
cp -r ./RobotControlSystem/model_Robot ./x64/Release
cd ./x64/Release
.\RobotControlSystem.exe- 模型版權:
05_openGL_robot/06_openGL_car專案中所使用的 3D 模型檔案為外部資源,並非本人創作,故不包含在倉儲中。使用者需自行準備相容之模型檔案進行測試。




