Vulkan-Hpp
InstanceExtensionProperties.cpp
Go to the documentation of this file.
1 // Copyright(c) 2019, NVIDIA CORPORATION. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15 // VulkanHpp Samples : InstanceExtensionProperties
16 // Get global extension properties to know what extension are available to enable at CreateInstance
17 // time.
18 
19 #include <iostream>
20 #include <sstream>
21 #include <vulkan/vulkan.hpp>
22 
23 int main( int /*argc*/, char ** /*argv*/ )
24 {
25  try
26  {
27  /* VULKAN_KEY_START */
28 
29  std::vector<vk::ExtensionProperties> extensionProperties = vk::enumerateInstanceExtensionProperties();
30 
31  // sort the extensions alphabetically
32 
33  std::sort( extensionProperties.begin(),
34  extensionProperties.end(),
35  []( vk::ExtensionProperties const & a, vk::ExtensionProperties const & b ) { return strcmp( a.extensionName, b.extensionName ) < 0; } );
36 
37  std::cout << "Instance Extensions:" << std::endl;
38  for ( auto const & ep : extensionProperties )
39  {
40  std::cout << ep.extensionName << ":" << std::endl;
41  std::cout << "\tVersion: " << ep.specVersion << std::endl;
42  std::cout << std::endl;
43  }
44 
45  /* VULKAN_KEY_END */
46  }
47  catch ( vk::SystemError & err )
48  {
49  std::cout << "vk::SystemError: " << err.what() << std::endl;
50  exit( -1 );
51  }
52  catch ( std::exception & err )
53  {
54  std::cout << "std::exception: " << err.what() << std::endl;
55  exit( -1 );
56  }
57  catch ( ... )
58  {
59  std::cout << "unknown error\n";
60  exit( -1 );
61  }
62  return 0;
63 }
int main(int, char **)
void cout(vk::SurfaceCapabilitiesKHR const &surfaceCapabilities)
virtual const char * what() const VULKAN_HPP_NOEXCEPT
Definition: vulkan.hpp:6206
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE Result enumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pPropertyCount, vk::ExtensionProperties *pProperties, Dispatch const &d) VULKAN_HPP_NOEXCEPT