vsg: include/vsg/app/WindowTraits.h Source File

vsg 1.1.3 VulkanSceneGraph library

Loading...
Searching...
No Matches
WindowTraits.h
1#pragma once
2
3/* <editor-fold desc="MIT License">
4
5Copyright(c) 2018 Robert Osfield
6
7Permission 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
9The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
11THE 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
19namespace 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, const CopyOp& copyop = {});
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
37 ref_ptr<Object> clone(const CopyOp& copyop = {}) const override { return WindowTraits::create(*this, copyop); }
38
40 void defaults();
41
43 void validate();
44
45 int32_t x = 0;
46 int32_t y = 0;
47 uint32_t width = 1280;
48 uint32_t height = 1024;
49
50 bool fullscreen = false;
51
52 std::string display;
53 int screenNum = -1;
54
55 std::string windowClass = "vsg::Window";
56 std::string windowTitle = "vsg window";
57
58 bool decoration = true;
59 bool hdpi = true;
60
61 // X11 hint of whether to ignore the Window managers redirection of window size/position
62 bool overrideRedirect = false;
63
64 uint32_t vulkanVersion = VK_API_VERSION_1_0;
65
66 SwapchainPreferences swapchainPreferences;
67 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
68 VkImageUsageFlags depthImageUsage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
69
70 VkQueueFlags queueFlags = VK_QUEUE_GRAPHICS_BIT;
71 std::vector<float> queuePiorities{1.0, 0.0};
72 VkPipelineStageFlagBits imageAvailableSemaphoreWaitFlag = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
73
74 // hints to which extenstion to enable during Instance/Device setup
75 bool debugLayer = false; // VK_LAYER_KHRONOS_validation
76 bool synchronizationLayer = false; // VK_LAYER_KHRONOS_synchronization2
77 bool apiDumpLayer = false; // VK_LAYER_LUNARG_api_dump
78 bool debugUtils = false; // VK_EXT_debug_utils
79
80 // Device to use, if not assigned use the device preferences below
81 ref_ptr<vsg::Device> device;
82
83 // device preferences
84 vsg::Names instanceExtensionNames;
85 vsg::Names requestedLayers;
86 vsg::Names deviceExtensionNames;
87 vsg::PhysicalDeviceTypes deviceTypePreferences;
88 ref_ptr<DeviceFeatures> deviceFeatures;
89
90 // Multisampling
91 // A bitmask of sample counts. The window's framebuffer will
92 // be configured with the maximum requested value that is
93 // supported by the device.
94 VkSampleCountFlags samples = VK_SAMPLE_COUNT_1_BIT;
95
96 std::any nativeWindow;
97 std::any systemConnection;
98
99 protected:
100 virtual ~WindowTraits() {}
101 };
102 VSG_type_name(vsg::WindowTraits);
103
104} // namespace vsg
vsg::CopyOp
Definition Object.h:42
vsg::Inherit
Definition Inherit.h:28
vsg::WindowTraits
WindowTraits specifies the settings required when creating windows/vulkan instance/device.
Definition WindowTraits.h:27
vsg::WindowTraits::defaults
void defaults()
set default values, called by all constructors except copy constructor
vsg::WindowTraits::clone
ref_ptr< Object > clone(const CopyOp &copyop={}) const override
Definition WindowTraits.h:37
vsg::WindowTraits::validate
void validate()
validate the instanceExtensionNames and requestedLayers, assigning additional layers required by debu...
vsg::ref_ptr
Definition ref_ptr.h:22
vsg::SwapchainPreferences
Swapchain preferences passed via WindowTraits::swapchainPreferences to guide swapchain creation assoc...
Definition Swapchain.h:36