Vulkan-Hpp
InstanceVersion.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 : InstanceVersion
16 // Get the version of instance-level functionality supported by the implementation.
17 
18 #include <iostream>
19 #include <sstream>
20 #include <vulkan/vulkan.hpp>
21 
22 std::string decodeAPIVersion( uint32_t apiVersion )
23 {
24  return std::to_string( VK_VERSION_MAJOR( apiVersion ) ) + "." + std::to_string( VK_VERSION_MINOR( apiVersion ) ) + "." +
25  std::to_string( VK_VERSION_PATCH( apiVersion ) );
26 }
27 
28 int main( int /*argc*/, char ** /*argv*/ )
29 {
30  try
31  {
32  /* VULKAN_KEY_START */
33 
34  uint32_t apiVersion = vk::enumerateInstanceVersion();
35  std::cout << "APIVersion = " << decodeAPIVersion( apiVersion ) << std::endl;
36 
37  /* VULKAN_KEY_END */
38  }
39  catch ( vk::SystemError & err )
40  {
41  std::cout << "vk::SystemError: " << err.what() << std::endl;
42  exit( -1 );
43  }
44  catch ( std::exception & err )
45  {
46  std::cout << "std::exception: " << err.what() << std::endl;
47  exit( -1 );
48  }
49  catch ( ... )
50  {
51  std::cout << "unknown error\n";
52  exit( -1 );
53  }
54  return 0;
55 }
int main(int, char **)
std::string decodeAPIVersion(uint32_t apiVersion)
void cout(vk::SurfaceCapabilitiesKHR const &surfaceCapabilities)
virtual const char * what() const VULKAN_HPP_NOEXCEPT
Definition: vulkan.hpp:6206
VULKAN_HPP_INLINE std::string to_string(FormatFeatureFlags value)
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE Result enumerateInstanceVersion(uint32_t *pApiVersion, Dispatch const &d) VULKAN_HPP_NOEXCEPT
#define VK_VERSION_MAJOR(version)
Definition: vulkan_core.h:82
#define VK_VERSION_PATCH(version)
Definition: vulkan_core.h:88
#define VK_VERSION_MINOR(version)
Definition: vulkan_core.h:85