Skip to content

Commit 4f45f46

Browse files
Fixed chapters 4, 5. Renamed class. Minor updates
1 parent c11afcb commit 4f45f46

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+665
-506
lines changed

.buildconfig

Lines changed: 0 additions & 6 deletions
This file was deleted.

Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
SUBDIRS = chap02 chap03 chap04 chap05 chap06 chap07 chap08 chap09 chap10
2+

README.md

Lines changed: 23 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,40 @@
11
# Vulkan API
22

3-
Hello everyone. This is going to be a technical book about the newly published Vulkan specification. We'll go over different topics such as...
3+
## An Introduction
4+
5+
This is going to be a technical book about the newly published Vulkan specification. We'll go over different topics such as:
46

5-
- Extensions
67
- Getting started
78
- Instances
8-
- Physical & logical devices
9-
- Queues
10-
- Surfaces
11-
- Swap chains
9+
- Physical and logical devices
1210
- Windowing across different platforms
13-
- And more!
11+
- Surfaces
12+
- Swapchains
13+
- Image layouts
14+
- Image views
15+
- Please see the table-of-contents for more!
16+
17+
## Resources
1418

15-
# Resources
19+
While resources are added everyday, there are a few I'd thoroughly recommend checking out:
1620

1721
- [Vulkan Quick Reference v1.0](https://www.khronos.org/files/vulkan10-reference-guide.pdf)
1822
- [Vulkan Specification v1.0.9](https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html)
1923
- [Vulkan Specification v1.0.9 + WSI Extensions](https://www.khronos.org/registry/vulkan/specs/1.0-wsi_extensions/xhtml/vkspec.html)
2024
- [Sascha Willem's Vulkan Samples](https://github.com/SaschaWillems/Vulkan)
2125
- [Vulkan in 30 Minutes](https://renderdoc.org/vulkan-in-30-minutes.html)
2226

23-
# Code
24-
25-
You can find the Github repository [here](https://github.com/HarryLovesCode/Vulkan-API-Book). For now, only Linux and Windows are **officially** supported.
26-
27-
# Building the Book
28-
29-
Currently there are two ways of building the book.
30-
31-
### Pandoc (Preferred)
32-
33-
Use the `book.sh` script which runs Pandoc and produces the book in `epub` and `pdf` formats.
34-
35-
### Gitbook
36-
37-
You can find information on how to get it [here](https://github.com/GitbookIO/gitbook-cli). Then simply run:
38-
39-
```sh
40-
gitbook build
41-
```
27+
## Code
4228

43-
In the root directory.
29+
You can find the repository on Github at [HarryLovesCode/Vulkan-API-Book](https://github.com/HarryLovesCode/Vulkan-API-Book). For now, only Linux and Windows are **officially** supported. However, Android support is in the works.
4430

45-
# Reading the Book
31+
## Reading the Book
4632

47-
You can find the latest stable version [on the release page](https://github.com/HarryLovesCode/Vulkan-API-Book/releases).
33+
You can find the latest stable version [on the Github releases page](https://github.com/HarryLovesCode/Vulkan-API-Book/releases). Otherwise, you can read it on [Gitbook](https://harrylovescode.gitbooks.io/vulkan-api/content/). If you'd like to build it yourself, you will need `pandoc`, `xetex` (for Linux), and `latex-extras` installed.
4834

49-
# Building Code on Linux
35+
## Building Code on Linux
5036

51-
To build on Linux, use the following commands:
37+
To build on Linux, you will need to make sure you have Vulkan headers available. Also, you will need `autotools`. When in doubt, look at your distribution's package repositories. You can use these commands.
5238

5339
```sh
5440
git clone https://github.com/HarryLovesCode/Vulkan-API-Book
@@ -59,12 +45,12 @@ autoreconf --install
5945
make -j4
6046
```
6147

62-
Once you've done that, you should find all the binaries located in the `./bin` folder.
48+
Once you've done that, you will find all the binaries located in the `./bin` folder.
6349

64-
# Building Code on Windows
50+
## Building Code on Windows
6551

66-
To build on Windows, you'll need Visual Studio 2015. You can find the Visual Studio solution in the root directory of the repository. Just open that and you can pick and choose which chapters to build and run.
52+
To build on Windows, you'll need Visual Studio 2015. You can find the Visual Studio solution in the root directory of the repository. Just open that, choose a startup project, and you're ready to go.
6753

68-
# Who am I?
54+
## A Little About Me
6955

70-
I'm Harry and I'm a young developer who enjoys 3D graphics. I've worked with WebGL, OpenGL, and DirectX and when I heard about Vulkan, I was excited to get started! This is, in a way, and experiment because I'm publishing as I go. Thus, the book may be rough around the edges. Feel free to submit issues or pull requests on Github and add inline comments through Gitbook.
56+
I'm Harry and I'm a young developer who enjoys 3D graphics. I've worked with WebGL, OpenGL, and DirectX and when I heard about Vulkan, I was excited to get started. The publishing of this book is, in a way, and experiment because I'm publishing as I go. Thus, the book may be rough around the edges. Feel free to submit issues or pull requests on Github and add inline comments through Gitbook.

book.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ You can find the repository on Github at [HarryLovesCode/Vulkan-API-Book](https:
3535

3636
## Reading the Book
3737

38-
You can find the latest stable version [on the Github releases page](https://github.com/HarryLovesCode/Vulkan-API-Book/releases). Otherwise, you can read it on [Gitbook](https://harrylovescode.gitbooks.io/vulkan-api/content/). If you'd like to build it yourself, you will need *pandoc*, *xetex* (for Linux), and *latex extras* installed.
38+
You can find the latest stable version [on the Github releases page](https://github.com/HarryLovesCode/Vulkan-API-Book/releases). Otherwise, you can read it on [Gitbook](https://harrylovescode.gitbooks.io/vulkan-api/content/). If you'd like to build it yourself, you will need `pandoc`, `xetex` (for Linux), and `latex-extras` installed.
3939

4040
## Building Code on Linux
4141

book.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@ pandoc book.md \
88
chap04/chap04.md \
99
chap04/chap04-linux.md \
1010
chap04/chap04-windows.md \
11-
chap05/chap05.md \
11+
chap05/chap05_0.md \
1212
chap05/chap05-windows.md \
1313
chap05/chap05-linux.md \
14+
chap05/chap05_1.md \
1415
chap06/chap06.md \
1516
chap07/chap07.md \
1617
chap08/chap08.md \
1718
chap09/chap09.md \
1819
--toc \
1920
--epub-stylesheet book.css \
20-
-o VulkanApiBook.epub
21+
-o VulkanApiBook.epub
2122

2223
# Generate the .pdf version of the book
2324
echo "Generating PDF"
@@ -27,9 +28,10 @@ pandoc book.md \
2728
chap04/chap04.md \
2829
chap04/chap04-linux.md \
2930
chap04/chap04-windows.md \
30-
chap05/chap05.md \
31+
chap05/chap05_0.md \
3132
chap05/chap05-windows.md \
3233
chap05/chap05-linux.md \
34+
chap05/chap05_1.md \
3335
chap06/chap06.md \
3436
chap07/chap07.md \
3537
chap08/chap08.md \
@@ -43,4 +45,4 @@ pandoc book.md \
4345
-V geometry:margin="2.0cm" \
4446
--chapters \
4547
--highlight-style tango \
46-
-o VulkanApiBook.pdf
48+
-o VulkanApiBook.pdf

chap02/Main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
#include "VulkanExample.hpp"
1+
#include "VulkanSwapchain.hpp"
22

3-
int main(int argc, char* argv[]) { VulkanExample ve = VulkanExample(); }
3+
int main(int argc, char* argv[]) { VulkanSwapchain ve = VulkanSwapchain(); }

chap02/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
bin_PROGRAMS = $(top_builddir)/bin/chap02
2-
__top_builddir__bin_chap02_SOURCES = Main.cpp VulkanExample.cpp
2+
__top_builddir__bin_chap02_SOURCES = Main.cpp VulkanSwapchain.cpp
33
__top_builddir__bin_chap02_CPPFLAGS = -std=c++11 -DVK_USE_PLATFORM_XCB_KHR
44
__top_builddir__bin_chap02_LDFLAGS = -lvulkan
55

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
#include "VulkanExample.hpp"
1+
#include "VulkanSwapchain.hpp"
22

3-
VulkanExample::VulkanExample() { initInstance(); }
3+
VulkanSwapchain::VulkanSwapchain() { initInstance(); }
44

5-
VulkanExample::~VulkanExample() { vkDestroyInstance(instance, NULL); }
5+
VulkanSwapchain::~VulkanSwapchain() { vkDestroyInstance(instance, NULL); }
66

7-
void VulkanExample::exitOnError(const char* msg) {
7+
void VulkanSwapchain::exitOnError(const char* msg) {
88
fputs(msg, stderr);
99
exit(EXIT_FAILURE);
1010
}
1111

12-
void VulkanExample::initInstance() {
12+
void VulkanSwapchain::initInstance() {
1313
VkApplicationInfo appInfo = {};
1414
appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
1515
appInfo.pNext = NULL;
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
#define VULKAN_EXAMPLE_HPP
33

44
#include <stdio.h>
5+
#include <stdlib.h>
56
#include <vector>
67

78
#include <vulkan/vulkan.h>
89

9-
class VulkanExample {
10+
class VulkanSwapchain {
1011
private:
1112
void exitOnError(const char* msg);
1213
void initInstance();
@@ -17,8 +18,8 @@ class VulkanExample {
1718
VkInstance instance;
1819

1920
public:
20-
VulkanExample();
21-
virtual ~VulkanExample();
21+
VulkanSwapchain();
22+
virtual ~VulkanSwapchain();
2223
};
2324

2425
#endif // VULKAN_EXAMPLE_HPP

chap02/chap02.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@ Before we are able to start using Vulkan, we must first create an instance. A `V
44

55
```cpp
66
#include <stdio.h>
7+
#include <stdlib.h>
78
#include <vector>
9+
810
#include <vulkan/vulkan.h>
911
```
1012

11-
We'll be storing all of our variables in a class we'll call `VulkanExample` for now. The code will start out looking like:
13+
We'll be storing all of our variables in a class we'll call `VulkanSwapchain` for now. The code will start out looking like:
1214

1315
```cpp
14-
class VulkanExample {
16+
class VulkanSwapchain {
1517
private:
1618
void exitOnError(const char* msg);
1719
void initInstance();
@@ -21,8 +23,8 @@ class VulkanExample {
2123

2224
VkInstance instance;
2325
public:
24-
VulkanExample();
25-
virtual ~VulkanExample();
26+
VulkanSwapchain();
27+
virtual ~VulkanSwapchain();
2628
};
2729
```
2830
@@ -69,7 +71,7 @@ appInfo.apiVersion = VK_MAKE_VERSION(1, 0, 3);
6971

7072
You'll notice that for `apiVersion`, I am using `VK_MAKE_VERSION`. This allows the developer to specify a targeted Vulkan version. We'll see later that if the version we try to get is unsupported, we'll get an error called `VK_ERROR_INCOMPATIBLE_DRIVER`.
7173

72-
## Instance Creation Information
74+
## Instance Create Information
7375

7476
`VkInstanceCreateInfo` will be used to inform Vulkan of our application info, layers we'll be using, and extensions we want.
7577

@@ -178,7 +180,7 @@ if (res == VK_ERROR_INCOMPATIBLE_DRIVER) {
178180
Our `exitOnError` method is simple at the moment. We'll make some minor changes to it when we start working with windows, but for now, this will fulfill our needs:
179181

180182
```cpp
181-
void VulkanExample::exitOnError(const char* msg) {
183+
void VulkanSwapchain::exitOnError(const char* msg) {
182184
fputs(msg, stderr);
183185
exit(EXIT_FAILURE);
184186
}
@@ -189,7 +191,7 @@ void VulkanExample::exitOnError(const char* msg) {
189191
Exiting should be graceful if possible. In the case that our destructor is called, we will destroy the instance we created. Afterwards, the program will exit. The destructor looks like this:
190192
191193
```cpp
192-
VulkanExample::~VulkanExample() {
194+
VulkanSwapchain::~VulkanSwapchain() {
193195
vkDestroyInstance(instance, NULL);
194196
}
195197
```

0 commit comments

Comments
 (0)