aboutsummaryrefslogtreecommitdiff
path: root/contrib/glfw/glfw-3.3.5.bin.WIN64/docs/html/vulkan_guide.html
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/glfw/glfw-3.3.5.bin.WIN64/docs/html/vulkan_guide.html')
-rw-r--r--contrib/glfw/glfw-3.3.5.bin.WIN64/docs/html/vulkan_guide.html188
1 files changed, 188 insertions, 0 deletions
diff --git a/contrib/glfw/glfw-3.3.5.bin.WIN64/docs/html/vulkan_guide.html b/contrib/glfw/glfw-3.3.5.bin.WIN64/docs/html/vulkan_guide.html
new file mode 100644
index 0000000..1d41421
--- /dev/null
+++ b/contrib/glfw/glfw-3.3.5.bin.WIN64/docs/html/vulkan_guide.html
@@ -0,0 +1,188 @@
1<!DOCTYPE html>
2<html lang="en">
3<head>
4<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
5<meta name="viewport" content="width=device-width, initial-scale=1.0">
6<meta http-equiv="X-UA-Compatible" content="IE=9"/>
7<meta name="generator" content="Doxygen 1.9.2"/>
8<title>GLFW: Vulkan guide</title>
9<link href="tabs.css" rel="stylesheet" type="text/css"/>
10<script type="text/javascript" src="jquery.js"></script>
11<script type="text/javascript" src="dynsections.js"></script>
12<link href="search/search.css" rel="stylesheet" type="text/css"/>
13<script type="text/javascript" src="search/searchdata.js"></script>
14<script type="text/javascript" src="search/search.js"></script>
15<link href="doxygen.css" rel="stylesheet" type="text/css" />
16<link href="extra.css" rel="stylesheet" type="text/css"/>
17</head>
18<body>
19<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
20<div id="titlearea">
21 <div class="glfwheader">
22 <a href="https://www.glfw.org/" id="glfwhome">GLFW</a>
23 <ul class="glfwnavbar">
24 <li><a href="https://www.glfw.org/documentation.html">Documentation</a></li>
25 <li><a href="https://www.glfw.org/download.html">Download</a></li>
26 <li><a href="https://www.glfw.org/community.html">Community</a></li>
27 </ul>
28 </div>
29</div>
30<!-- end header part -->
31<!-- Generated by Doxygen 1.9.2 -->
32<script type="text/javascript">
33/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
34var searchBox = new SearchBox("searchBox", "search",'Search','.html');
35/* @license-end */
36</script>
37<script type="text/javascript" src="menudata.js"></script>
38<script type="text/javascript" src="menu.js"></script>
39<script type="text/javascript">
40/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
41$(function() {
42 initMenu('',true,false,'search.php','Search');
43 $(document).ready(function() { init_search(); });
44});
45/* @license-end */
46</script>
47<div id="main-nav"></div>
48<!-- window showing the filter options -->
49<div id="MSearchSelectWindow"
50 onmouseover="return searchBox.OnSearchSelectShow()"
51 onmouseout="return searchBox.OnSearchSelectHide()"
52 onkeydown="return searchBox.OnSearchSelectKey(event)">
53</div>
54
55<!-- iframe showing the search results (closed by default) -->
56<div id="MSearchResultsWindow">
57<iframe src="javascript:void(0)" frameborder="0"
58 name="MSearchResults" id="MSearchResults">
59</iframe>
60</div>
61
62</div><!-- top -->
63<div><div class="header">
64 <div class="headertitle"><div class="title">Vulkan guide </div></div>
65</div><!--header-->
66<div class="contents">
67<div class="toc"><h3>Table of Contents</h3>
68<ul><li class="level1"><a href="#vulkan_loader">Linking against the Vulkan loader</a></li>
69<li class="level1"><a href="#vulkan_include">Including the Vulkan and GLFW header files</a></li>
70<li class="level1"><a href="#vulkan_support">Querying for Vulkan support</a><ul><li class="level2"><a href="#vulkan_proc">Querying Vulkan function pointers</a></li>
71</ul>
72</li>
73<li class="level1"><a href="#vulkan_ext">Querying required Vulkan extensions</a></li>
74<li class="level1"><a href="#vulkan_present">Querying for Vulkan presentation support</a></li>
75<li class="level1"><a href="#vulkan_window">Creating the window</a></li>
76<li class="level1"><a href="#vulkan_surface">Creating a Vulkan window surface</a></li>
77</ul>
78</div>
79<div class="textblock"><p >This guide is intended to fill the gaps between the official <a href="https://www.khronos.org/vulkan/">Vulkan resources</a> and the rest of the GLFW documentation and is not a replacement for either. It assumes some familiarity with Vulkan concepts like loaders, devices, queues and surfaces and leaves it to the Vulkan documentation to explain the details of Vulkan functions.</p>
80<p >To develop for Vulkan you should download the <a href="https://vulkan.lunarg.com/">LunarG Vulkan SDK</a> for your platform. Apart from headers and link libraries, they also provide the validation layers necessary for development.</p>
81<p >The <a href="https://vulkan-tutorial.com/">Vulkan Tutorial</a> has more information on how to use GLFW and Vulkan. The <a href="https://github.com/KhronosGroup/Vulkan-Samples">Khronos Vulkan Samples</a> also use GLFW, although with a small framework in between.</p>
82<p >For details on a specific Vulkan support function, see the <a class="el" href="group__vulkan.html">Vulkan support reference</a>. There are also guides for the other areas of the GLFW API.</p>
83<ul>
84<li><a class="el" href="intro_guide.html">Introduction to the API</a></li>
85<li><a class="el" href="window_guide.html">Window guide</a></li>
86<li><a class="el" href="context_guide.html">Context guide</a></li>
87<li><a class="el" href="monitor_guide.html">Monitor guide</a></li>
88<li><a class="el" href="input_guide.html">Input guide</a></li>
89</ul>
90<h1><a class="anchor" id="vulkan_loader"></a>
91Linking against the Vulkan loader</h1>
92<p >By default, GLFW will look for the Vulkan loader on demand at runtime via its standard name (<code>vulkan-1.dll</code> on Windows, <code>libvulkan.so.1</code> on Linux and other Unix-like systems and <code>libvulkan.1.dylib</code> on macOS). This means that GLFW does not need to be linked against the loader. However, it also means that if you are using the static library form of the Vulkan loader GLFW will either fail to find it or (worse) use the wrong one.</p>
93<p >The <a class="el" href="compile_guide.html#GLFW_VULKAN_STATIC">GLFW_VULKAN_STATIC</a> CMake option makes GLFW call the Vulkan loader directly instead of dynamically loading it at runtime. Not linking against the Vulkan loader will then be a compile-time error.</p>
94<p ><b>macOS:</b> Because the Vulkan loader and ICD are not installed globally on macOS, you need to set up the application bundle according to the LunarG SDK documentation. This is explained in more detail in the <a href="https://vulkan.lunarg.com/doc/sdk/latest/mac/getting_started.html">SDK documentation for macOS</a>.</p>
95<h1><a class="anchor" id="vulkan_include"></a>
96Including the Vulkan and GLFW header files</h1>
97<p >To include the Vulkan header, define <a class="el" href="build_guide.html#GLFW_INCLUDE_VULKAN">GLFW_INCLUDE_VULKAN</a> before including the GLFW header.</p>
98<div class="fragment"><div class="line"><span class="preprocessor">#define GLFW_INCLUDE_VULKAN</span></div>
99<div class="line"><span class="preprocessor">#include &lt;GLFW/glfw3.h&gt;</span></div>
100</div><!-- fragment --><p >If you instead want to include the Vulkan header from a custom location or use your own custom Vulkan header then do this before the GLFW header.</p>
101<div class="fragment"><div class="line"><span class="preprocessor">#include &lt;path/to/vulkan.h&gt;</span></div>
102<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="glfw3_8h.html">GLFW/glfw3.h</a>&gt;</span></div>
103<div class="ttc" id="aglfw3_8h_html"><div class="ttname"><a href="glfw3_8h.html">glfw3.h</a></div><div class="ttdoc">The header of the GLFW 3 API.</div></div>
104</div><!-- fragment --><p >Unless a Vulkan header is included, either by the GLFW header or above it, any GLFW functions that take or return Vulkan types will not be declared.</p>
105<p >The <code>VK_USE_PLATFORM_*_KHR</code> macros do not need to be defined for the Vulkan part of GLFW to work. Define them only if you are using these extensions directly.</p>
106<h1><a class="anchor" id="vulkan_support"></a>
107Querying for Vulkan support</h1>
108<p >If you are linking directly against the Vulkan loader then you can skip this section. The canonical desktop loader library exports all Vulkan core and Khronos extension functions, allowing them to be called directly.</p>
109<p >If you are loading the Vulkan loader dynamically instead of linking directly against it, you can check for the availability of a loader and ICD with <a class="el" href="group__vulkan.html#ga2e7f30931e02464b5bc8d0d4b6f9fe2b">glfwVulkanSupported</a>.</p>
110<div class="fragment"><div class="line"><span class="keywordflow">if</span> (<a class="code hl_function" href="group__vulkan.html#ga2e7f30931e02464b5bc8d0d4b6f9fe2b">glfwVulkanSupported</a>())</div>
111<div class="line">{</div>
112<div class="line"> <span class="comment">// Vulkan is available, at least for compute</span></div>
113<div class="line">}</div>
114<div class="ttc" id="agroup__vulkan_html_ga2e7f30931e02464b5bc8d0d4b6f9fe2b"><div class="ttname"><a href="group__vulkan.html#ga2e7f30931e02464b5bc8d0d4b6f9fe2b">glfwVulkanSupported</a></div><div class="ttdeci">int glfwVulkanSupported(void)</div><div class="ttdoc">Returns whether the Vulkan loader and an ICD have been found.</div></div>
115</div><!-- fragment --><p >This function returns <code>GLFW_TRUE</code> if the Vulkan loader and any minimally functional ICD was found.</p>
116<p >If one or both were not found, calling any other Vulkan related GLFW function will generate a <a class="el" href="group__errors.html#ga56882b290db23261cc6c053c40c2d08e">GLFW_API_UNAVAILABLE</a> error.</p>
117<h2><a class="anchor" id="vulkan_proc"></a>
118Querying Vulkan function pointers</h2>
119<p >To load any Vulkan core or extension function from the found loader, call <a class="el" href="group__vulkan.html#gadf228fac94c5fd8f12423ec9af9ff1e9">glfwGetInstanceProcAddress</a>. To load functions needed for instance creation, pass <code>NULL</code> as the instance.</p>
120<div class="fragment"><div class="line">PFN_vkCreateInstance pfnCreateInstance = (PFN_vkCreateInstance)</div>
121<div class="line"> <a class="code hl_function" href="group__vulkan.html#gadf228fac94c5fd8f12423ec9af9ff1e9">glfwGetInstanceProcAddress</a>(NULL, <span class="stringliteral">&quot;vkCreateInstance&quot;</span>);</div>
122<div class="ttc" id="agroup__vulkan_html_gadf228fac94c5fd8f12423ec9af9ff1e9"><div class="ttname"><a href="group__vulkan.html#gadf228fac94c5fd8f12423ec9af9ff1e9">glfwGetInstanceProcAddress</a></div><div class="ttdeci">GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, const char *procname)</div><div class="ttdoc">Returns the address of the specified Vulkan instance function.</div></div>
123</div><!-- fragment --><p >Once you have created an instance, you can load from it all other Vulkan core functions and functions from any instance extensions you enabled.</p>
124<div class="fragment"><div class="line">PFN_vkCreateDevice pfnCreateDevice = (PFN_vkCreateDevice)</div>
125<div class="line"> <a class="code hl_function" href="group__vulkan.html#gadf228fac94c5fd8f12423ec9af9ff1e9">glfwGetInstanceProcAddress</a>(instance, <span class="stringliteral">&quot;vkCreateDevice&quot;</span>);</div>
126</div><!-- fragment --><p >This function in turn calls <code>vkGetInstanceProcAddr</code>. If that fails, the function falls back to a platform-specific query of the Vulkan loader (i.e. <code>dlsym</code> or <code>GetProcAddress</code>). If that also fails, the function returns <code>NULL</code>. For more information about <code>vkGetInstanceProcAddr</code>, see the Vulkan documentation.</p>
127<p >Vulkan also provides <code>vkGetDeviceProcAddr</code> for loading device-specific versions of Vulkan function. This function can be retrieved from an instance with <a class="el" href="group__vulkan.html#gadf228fac94c5fd8f12423ec9af9ff1e9">glfwGetInstanceProcAddress</a>.</p>
128<div class="fragment"><div class="line">PFN_vkGetDeviceProcAddr pfnGetDeviceProcAddr = (PFN_vkGetDeviceProcAddr)</div>
129<div class="line"> <a class="code hl_function" href="group__vulkan.html#gadf228fac94c5fd8f12423ec9af9ff1e9">glfwGetInstanceProcAddress</a>(instance, <span class="stringliteral">&quot;vkGetDeviceProcAddr&quot;</span>);</div>
130</div><!-- fragment --><p >Device-specific functions may execute a little bit faster, due to not having to dispatch internally based on the device passed to them. For more information about <code>vkGetDeviceProcAddr</code>, see the Vulkan documentation.</p>
131<h1><a class="anchor" id="vulkan_ext"></a>
132Querying required Vulkan extensions</h1>
133<p >To do anything useful with Vulkan you need to create an instance. If you want to use Vulkan to render to a window, you must enable the instance extensions GLFW requires to create Vulkan surfaces.</p>
134<p >To query the instance extensions required, call <a class="el" href="group__vulkan.html#ga99ad342d82f4a3421e2864978cb6d1d6">glfwGetRequiredInstanceExtensions</a>.</p>
135<div class="fragment"><div class="line">uint32_t count;</div>
136<div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span>** extensions = <a class="code hl_function" href="group__vulkan.html#ga99ad342d82f4a3421e2864978cb6d1d6">glfwGetRequiredInstanceExtensions</a>(&amp;count);</div>
137<div class="ttc" id="agroup__vulkan_html_ga99ad342d82f4a3421e2864978cb6d1d6"><div class="ttname"><a href="group__vulkan.html#ga99ad342d82f4a3421e2864978cb6d1d6">glfwGetRequiredInstanceExtensions</a></div><div class="ttdeci">const char ** glfwGetRequiredInstanceExtensions(uint32_t *count)</div><div class="ttdoc">Returns the Vulkan instance extensions required by GLFW.</div></div>
138</div><!-- fragment --><p >These extensions must all be enabled when creating instances that are going to be passed to <a class="el" href="group__vulkan.html#gaff3823355cdd7e2f3f9f4d9ea9518d92">glfwGetPhysicalDevicePresentationSupport</a> and <a class="el" href="group__vulkan.html#ga1a24536bec3f80b08ead18e28e6ae965">glfwCreateWindowSurface</a>. The set of extensions will vary depending on platform and may also vary depending on graphics drivers and other factors.</p>
139<p >If it fails it will return <code>NULL</code> and GLFW will not be able to create Vulkan window surfaces. You can still use Vulkan for off-screen rendering and compute work.</p>
140<p >If successful the returned array will always include <code>VK_KHR_surface</code>, so if you don't require any additional extensions you can pass this list directly to the <code>VkInstanceCreateInfo</code> struct.</p>
141<div class="fragment"><div class="line">VkInstanceCreateInfo ici;</div>
142<div class="line"> </div>
143<div class="line">memset(&amp;ici, 0, <span class="keyword">sizeof</span>(ici));</div>
144<div class="line">ici.enabledExtensionCount = count;</div>
145<div class="line">ici.ppEnabledExtensionNames = extensions;</div>
146<div class="line">...</div>
147</div><!-- fragment --><p >Additional extensions may be required by future versions of GLFW. You should check whether any extensions you wish to enable are already in the returned array, as it is an error to specify an extension more than once in the <code>VkInstanceCreateInfo</code> struct.</p>
148<h1><a class="anchor" id="vulkan_present"></a>
149Querying for Vulkan presentation support</h1>
150<p >Not every queue family of every Vulkan device can present images to surfaces. To check whether a specific queue family of a physical device supports image presentation without first having to create a window and surface, call <a class="el" href="group__vulkan.html#gaff3823355cdd7e2f3f9f4d9ea9518d92">glfwGetPhysicalDevicePresentationSupport</a>.</p>
151<div class="fragment"><div class="line"><span class="keywordflow">if</span> (<a class="code hl_function" href="group__vulkan.html#gaff3823355cdd7e2f3f9f4d9ea9518d92">glfwGetPhysicalDevicePresentationSupport</a>(instance, physical_device, queue_family_index))</div>
152<div class="line">{</div>
153<div class="line"> <span class="comment">// Queue family supports image presentation</span></div>
154<div class="line">}</div>
155<div class="ttc" id="agroup__vulkan_html_gaff3823355cdd7e2f3f9f4d9ea9518d92"><div class="ttname"><a href="group__vulkan.html#gaff3823355cdd7e2f3f9f4d9ea9518d92">glfwGetPhysicalDevicePresentationSupport</a></div><div class="ttdeci">int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily)</div><div class="ttdoc">Returns whether the specified queue family can present images.</div></div>
156</div><!-- fragment --><p >The <code>VK_KHR_surface</code> extension additionally provides the <code>vkGetPhysicalDeviceSurfaceSupportKHR</code> function, which performs the same test on an existing Vulkan surface.</p>
157<h1><a class="anchor" id="vulkan_window"></a>
158Creating the window</h1>
159<p >Unless you will be using OpenGL or OpenGL ES with the same window as Vulkan, there is no need to create a context. You can disable context creation with the <a class="el" href="window_guide.html#GLFW_CLIENT_API_hint">GLFW_CLIENT_API</a> hint.</p>
160<div class="fragment"><div class="line"><a class="code hl_function" href="group__window.html#ga7d9c8c62384b1e2821c4dc48952d2033">glfwWindowHint</a>(<a class="code hl_define" href="group__window.html#ga649309cf72a3d3de5b1348ca7936c95b">GLFW_CLIENT_API</a>, <a class="code hl_define" href="glfw3_8h.html#a8f6dcdc968d214ff14779564f1389264">GLFW_NO_API</a>);</div>
161<div class="line"><a class="code hl_typedef" href="group__window.html#ga3c96d80d363e67d13a41b5d1821f3242">GLFWwindow</a>* window = <a class="code hl_function" href="group__window.html#ga3555a418df92ad53f917597fe2f64aeb">glfwCreateWindow</a>(640, 480, <span class="stringliteral">&quot;Window Title&quot;</span>, NULL, NULL);</div>
162<div class="ttc" id="aglfw3_8h_html_a8f6dcdc968d214ff14779564f1389264"><div class="ttname"><a href="glfw3_8h.html#a8f6dcdc968d214ff14779564f1389264">GLFW_NO_API</a></div><div class="ttdeci">#define GLFW_NO_API</div><div class="ttdef"><b>Definition:</b> glfw3.h:1037</div></div>
163<div class="ttc" id="agroup__window_html_ga3555a418df92ad53f917597fe2f64aeb"><div class="ttname"><a href="group__window.html#ga3555a418df92ad53f917597fe2f64aeb">glfwCreateWindow</a></div><div class="ttdeci">GLFWwindow * glfwCreateWindow(int width, int height, const char *title, GLFWmonitor *monitor, GLFWwindow *share)</div><div class="ttdoc">Creates a window and its associated context.</div></div>
164<div class="ttc" id="agroup__window_html_ga3c96d80d363e67d13a41b5d1821f3242"><div class="ttname"><a href="group__window.html#ga3c96d80d363e67d13a41b5d1821f3242">GLFWwindow</a></div><div class="ttdeci">struct GLFWwindow GLFWwindow</div><div class="ttdoc">Opaque window object.</div><div class="ttdef"><b>Definition:</b> glfw3.h:1186</div></div>
165<div class="ttc" id="agroup__window_html_ga649309cf72a3d3de5b1348ca7936c95b"><div class="ttname"><a href="group__window.html#ga649309cf72a3d3de5b1348ca7936c95b">GLFW_CLIENT_API</a></div><div class="ttdeci">#define GLFW_CLIENT_API</div><div class="ttdoc">Context client API hint and attribute.</div><div class="ttdef"><b>Definition:</b> glfw3.h:950</div></div>
166<div class="ttc" id="agroup__window_html_ga7d9c8c62384b1e2821c4dc48952d2033"><div class="ttname"><a href="group__window.html#ga7d9c8c62384b1e2821c4dc48952d2033">glfwWindowHint</a></div><div class="ttdeci">void glfwWindowHint(int hint, int value)</div><div class="ttdoc">Sets the specified window hint to the desired value.</div></div>
167</div><!-- fragment --><p >See <a class="el" href="context_guide.html#context_less">Windows without contexts</a> for more information.</p>
168<h1><a class="anchor" id="vulkan_surface"></a>
169Creating a Vulkan window surface</h1>
170<p >You can create a Vulkan surface (as defined by the <code>VK_KHR_surface</code> extension) for a GLFW window with <a class="el" href="group__vulkan.html#ga1a24536bec3f80b08ead18e28e6ae965">glfwCreateWindowSurface</a>.</p>
171<div class="fragment"><div class="line">VkSurfaceKHR surface;</div>
172<div class="line">VkResult err = <a class="code hl_function" href="group__vulkan.html#ga1a24536bec3f80b08ead18e28e6ae965">glfwCreateWindowSurface</a>(instance, window, NULL, &amp;surface);</div>
173<div class="line"><span class="keywordflow">if</span> (err)</div>
174<div class="line">{</div>
175<div class="line"> <span class="comment">// Window surface creation failed</span></div>
176<div class="line">}</div>
177<div class="ttc" id="agroup__vulkan_html_ga1a24536bec3f80b08ead18e28e6ae965"><div class="ttname"><a href="group__vulkan.html#ga1a24536bec3f80b08ead18e28e6ae965">glfwCreateWindowSurface</a></div><div class="ttdeci">VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow *window, const VkAllocationCallbacks *allocator, VkSurfaceKHR *surface)</div><div class="ttdoc">Creates a Vulkan surface for the specified window.</div></div>
178</div><!-- fragment --><p >If an OpenGL or OpenGL ES context was created on the window, the context has ownership of the presentation on the window and a Vulkan surface cannot be created.</p>
179<p >It is your responsibility to destroy the surface. GLFW does not destroy it for you. Call <code>vkDestroySurfaceKHR</code> function from the same extension to destroy it. </p>
180</div></div><!-- contents -->
181</div><!-- PageDoc -->
182<address class="footer">
183<p>
184Last update on Thu Oct 28 2021 for GLFW 3.3.5
185</p>
186</address>
187</body>
188</html>