Vulkan-Hpp
01_InitInstance.cpp
Go to the documentation of this file.
1 // Copyright(c) 2018-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 : 01_InitInstance
16 // Create and destroy a vk::Instance
17 
18 #include <iostream>
19 #include <vulkan/vulkan.hpp>
20 
21 static std::string AppName = "01_InitInstance";
22 static std::string EngineName = "Vulkan.hpp";
23 
24 int main( int /*argc*/, char ** /*argv*/ )
25 {
26  /* VULKAN_HPP_KEY_START */
27 
28  try
29  {
30  // initialize the vk::ApplicationInfo structure
31  vk::ApplicationInfo applicationInfo( AppName.c_str(), 1, EngineName.c_str(), 1, VK_API_VERSION_1_1 );
32 
33  // initialize the vk::InstanceCreateInfo
34  vk::InstanceCreateInfo instanceCreateInfo( {}, &applicationInfo );
35 
36  // create an Instance
37  vk::Instance instance = vk::createInstance( instanceCreateInfo );
38 
39  // destroy it again
40  instance.destroy();
41  }
42  catch ( vk::SystemError & err )
43  {
44  std::cout << "vk::SystemError: " << err.what() << std::endl;
45  exit( -1 );
46  }
47  catch ( std::exception & err )
48  {
49  std::cout << "std::exception: " << err.what() << std::endl;
50  exit( -1 );
51  }
52  catch ( ... )
53  {
54  std::cout << "unknown error\n";
55  exit( -1 );
56  }
57 
58  /* VULKAN_HPP_KEY_END */
59 
60  return 0;
61 }
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 createInstance(const vk::InstanceCreateInfo *pCreateInfo, const vk::AllocationCallbacks *pAllocator, vk::Instance *pInstance, Dispatch const &d) VULKAN_HPP_NOEXCEPT
#define VK_API_VERSION_1_1
Definition: vulkan_core.h:4854