vsg  1.1.0
VulkanSceneGraph library
WindowTraits.h
1 #pragma once
2 
3 /* <editor-fold desc="MIT License">
4 
5 Copyright(c) 2018 Robert Osfield
6 
7 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 
9 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10 
11 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12 
13 </editor-fold> */
14 
15 #include <any>
16 
17 #include <vsg/vk/Swapchain.h>
18 
19 namespace vsg
20 {
21 
22  // forward declare
23  class Window;
24 
26  class VSG_DECLSPEC WindowTraits : public Inherit<Object, WindowTraits>
27  {
28  public:
29  WindowTraits();
30  explicit WindowTraits(const WindowTraits& traits);
31  explicit WindowTraits(const std::string& title);
32  WindowTraits(int32_t in_x, int32_t in_y, uint32_t in_width, uint32_t in_height, const std::string& title = "vsg window");
33  WindowTraits(uint32_t in_width, uint32_t in_height, const std::string& title = "vsg window");
34 
35  WindowTraits& operator=(const WindowTraits&) = delete;
36 
38  void defaults();
39 
41  void validate();
42 
43  int32_t x = 0;
44  int32_t y = 0;
45  uint32_t width = 1280;
46  uint32_t height = 1024;
47 
48  bool fullscreen = false;
49 
50  std::string display;
51  int screenNum = -1;
52 
53  std::string windowClass = "vsg::Window";
54  std::string windowTitle = "vsg window";
55 
56  bool decoration = true;
57  bool hdpi = true;
58 
59  // X11 hint of whether to ignore the Window managers redirection of window size/position
60  bool overrideRedirect = false;
61 
62  uint32_t vulkanVersion = VK_API_VERSION_1_0;
63 
64  SwapchainPreferences swapchainPreferences;
65  VkFormat depthFormat = VK_FORMAT_D32_SFLOAT; // VK_FORMAT_D24_UNORM_S8_UINT or VK_FORMAT_D32_SFLOAT_S8_UINT or VK_FORMAT_D24_SFLOAT_S8_UINT
66  VkImageUsageFlags depthImageUsage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
67 
68  VkQueueFlags queueFlags = VK_QUEUE_GRAPHICS_BIT;
69  std::vector<float> queuePiorities{1.0, 0.0};
70  VkPipelineStageFlagBits imageAvailableSemaphoreWaitFlag = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
71 
72  // hints to which extenstion to enable during Instance/Device setup
73  bool debugLayer = false; // VK_LAYER_KHRONOS_validation
74  bool synchronizationLayer = false; // VK_LAYER_KHRONOS_synchronization2
75  bool apiDumpLayer = false; // VK_LAYER_LUNARG_api_dump
76  bool debugUtils = false; // VK_EXT_debug_utils
77 
78  // Device to use, if not assigned use the device preferences below
79  ref_ptr<vsg::Device> device;
80 
81  // device preferences
82  vsg::Names instanceExtensionNames;
83  vsg::Names requestedLayers;
84  vsg::Names deviceExtensionNames;
85  vsg::PhysicalDeviceTypes deviceTypePreferences;
86  ref_ptr<DeviceFeatures> deviceFeatures;
87 
88  // Multisampling
89  // A bitmask of sample counts. The window's framebuffer will
90  // be configured with the maximum requested value that is
91  // supported by the device.
92  VkSampleCountFlags samples = VK_SAMPLE_COUNT_1_BIT;
93 
94  std::any nativeWindow;
95  std::any systemConnection;
96 
97  protected:
98  virtual ~WindowTraits() {}
99  };
100  VSG_type_name(vsg::WindowTraits);
101 
102 } // namespace vsg
Definition: Inherit.h:28
WindowTraits specifies the settings required when creating windows/vulkan instance/device.
Definition: WindowTraits.h:27
void defaults()
set default values, called by all constructors except copy constructor
void validate()
validate the instanceExtensionNames and requestedLayers, assigning additional layers required by debu...
Swapchain preferences passed via WindowTraits::swapchainPreferences to guide swapchain creation assoc...
Definition: Swapchain.h:36