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
Copy file name to clipboardExpand all lines: 02_Development_environment.md
+124-2Lines changed: 124 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,7 +62,7 @@ As mentioned before, Vulkan by itself is a platform agnostic API and does not
62
62
include tools for creating a window to display the rendered results. To benefit
63
63
from the cross-platform advantages of Vulkan and to avoid the horrors of Win32,
64
64
we'll use the [GLFW library](http://www.glfw.org/) to create a window, which
65
-
supports both Windowsand Linux. There are other libraries available for this
65
+
supports Windows, Linux and MacOS. There are other libraries available for this
66
66
purpose, like [SDL](https://www.libsdl.org/), but the advantage of GLFW is that
67
67
it also abstracts away some of the other platform-specific things in Vulkan
68
68
besides just window creation.
@@ -266,7 +266,7 @@ As mentioned before, Vulkan by itself is a platform agnostic API and does not
266
266
include tools for creation a window to display the rendered results. To benefit
267
267
from the cross-platform advantages of Vulkan and to avoid the horrors of X11,
268
268
we'll use the [GLFW library](http://www.glfw.org/) to create a window, which
269
-
supports both Windowsand Linux. There are other libraries available for this
269
+
supports Windows, Linux and MacOS. There are other libraries available for this
270
270
purpose, like [SDL](https://www.libsdl.org/), but the advantage of GLFW is that
271
271
it also abstracts away some of the other platform-specific things in Vulkan
272
272
besides just window creation.
@@ -487,3 +487,125 @@ offline version of the entire Vulkan specification. Feel free to explore the
487
487
other files, but we won't need them for this tutorial.
488
488
489
489
You are now all set for [the real adventure](!Drawing_a_triangle/Setup/Base_code).
490
+
491
+
## MacOS
492
+
493
+
These instructions will assume you are using Xcode and the [Homebrew package manager](https://brew.sh/). Also, keep in mind that you will need at least MacOS version 10.11, and your device needs to support the [Metal API](https://en.wikipedia.org/wiki/Metal_(API)#Supported_GPUs).
494
+
495
+
### MoltenVK
496
+
497
+
For MacOS what we will be using to develop Vulkan application is [MoltenVK](https://moltengl.com/). This is a library that maps Vulkan to Apple's Metal graphics framework, with this you can take advantage of debugging and performance benefits of Apple's Metal framework.
498
+
499
+
To install and build MoltenVK go the the project's [github repository](https://github.com/KhronosGroup/MoltenVK) and follow the instructions. By the end you should have built one of the runtime distribution packages, either the Release or the Debug configuration. To make sure everything was done successfully, we will run one of the examples from the repository. Go to the folder where you cloned the repository, find and open the file `../MoltenVK/Demos/Demos.xcworkspace`. Now all the projects should open on Xcode, select the application `Cube-macOS`, build and run it. You should see the following:
500
+
501
+

502
+
503
+
### GLFW
504
+
505
+
As mentioned before, Vulkan by itself is a platform agnostic API and does not include tools for creation a window to display the rendered results. To benefit from the cross-platform advantages of Vulkan and to avoid the horrors of X11, we'll use the [GLFW library](http://www.glfw.org/) to create a window, which supports Windows, Linux and MacOS. There are other libraries available for this purpose, like [SDL](https://www.libsdl.org/), but the advantage of GLFW is that it also abstracts away some of the other platform-specific things in Vulkan besides just window creation.
506
+
507
+
To install GLFW on MacOS you can follow the same instructions to install it on Linux, so please refer to that topic on this chapter.
508
+
509
+
### GLM
510
+
511
+
Unlike DirectX 12, Vulkan does not include a library for linear algebra
512
+
operations, so we'll have to download one. [GLM](http://glm.g-truc.net/) is a
513
+
nice library that is designed for use with graphics APIs and is also commonly
514
+
used with OpenGL.
515
+
516
+
It is a header-only library that can be installed from the `glm` package:
517
+
518
+
```bash
519
+
brew install glm
520
+
```
521
+
522
+
### Setting up Xcode
523
+
524
+
Now that all the dependencies are installed we can set up a basic Xcode project for Vulkan. Most of the instructions here are essentially a lot of "plumbing" so we can get all the dependencies linked to the project.
525
+
526
+
Start Xcode and create a new Xcode project. On the window that will open select Application > Command Line Tool.
527
+
528
+

529
+
530
+
Select `Next`, write a name for the project and for `Language` select `C++`.
531
+
532
+

533
+
534
+
Press `Next` and the project should have been created. Now, let's change the code on the generated `main.cpp` file to the following code:
Xcode should already be complaining of errors such as libraries it cannot find. We will now start configuring the project to get rid of those errors. On the *Project Navigator* panel select your project. Open the *Build Settings* tab and then:
575
+
576
+
* Find the **Framework Search Paths** field and add a link to the `../MoltenVK/macOS` folder (which should be in the folder you clonned the MoltenVK project).
577
+
* Find the **Header Search Paths** field and add a link to `/usr/local/include` (this is where Homebrew install libraries, so the glm header files should be there), a link to `../glfw-3.2.1/include` for the glfw headers, and finally a link to `../MoltenVK/Package/Release/MoltenVK/include` for the Vulkan headers (in this example I built the framework for the Release configuration).
578
+
* Find the **Library Search Paths** field and add a link to `../glfw-3.2.1/src`.
579
+
580
+
It should look like so (obviously, paths will be different depending on where you placed on your files):
581
+
582
+

583
+
584
+
Above I have added the values for the Release configurations because it's the one I'm using, you just need to add the paths on the configuration that you picked.
585
+
586
+
Now, on the *General* tab, on **Linked Frameworks and Libraries** you will need to add the following frameworks:
587
+
588
+
* libc++.tbd
589
+
* libglfw3.a
590
+
* Should be at `../glfw-3.2.1/src/libglfw3.a`.
591
+
* MoltenVK.framework
592
+
* Should be at `../MoltenVK/Package/Release/MoltenVK/macOS/MoltenVK.framework`.
593
+
* Metal.framework
594
+
* IOSurface.framework
595
+
* QuartzCore.framework
596
+
* IOKit.framework
597
+
* Foundation.framework
598
+
* Cocoa.framework
599
+
* CoreVideo.framework
600
+
601
+
Should look like:
602
+
603
+

604
+
605
+
Finally, you should be all set! Now if you run the project (remembering to setting the build configuration to Debug or Release depending on the configuration you chose) you should see the following:
606
+
607
+

608
+
609
+
The number of extensions should be non-zero. The other logs are from the libraries, you might get different messages from those depending on tour configuration.
610
+
611
+
You are now all set for [the real thing](!Drawing_a_triangle/Setup/Base_code).
0 commit comments