Skip to content

Commit 12ba16a

Browse files
committed
WIP zh-TW
1 parent e2a4e05 commit 12ba16a

File tree

10 files changed

+159
-0
lines changed

10 files changed

+159
-0
lines changed

guide/build.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ endfunction()
2424
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/theme" DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/translations")
2525

2626
BuildBook("en" "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/book")
27+
BuildBook("zh-TW" "${CMAKE_CURRENT_SOURCE_DIR}/translations/zh-TW" "${CMAKE_CURRENT_SOURCE_DIR}/book/zh-TW")
2728
BuildBook("ko-KR" "${CMAKE_CURRENT_SOURCE_DIR}/translations/ko-KR" "${CMAKE_CURRENT_SOURCE_DIR}/book/ko-KR")

guide/theme/index.hbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@
143143
</button>
144144
<ul id="lang-list" class="theme-popup" aria-label="Languages" role="menu">
145145
<li role="none"><button role="menuitem" class="theme" data-lang="en">English</button></li>
146+
<li role="none"><button role="menuitem" class="theme" data-lang="zh-TW">中文</button></li>
146147
<li role="none"><button role="menuitem" class="theme" data-lang="ko-KR">한글</button></li>
147148
</ul>
148149
{{#if search_enabled}}

guide/translations/zh-TW/book.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[book]
2+
authors = ["Karnage", "Mes"]
3+
language = "zh-TW"
4+
src = "src"
5+
title = "Learn Vulkan"
6+
7+
[output.html]
8+
theme = "../theme"
9+
additional-js = ["../theme/lang_toggle.js"]
10+
additional-css = ["../theme/lang_toggle.css"]
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# (中文 WIP) Intro
2+
3+
Vulkan is known for being explicit and verbose. But the _required_ verbosity has steadily reduced with each successive version, its new features, and previous extensions being absorbed into the core API. Similarly, RAII has been a pillar of C++ since its inception, yet most Vulkan guides do not utilize it, instead choosing to "extend" the explicitness by manually cleaning up resources.
4+
5+
To fill that gap, this guide has the following goals:
6+
7+
- Leverage modern C++, VulkanHPP, and Vulkan 1.3 features
8+
- Focus on keeping it simple and straightforward, _not_ on performance
9+
- Develop a basic but dynamic rendering foundation
10+
11+
To reiterate, the focus is _not on performance_, it is on a quick introduction to the current standard multi-platform graphics API while utilizing the modern paradigms and tools (at the time of writing). Even disregarding potential performance gains, Vulkan has a better and modern design and ecosystem than OpenGL, eg: there is no global state machine, parameters are passed by filling structs with meaningful member variable names, multi-threading is largely trivial (yes, it is actually easier to do on Vulkan than OpenGL), there are a comprehensive set of validation layers to catch misuse which can be enabled without _any_ changes to application code, etc.
12+
13+
## Target Audience
14+
15+
The guide is for you if you:
16+
17+
- Understand the principles of modern C++ and its usage
18+
- Have created C++ projects using third-party libraries
19+
- Are somewhat familiar with graphics
20+
- Having done OpenGL tutorials would be ideal
21+
- Experience with frameworks like SFML / SDL is great
22+
- Don't mind if all the information you need isn't monolithically in one place (ie, this guide)
23+
24+
Some examples of what this guide _does not_ focus on:
25+
26+
- GPU-driven rendering
27+
- Real-time graphics from ground-up
28+
- Considerations for tiled GPUs (eg mobile devices / Android)
29+
30+
## Source
31+
32+
The source code for the project (as well as this guide) is located in [this repository](https://github.com/cpp-gamedev/learn-vulkan). A `section/*` branch intends to reflect the state of the code at the end of a particular section of the guide. Bugfixes / changes are generally backported, but there may be some divergence from the current state of the code (ie, in `main`). The source of the guide itself is only up-to-date on `main`, changes are not backported.
33+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# (中文 WIP) Summary
2+
3+
[(中文 WIP) Introduction](README.md)
4+
5+
# (中文 WIP) Basics
6+
7+
- [(中文 WIP) Getting Started](getting_started/README.md)
8+
- [(中文 WIP) Project Layout](getting_started/project_layout.md)
9+
- [(中文 WIP) Validation Layers](getting_started/validation_layers.md)
10+
- [(中文 WIP) class App](getting_started/class_app.md)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# (中文 WIP) Getting Started
2+
3+
Vulkan is platform agnostic, which is one of the main reasons for its verbosity: it has to account for a wide range of implementations in its API. We shall be constraining our approach to Windows and Linux (x64 or aarch64), and focusing on discrete GPUs, enabing us to sidestep quite a bit of that verbosity. Vulkan 1.3 is widely supported by the target desktop platforms and reasonably recent graphics cards.
4+
5+
> This doesn't mean that eg an integrated graphics chip will not be supported, it will just not be particularly designed/optimized for.
6+
7+
## Technical Requirements
8+
9+
1. Vulkan 1.3+ capable GPU and loader
10+
1. [Vulkan 1.3+ SDK](https://vulkan.lunarg.com/sdk/home)
11+
1. This is required for validation layers, a critical component/tool to use when developing Vulkan applications. The project itself does not use the SDK.
12+
1. Always using the latest SDK is recommended (1.4.x at the time of writing).
13+
1. Desktop operating system that natively supports Vulkan
14+
1. Windows and/or Linux (distros that use repos with recent packages) is recommended.
15+
1. MacOS does _not_ natively support Vulkan. It _can_ be used through MoltenVk, but at the time of writing MoltenVk does not fully support Vulkan 1.3, so if you decide to take this route, you may face some roadblocks.
16+
1. C++23 compiler and standard library
17+
1. GCC14+, Clang18+, and/or latest MSVC are recommended. MinGW/MSYS is _not_ recommended.
18+
1. Using C++20 with replacements for C++23 specific features is possible. Eg replace `std::print()` with `fmt::print()`, add `()` to lambdas, etc.
19+
1. CMake 3.24+
20+
21+
## Overview
22+
23+
While support for C++ modules is steadily growing, tooling is not yet ready on all platforms/IDEs we want to target, so we will unfortuntely still be using headers. This might change in the near future, followed by a refactor of this guide.
24+
25+
The project uses a "Build the World" approach, enabling usage of sanitizers, reproducible builds on any supported platform, and requiring minimum pre-installed things on target machines. Feel free to use pre-built binaries instead, it doesn't change anything about how you would use Vulkan.
26+
27+
## Dependencies
28+
29+
1. [GLFW](https://github.com/glfw/glfw) for windowing, input, and Surface creation
30+
1. [VulkanHPP](https://github.com/KhronosGroup/Vulkan-Hpp) (via [Vulkan-Headers](https://github.com/KhronosGroup/Vulkan-Headers)) for interacting with Vulkan
31+
1. While Vulkan is a C API, it offers an official C++ wrapper library with many quality-of-life features. This guide almost exclusively uses that, except at the boundaries of other C libraries that themselves use the C API (eg GLFW and VMA).
32+
1. [Vulkan Memory Allocator](https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator/) for dealing with Vulkan memory heaps
33+
1. [GLM](https://github.com/g-truc/glm) for GLSL-like linear algebra in C++
34+
1. [Dear ImGui](https://github.com/ocornut/imgui) for UI
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# (中文 WIP) Application
2+
3+
`class App` will serve as the owner and driver of the entire application. While there will only be one instance, using a class enables us to leverage RAII and destroy all its resources automatically and in the correct order, and avoids the need for globals.
4+
5+
```cpp
6+
// app.hpp
7+
namespace lvk {
8+
class App {
9+
public:
10+
void run();
11+
};
12+
} // namespace lvk
13+
14+
// app.cpp
15+
namespace lvk {
16+
void App::run() {
17+
// TODO
18+
}
19+
} // namespace lvk
20+
```
21+
22+
## Main
23+
24+
`main.cpp` will not do much: it's mainly responsible for transferring control to the actual entry point, and catching fatal exceptions.
25+
26+
```cpp
27+
// main.cpp
28+
auto main() -> int {
29+
try {
30+
lvk::App{}.run();
31+
} catch (std::exception const& e) {
32+
std::println(stderr, "PANIC: {}", e.what());
33+
return EXIT_FAILURE;
34+
} catch (...) {
35+
std::println("PANIC!");
36+
return EXIT_FAILURE;
37+
}
38+
}
39+
```
187 KB
Loading
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# (中文 WIP) Project Layout
2+
3+
This page describes the layout used by the code in this guide. Everything here is just an opinionated option used by the guide, and is not related to Vulkan usage.
4+
5+
External dependencies are stuffed into a zip file that's decompressed by CMake during the configure stage. Using FetchContent is a viable alternative.
6+
7+
`Ninja Multi-Config` is the assumed generator used, regardless of OS/compiler. This is set up in a `CMakePresets.json` file in the project root. Additional custom presets can be added via `CMakeUserPresets.json`.
8+
9+
> On Windows, Visual Studio CMake Mode uses this generator and automatically loads presets. With Visual Studio Code, the CMake Tools extension automatically uses presets. For other IDEs, refer to their documentation on using CMake presets.
10+
11+
**Filesystem**
12+
13+
```
14+
.
15+
|-- CMakeLists.txt <== executable target
16+
|-- CMakePresets.json
17+
|-- [other project files]
18+
|-- ext/
19+
│ |-- CMakeLists.txt <== external dependencies target
20+
|-- src/
21+
|-- [sources and headers]
22+
```
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# (中文 WIP) Validation Layers
2+
3+
The area of Vulkan that apps interact with: the loader, is very powerful and flexible. Read more about it [here](https://github.com/KhronosGroup/Vulkan-Loader/blob/main/docs/LoaderInterfaceArchitecture.md). Its design enables it to chain API calls through configurable **layers**, eg for overlays, and most importantly for us: [Validation Layers](https://github.com/KhronosGroup/Vulkan-ValidationLayers/blob/main/docs/README.md).
4+
5+
![Vulkan Loader](high_level_loader.png)
6+
7+
As [suggested](https://github.com/KhronosGroup/Vulkan-ValidationLayers/blob/main/docs/khronos_validation_layer.md#vkconfig) by the Khronos Group, we recommend using [Vulkan Configurator (GUI)](https://github.com/LunarG/VulkanTools/tree/main/vkconfig_gui) for validation layers. This application is shipped with the Vulkan SDK, just keep it running while developing Vulkan applications, and ensure it is setup to inject validation layers into all detected applications, with Synchronization Validation enabled. This approach provides a lot of flexibility at runtime, including the ability to have VkConfig break the debugger on encountering an error, and also eliminates the need for validation layer specific code in the applications.
8+
9+
> Note: modify your development (or desktop) environment's `PATH` (or use `LD_LIBRARY_PATH` on supported systems) to make sure the SDK's binaries are visible first.

0 commit comments

Comments
 (0)