vsg  1.0.4
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  VkPipelineStageFlagBits imageAvailableSemaphoreWaitFlag = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
70 
71  bool debugLayer = false;
72  bool synchronizationLayer = false;
73  bool apiDumpLayer = false;
74 
75  // device preferences
76  vsg::Names instanceExtensionNames;
77  vsg::Names requestedLayers;
78  vsg::Names deviceExtensionNames;
79  vsg::PhysicalDeviceTypes deviceTypePreferences;
80  ref_ptr<DeviceFeatures> deviceFeatures;
81 
82  // Multisampling
83  // A bitmask of sample counts. The window's framebuffer will
84  // be configured with the maximum requested value that is
85  // supported by the device.
86  VkSampleCountFlags samples = VK_SAMPLE_COUNT_1_BIT;
87 
88  Window* shareWindow = nullptr;
89 
90  std::any nativeWindow;
91  std::any systemConnection;
92 
93  protected:
94  virtual ~WindowTraits() {}
95  };
96  VSG_type_name(vsg::WindowTraits);
97 
98 } // 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...
Definition: Window.h:31
Definition: ref_ptr.h:22
Swapchain preferences passed via WindowTraits::swapchainPreferences to guide swapchain creation assoc...
Definition: Swapchain.h:36