Skip to content

Commit d67a432

Browse files
committed
update CMakePresets
1 parent 2963e96 commit d67a432

File tree

8 files changed

+288
-49
lines changed

8 files changed

+288
-49
lines changed

.gitattributes

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.gitignore export-ignore
2+
.gitattributes export-ignore
3+
4+
.github export-ignore
5+
6+
models export-ignore
7+
shaders export-ignore
8+
textures export-ignore
9+
src export-ignore
10+
CMakeLists.txt export-ignore
11+
CMakePresets.json export-ignore

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
.idea/
44

55
build/
6-
shaders_copy/
6+
install/
77
shaders/*.spv
88
site/

CMakePresets.json

Lines changed: 122 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,125 @@
11
{
2-
"version": 8,
3-
"cmakeMinimumRequired": {
4-
"major": 3,
5-
"minor": 30,
6-
"patch": 0
7-
},
8-
"configurePresets": [
9-
{
10-
"name": "Ninja-x64",
11-
"description": "x64-config",
12-
"generator": "Ninja Multi-Config",
13-
"binaryDir": "${sourceDir}/build/",
14-
"installDir": "${sourceDir}/build/",
15-
"cacheVariables": {
16-
"CMAKE_CONFIGURATION_TYPES": "Debug;Release",
17-
"CMAKE_CXX_COMPILER": "cl.exe",
18-
"CMAKE_C_COMPILER": "cl.exe"
19-
},
20-
"architecture": {
21-
"value": "x64",
22-
"strategy": "external"
23-
}
2+
"version": 6,
3+
"configurePresets": [
4+
{
5+
"name": "ninja-base",
6+
"hidden": true,
7+
"description": "config-base, use Ninja, set binaryDir and installDir",
8+
"generator": "Ninja",
9+
"binaryDir": "${sourceDir}/build/",
10+
"installDir": "${sourceDir}/install/",
11+
"condition": {
12+
"type": "not",
13+
"condition": {
14+
"type": "equals",
15+
"lhs": "${hostSystemName}",
16+
"rhs": "Windows"
2417
}
25-
],
26-
"buildPresets": [
27-
{
28-
"name": "x64-build-debug",
29-
"displayName": "x64 Build Debug",
30-
"configurePreset": "Ninja-x64",
31-
"configuration": "Debug"
32-
},
33-
{
34-
"name": "x64-build-release",
35-
"displayName": "x64 Build Release",
36-
"configurePreset": "Ninja-x64",
37-
"configuration": "Release"
38-
}
39-
]
18+
}
19+
},
20+
{
21+
"name": "win-x64",
22+
"description": "Windows x64 config presets(MSVC + Ninja Multi-Config)",
23+
"inherits": "ninja-base",
24+
"generator": "Ninja Multi-Config",
25+
"cacheVariables": {
26+
"CMAKE_CONFIGURATION_TYPES": "Debug;Release",
27+
"CMAKE_CXX_COMPILER": "cl.exe",
28+
"CMAKE_C_COMPILER": "cl.exe"
29+
},
30+
"architecture": {
31+
"value": "x64",
32+
"strategy": "external"
33+
} ,
34+
"condition": {
35+
"type": "equals",
36+
"lhs": "${hostSystemName}",
37+
"rhs": "Windows"
38+
}
39+
},
40+
{
41+
"name": "unix-gnu-debug",
42+
"description": "Linux/macOS GNU Debug config presets(GNU + Ninja)",
43+
"inherits": "ninja-base",
44+
"cacheVariables": {
45+
"CMAKE_BUILD_TYPE": "Debug",
46+
"CMAKE_CXX_COMPILER": "g++",
47+
"CMAKE_C_COMPILER": "gcc"
48+
}
49+
},
50+
{
51+
"name": "unix-gnu-release",
52+
"description": "Linux/macOS GNU Release config presets(GNU + Ninja)",
53+
"inherits": "ninja-base",
54+
"cacheVariables": {
55+
"CMAKE_BUILD_TYPE": "Release",
56+
"CMAKE_CXX_COMPILER": "g++",
57+
"CMAKE_C_COMPILER": "gcc"
58+
}
59+
},
60+
{
61+
"name": "unix-clang-debug",
62+
"description": "Linux/macOS Clang Debug config presets(Clang + Ninja)",
63+
"inherits": "ninja-base",
64+
"cacheVariables": {
65+
"CMAKE_BUILD_TYPE": "Debug",
66+
"CMAKE_CXX_COMPILER": "clang++",
67+
"CMAKE_C_COMPILER": "clang"
68+
}
69+
},
70+
{
71+
"name": "unix-clang-release",
72+
"description": "Linux/macOS Clang Release config presets(Clang + Ninja)",
73+
"inherits": "ninja-base",
74+
"cacheVariables": {
75+
"CMAKE_BUILD_TYPE": "Release",
76+
"CMAKE_CXX_COMPILER": "clang++",
77+
"CMAKE_C_COMPILER": "clang"
78+
}
79+
}
80+
],
81+
"buildPresets": [
82+
{
83+
"name": "win-x64-build-debug",
84+
"displayName": "win-x64 Build Debug",
85+
"description": "win-x64 build Debug preset",
86+
"configurePreset": "win-x64",
87+
"configuration": "Debug"
88+
},
89+
{
90+
"name": "win-x64-build-release",
91+
"displayName": "win-x64 Build Release",
92+
"description": "win-x64 build Release preset",
93+
"configurePreset": "win-x64",
94+
"configuration": "Release"
95+
},
96+
{
97+
"name": "unix-gnu-build-debug",
98+
"displayName": "unix-gnu Build Debug",
99+
"description": "unix-gnu build Debug preset",
100+
"configurePreset": "unix-gnu-debug",
101+
"configuration": "Debug"
102+
},
103+
{
104+
"name": "unix-gnu-build-release",
105+
"displayName": "unix-gnu Build Release",
106+
"description": "unix-gnu build Release preset",
107+
"configurePreset": "unix-gnu-release",
108+
"configuration": "Release"
109+
},
110+
{
111+
"name": "unix-clang-build-debug",
112+
"displayName": "unix-clang Build Debug",
113+
"description": "unix-clang build Debug preset",
114+
"configurePreset": "unix-clang-debug",
115+
"configuration": "Debug"
116+
},
117+
{
118+
"name": "unix-clang-build-release",
119+
"displayName": "unix-clang Build Release",
120+
"description": "unix-clang build Release preset",
121+
"configurePreset": "unix-clang-release",
122+
"configuration": "Release"
123+
}
124+
]
40125
}
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
{
2+
"version": 8,
3+
"cmakeMinimumRequired": {
4+
"major": 3,
5+
"minor": 30,
6+
"patch": 0
7+
},
8+
"configurePresets": [
9+
{
10+
"name": "ninja-base",
11+
"hidden": true,
12+
"description": "config-base, use Ninja, set binaryDir and installDir",
13+
"generator": "Ninja",
14+
"binaryDir": "${sourceDir}/build/",
15+
"installDir": "${sourceDir}/install/",
16+
"condition": {
17+
"type": "not",
18+
"condition": {
19+
"type": "equals",
20+
"lhs": "${hostSystemName}",
21+
"rhs": "Windows"
22+
}
23+
}
24+
},
25+
{
26+
"name": "win-x64",
27+
"description": "Windows x64 config presets(MSVC + Ninja Multi-Config)",
28+
"inherits": "ninja-base",
29+
"generator": "Ninja Multi-Config",
30+
"cacheVariables": {
31+
"CMAKE_CONFIGURATION_TYPES": "Debug;Release",
32+
"CMAKE_CXX_COMPILER": "cl.exe",
33+
"CMAKE_C_COMPILER": "cl.exe"
34+
},
35+
"architecture": {
36+
"value": "x64",
37+
"strategy": "external"
38+
} ,
39+
"condition": {
40+
"type": "equals",
41+
"lhs": "${hostSystemName}",
42+
"rhs": "Windows"
43+
}
44+
},
45+
{
46+
"name": "unix-gnu-debug",
47+
"description": "Linux/macOS GNU Debug config presets(GNU + Ninja)",
48+
"inherits": "ninja-base",
49+
"cacheVariables": {
50+
"CMAKE_BUILD_TYPE": "Debug",
51+
"CMAKE_CXX_COMPILER": "g++",
52+
"CMAKE_C_COMPILER": "gcc"
53+
}
54+
},
55+
{
56+
"name": "unix-gnu-release",
57+
"description": "Linux/macOS GNU Release config presets(GNU + Ninja)",
58+
"inherits": "ninja-base",
59+
"cacheVariables": {
60+
"CMAKE_BUILD_TYPE": "Release",
61+
"CMAKE_CXX_COMPILER": "g++",
62+
"CMAKE_C_COMPILER": "gcc"
63+
}
64+
},
65+
{
66+
"name": "unix-clang-debug",
67+
"description": "Linux/macOS Clang Debug config presets(Clang + Ninja)",
68+
"inherits": "ninja-base",
69+
"cacheVariables": {
70+
"CMAKE_BUILD_TYPE": "Debug",
71+
"CMAKE_CXX_COMPILER": "clang++",
72+
"CMAKE_C_COMPILER": "clang"
73+
}
74+
},
75+
{
76+
"name": "unix-clang-release",
77+
"description": "Linux/macOS Clang Release config presets(Clang + Ninja)",
78+
"inherits": "ninja-base",
79+
"cacheVariables": {
80+
"CMAKE_BUILD_TYPE": "Release",
81+
"CMAKE_CXX_COMPILER": "clang++",
82+
"CMAKE_C_COMPILER": "clang"
83+
}
84+
}
85+
],
86+
"buildPresets": [
87+
{
88+
"name": "win-x64-build-debug",
89+
"displayName": "win-x64 Build Debug",
90+
"description": "win-x64 build Debug preset",
91+
"configurePreset": "win-x64",
92+
"configuration": "Debug"
93+
},
94+
{
95+
"name": "win-x64-build-release",
96+
"displayName": "win-x64 Build Release",
97+
"description": "win-x64 build Release preset",
98+
"configurePreset": "win-x64",
99+
"configuration": "Release"
100+
},
101+
{
102+
"name": "unix-gnu-build-debug",
103+
"displayName": "unix-gnu Build Debug",
104+
"description": "unix-gnu build Debug preset",
105+
"configurePreset": "unix-gnu-debug",
106+
"configuration": "Debug"
107+
},
108+
{
109+
"name": "unix-gnu-build-release",
110+
"displayName": "unix-gnu Build Release",
111+
"description": "unix-gnu build Release preset",
112+
"configurePreset": "unix-gnu-release",
113+
"configuration": "Release"
114+
},
115+
{
116+
"name": "unix-clang-build-debug",
117+
"displayName": "unix-clang Build Debug",
118+
"description": "unix-clang build Debug preset",
119+
"configurePreset": "unix-clang-debug",
120+
"configuration": "Debug"
121+
},
122+
{
123+
"name": "unix-clang-build-release",
124+
"displayName": "unix-clang Build Release",
125+
"description": "unix-clang build Release preset",
126+
"configurePreset": "unix-clang-release",
127+
"configuration": "Release"
128+
}
129+
]
130+
}

docs/md/00/01_env.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,13 @@ build/HelloVulkan
226226
- 弹出空白窗口
227227
- 关闭窗口后,控制台输出支持的Vulkan扩展数量
228228

229-
> 你或许喜欢使用CMakePresets简化配置,可以自行创建使用,但本教程不涉及CMake预设。
229+
### 关于CMake预设
230+
231+
**注意:CMake预设不是必须的,我们没有复杂的配置需求,你完全可以通过上面两行简单的CMake指令构建项目!**
232+
233+
如果你喜欢使用 `CMakePresets.json` (可以很好地和CLion、VSCode、Visual Studio配合),可以参考 **[这个](../../codes/00/01_env/CMakePresets.json)** 预设模板。
234+
235+
此预设模板使用Ninja作为生成器,提供了MSVC/GNU/Clang的预设配置。但它未经过充分测试,不保证全平台可用。
230236

231237
---
232238

docs/md/03/00_loadmodel.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,11 @@ for (const auto& shape : shapes) {
289289
> `map` 只需要提供 `<` 运算符重载即可。`unordered_map` 则需要 `==``std::hash<>` 特化。
290290
291291
自定义比较和哈希的方式有很多,最常见的就是提供哈希模板的特化以及`==`运算符重载。
292-
不过我决定使用一种不太常见的方式:直接向 `std::unordered_map<>` 模板填写第三和第四个模板形参,第三个参数是哈希第四个是等于。
292+
不过我决定使用一种不太常见的方式:直接向 `std::unordered_map<>` 模板填写第三和第四个模板形参,第三个参数是哈希第四个是等于。
293293

294-
> 示例代码将`Vertex`放在了`HelloTriangleApplication`的私有区域,导致模板特化和`==`重载较为麻烦。
294+
> 示例代码将 `Vertex` 放在了类的私有区域,导致模板特化和`==`重载较为麻烦。
295295
296-
首先导入 GLM 的哈希库,它封装了 内置向量的哈希函数,可以简化代码。因为是实验性的,我们需要加上 `GLM_ENABLE_EXPERIMENTAL` 宏。
296+
首先导入 GLM 的哈希库,它封装了内置向量的哈希函数,可以简化代码。因为是实验性的,我们需要加上 `GLM_ENABLE_EXPERIMENTAL` 宏。
297297

298298
```cpp
299299
#define GLM_ENABLE_EXPERIMENTAL
@@ -320,6 +320,9 @@ std::unordered_map<
320320
- 第三个模板形参是哈希算法,看起来比较复杂,但实际只是几个位运算的杂乱组合。
321321
- 第四个模板形参是键的等于算法,我们要求三个内容完全相等。
322322
323+
> C++20之前,lambda表达式对应的类型的默认构成为`delete`,无法像这样使用。
324+
> 自C++20起,lambda表达式捕获列表为空时,默认构造为`default`,此时才能作为上面的模板形参。
325+
323326
## **最后**
324327
325328
您现在应该能够成功编译并运行您的程序。

docs/md/03/30_movecamera.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# **移动摄像头**
1+
# **移动摄像机**
22

33
我们后续还会载入各种各样的几何体,不可能每次都手动调整模型大小或计算摄像头合适位置。
44
所以在开始进阶内容之前,我们先做一件有趣的事情,那就是获取外设输入并实时移动摄像头位置与角度。

mkdocs.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
site_name: Vulkan-hpp-tutorial
2-
site_url: https://mysvac.github.io/vulkan-hpp-tutorial/
2+
site_author: 迷枵(Mysvac)
3+
site_url: https://mysvac.github.io/vulkan-hpp-tutorial/
34
repo_url: https://github.com/Mysvac/vulkan-hpp-tutorial
5+
repo_name: Mysvac/vulkan-hpp-tutorial
6+
site_description: >
7+
Vulkan 入门教程,使用 C++20 编写,基于官方 Vulkan SDK 的 vulkan-hpp 和 RAII 封装,帮助开发者更现代、安全地学习 Vulkan 图形编程。
48
59
theme:
610
name: material
711
language: zh
8-
palette: # 启用深浅模式切换
9-
- scheme: default # 浅色模式
12+
palette:
13+
- scheme: default
1014
toggle:
11-
icon: material/weather-sunny # 太阳图标
15+
icon: material/weather-sunny
1216
name: 切换到深色模式
13-
- scheme: slate # 深色模式(内置)
17+
- scheme: slate
1418
toggle:
15-
icon: material/weather-night # 月亮图标
19+
icon: material/weather-night
1620
name: 切换到浅色模式
1721
features:
1822
- content.code.annotate

0 commit comments

Comments
 (0)