You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All we need to do now is write the contents of the `renderLoop` method. Again, I'm not going to be going too far into depth because this is just glue and we're focused on Vulkan here. Anyways, we'll be using the `xcb_wait_for_event` method to do just that: wait for events. In order to convert the server's response to a value we can check in a **switch case** block, we need to use the bitwise `AND` (`&`) operator with the value: `~0x80`. You can see what I'm talking about below:
Copy file name to clipboardExpand all lines: chap04/chap04-windows.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -148,7 +148,7 @@ HWND window;
148
148
In this section we'll be writing the body this method:
149
149
150
150
```cpp
151
-
voidinitWindow(HINSTANCE hInstance) {}
151
+
voidcreateWindow(HINSTANCE hInstance) {}
152
152
```
153
153
154
154
Don't worry about `hInstance` for now. It is passed from the `WinMain` method we'll write later on. To setup our window, we'll need to register it with Windows, but first, we need to create a `WNDCLASSEX` object to pass during registration.
@@ -349,7 +349,7 @@ switch (message) {
349
349
For this section, we'll write the body of this method:
350
350
351
351
```cpp
352
-
voidVulkanSwapchain::renderLoop() {}
352
+
voidVulkanExample::renderLoop() {}
353
353
```
354
354
355
355
We're calling it `renderLoop` because later we'll make calls to rendering functions within it. For now, however, we're going to:
@@ -374,7 +374,7 @@ while (GetMessage(&message, NULL, 0, 0)) {
374
374
This is our application's new entry-point. We will **not** be using your typical `int main()` entry-point. This is because Windows requires GUI applications to enter at `WinMain`. We need to:
375
375
376
376
- Create an instance of our class
377
-
- Call our `initWindow` method
377
+
- Call our `createWindow` method
378
378
- Call our `renderLoop`
379
379
380
380
**Definition for `WinMain`**:
@@ -401,7 +401,7 @@ int CALLBACK WinMain(
401
401
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
Per usual, in addition to calling the method, we'll also verify it was successful.
122
122
123
123
```cpp
124
-
VkResult result = vkAllocateCommandBuffers(device, &cmdBufAllocInfo,
124
+
VkResult result = vkAllocateCommandBuffers(device, &cmdBufAllocInfo,
125
125
&initialCmdBuffer);
126
126
assert(result == VK_SUCCESS);
127
127
```
128
128
129
129
## Preparing Command Buffer for Recording
130
130
131
-
Before we can start recording to our command buffer, we'll have to first create a `VkCommandBufferBeginInfo` object.
131
+
Before we can start recording to our command buffer, we'll have to first create a `VkCommandBufferBeginInfo` object.
132
132
133
133
**Definition for `VkCommandBufferBeginInfo`**:
134
134
@@ -157,4 +157,26 @@ cmdBufBeginInfo.flags = 0;
157
157
cmdBufBeginInfo.pNext = NULL;
158
158
```
159
159
160
-
## Beginning Recording to Command Buffer
160
+
## Begin Recording to a Command Buffer
161
+
162
+
Now that we've allocated a command buffer and readied the information Vulkan needs to begin recording, we can call `vkBeginCommandBuffer`. This method will take a handle to our command buffer and put it in a recording state.
163
+
164
+
**Definition for `vkBeginCommandBuffer`**:
165
+
166
+
```cpp
167
+
VkResult vkBeginCommandBuffer(
168
+
VkCommandBuffer commandBuffer,
169
+
const VkCommandBufferBeginInfo* pBeginInfo);
170
+
```
171
+
172
+
**[Documentation](https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html#vkBeginCommandBuffer) for `vkBeginCommandBuffer`**:
173
+
174
+
- `commandBuffer` is the handle of the command buffer which is to be put in the recording state.
175
+
- `pBeginInfo` is an instance of the `VkCommandBufferBeginInfo` structure, which defines additional information about how the command buffer begins recording.
176
+
177
+
**Usage for `vkBeginCommandBuffer`**:
178
+
179
+
```cpp
180
+
result = vkBeginCommandBuffer(initialCmdBuffer, &cmdBufBeginInfo);
0 commit comments