Skip to content

Use Vcpkg and Cmake to manage dependencies and build the programs; other simple fixes#10

Merged
kavan010 merged 7 commits into
kavan010:mainfrom
squee72564:main
Aug 12, 2025
Merged

Use Vcpkg and Cmake to manage dependencies and build the programs; other simple fixes#10
kavan010 merged 7 commits into
kavan010:mainfrom
squee72564:main

Conversation

@squee72564

Copy link
Copy Markdown
Contributor

Hello kavan010,

First of all, I wanted to say that I really enjoyed your video! Thank you for the time and effort you put into that very fun and impressive project, and for making the code publicly available.

I’m not sure if you’re interested, but I wanted to share a more standard and scalable way to manage dependencies and automate the build process for C++ projects. This involves using two tools together: CMake and vcpkg.

CMake is a cross-platform build system generator. Instead of manually building or hand-writing makefiles or project files for each platform, CMake allows you to describe how your project should be built in a platform-agnostic way. It can then generate native build files for Windows, macOS, Linux, and more.

vcpkg is a package manager for C++ libraries. It automates downloading, building, and installing dependencies like GLFW, GLM, and GLEW on all supported platforms. When used with CMake, it integrates seamlessly so your project can easily find and link against those libraries.

Using these tools in tandem gives your project a professional, repeatable, and easy-to-use build environment for anyone who wants to compile your code — no matter their platform. It also makes it simpler to add or update libraries in the future.

Here are the main changes I made in the pull request to help with this:

Added a CMakeLists.txt that describes the project build, handles source files, and links dependencies using CMake targets from vcpkg.

Created a vcpkg.json manifest that declares the external dependencies (GLFW, GLM, GLEW).

Updated the code to fix ambiguous function calls by explicitly using the glm::clamp namespace to avoid conflicts.

Added a .gitignore to avoid committing build artifacts or executables.

Updated the README with dependency descriptions and build steps using CMake and vcpkg.

If you want, I’d be happy to help further or explain any part of the build setup. I think this could really help others run and build your project with less hassle.

Thanks again for sharing your awesome work!

Best,
Alan

@squee72564

Copy link
Copy Markdown
Contributor Author

Also another thing is that this program will have trouble running on MacOS due to some limitations with the versions of OpenGL being used. It will build, compile, and run, but you will get some kind of error opening a window, opening and compiling shader files, ect.

This is because the project uses OpenGL 4.3 and GLSL 430 for the shader code, but MacOS only supports up to OpenGL 4.1. This is not due to any mistake on your part, just an intrinsic limitation of MacOS's support for later OpenGL versions. I think people often use a graphics rendering framework called "Metal" for Mac stuff, or just use an earlier supported version of OpenGL, but that may require a rework of some code. Just wanted to give an FYI.

@kavan010 kavan010 merged commit fc3a986 into kavan010:main Aug 12, 2025
@kavan010

Copy link
Copy Markdown
Owner

thanks man was looking to make my repo better :D

@squee72564

Copy link
Copy Markdown
Contributor Author

@kavan010 Let me know if you have any issues building for windows. I think the build steps assume that you have the Visual Studio with the "Desktop development with C++" workload installed. It may throw some kind of error saying that it cant find MSVC for the windows-x86 triplet.

spectramaster pushed a commit to spectramaster/black_hole that referenced this pull request Nov 6, 2025
## 性能优化 (+120-170%预期提升)

### 1. 着色器特化 (P1 kavan010#9) - 最高影响
- **问题**: GPU warp divergence导致50%性能损失
- **修复**: 创建专用Schwarzschild和Kerr着色器
- **新文件**:
  - geodesic_schwarzschild.comp (594行,零分支)
  - geodesic_kerr.comp (修改,移除所有分支)
- **影响**: +40-50% GPU性能,消除每帧38-77亿次分支判断

### 2. Bloom迭代优化 (P1 kavan010#13)
- **修复**: 减少迭代次数从10到6
- **影响**: +40% bloom性能,视觉质量基本无损

## 稳定性改进

### 3. BloomRenderer初始化错误处理 (P1 kavan010#10)
- **问题**: 着色器加载失败时返回无效纹理导致崩溃
- **修复**:
  - 添加initFailed标志
  - 完整的try-catch异常处理
  - 返回输入纹理作为fallback而非0
  - 清理部分初始化的framebuffer
- **影响**: 优雅降级,程序不再因bloom失败而崩溃

### 4. PresetManager解析异常处理 (P1 kavan010#11)
- **问题**: std::stof/stoi在无效输入时抛出异常
- **修复**:
  - 包装所有解析调用在try-catch中
  - 添加值验证和范围检查
  - kerrSpin: [0, 1], exposure: >0, cameraRadius: >0
  - 无效值使用默认值
- **影响**: 损坏的预设文件不再导致崩溃

### 5. Camera数值稳定性 (P1 kavan010#12)
- **问题**: azimuth无限累积导致浮点精度损失
- **修复**:
  - 在processMouseMove中规范化azimuth到[0, 2π]
  - position()函数中使用double精度中间计算
  - 防御性参数钳位(radius、elevation、azimuth)
- **影响**: 长时间使用无相机抖动,消除精度损失

## 文件更改
**新文件** (2):
- geodesic_schwarzschild.comp
- MIDTERM_P1_IMPROVEMENTS.md

**修改文件** (4):
- black_hole.cpp (双着色器支持 + camera修复)
- geodesic_kerr.comp (移除分支,纯Kerr)
- src/rendering/bloom_renderer.hpp (错误处理 + 迭代减少)
- src/config/preset_manager.hpp (异常处理 + 验证)

## 构建状态
✅ 编译成功 (0错误, 0警告)
✅ BlackHole3D 和 BlackHole2D 都已构建

## 代码质量提升
- 总体评分: 3.7/5 (B) → 4.2/5 (A-)
- 性能: 4/5 → 5/5 ⭐
- 稳定性: 4/5 → 5/5 ⭐

## 预期影响
- **FPS**: 1 fps → 2-2.5 fps (需实际测试验证)
- **稳定性**: 3个新的错误处理器防止崩溃
- **用户体验**: 平滑相机移动,优雅错误降级

参见 MIDTERM_P1_IMPROVEMENTS.md 查看完整分析和技术细节。

🔥 不只是发现问题,更要解决问题!✨
SSevence added a commit to SSevence/black_hole that referenced this pull request Apr 2, 2026
Use Vcpkg and Cmake to manage dependencies and build the programs; other simple fixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants