Skip to content

Commit 8358f43

Browse files
Improve wording and C++ usage
Rationale: * "Default initialization" actually means not initializing the object, which would leave it uninitialized. Using `= {}` is "aggregate initialization" syntax, which leads to "value initialization". Directly using `{}` is just "value initialization". * `std::endl` is overused and can be a source of performance issues, as it forces the output buffer to be flushed. `\n` is - most of the times - what you need. Just doing my part in trying to avoid overuse of `std::endl`.
1 parent 03e8ea7 commit 8358f43

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

en/03_Drawing_a_triangle/00_Setup/01_Instance.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ an *instance*. The instance is the connection between your application and the
55
Vulkan library and creating it involves specifying some details about your
66
application to the driver.
77

8-
Start by adding a `createInstance` function and add a call to it in the
8+
Start by adding a `createInstance` function and invoking it in the
99
`initVulkan` function.
1010

1111
```c++
@@ -14,7 +14,7 @@ void initVulkan() {
1414
}
1515
```
1616

17-
Additionally add a class member to hold the handle to the instance:
17+
Additionally add a data member to hold the handle to the instance:
1818

1919
```c++
2020
private:
@@ -23,13 +23,13 @@ VkInstance instance;
2323

2424
Now, to create an instance we'll first have to fill in a struct with some
2525
information about our application. This data is technically optional, but it may
26-
provide some useful information to the driver to optimize for our specific
27-
application, for example because it uses a well-known graphics engine with
28-
certain special behavior. This struct is called `VkApplicationInfo`:
26+
provide some useful information to the driver in order to optimize our specific
27+
application (e.g. because it uses a well-known graphics engine with
28+
certain special behavior). This struct is called `VkApplicationInfo`:
2929

3030
```c++
3131
void createInstance() {
32-
VkApplicationInfo appInfo = {};
32+
VkApplicationInfo appInfo{};
3333
appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
3434
appInfo.pApplicationName = "Hello Triangle";
3535
appInfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0);
@@ -42,7 +42,7 @@ void createInstance() {
4242
As mentioned before, many structs in Vulkan require you to explicitly specify
4343
the type in the `sType` member. This is also one of the many structs with a
4444
`pNext` member that can point to extension information in the future. We're
45-
using default initialization here to leave it as `nullptr`.
45+
using value initialization here to leave it as `nullptr`.
4646

4747
A lot of information in Vulkan is passed through structs instead of function
4848
parameters and we'll have to fill in one more struct to provide sufficient
@@ -150,10 +150,10 @@ extension. We can list them with a simple for loop (`\t` is a tab for
150150
indentation):
151151
152152
```c++
153-
std::cout << "available extensions:" << std::endl;
153+
std::cout << "available extensions:\n";
154154
155155
for (const auto& extension : extensions) {
156-
std::cout << "\t" << extension.extensionName << std::endl;
156+
std::cout << '\t' << extension.extensionName << '\n';
157157
}
158158
```
159159

0 commit comments

Comments
 (0)