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

vsg 1.1.3 VulkanSceneGraph library

Loading...
Searching...
No Matches
WindowResizeHandler.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 <vsg/app/Camera.h>
16#include <vsg/app/Window.h>
17#include <vsg/nodes/Group.h>
18
19#include <set>
20
21namespace vsg
22{
23
26 class VSG_DECLSPEC UpdateGraphicsPipelines : public Inherit<Visitor, UpdateGraphicsPipelines>
27 {
28 public:
29 UpdateGraphicsPipelines();
30
31 ref_ptr<Context> context;
32 std::set<std::pair<const Object*, uint32_t>> visited;
33
34 bool visit(const Object* object, uint32_t index);
35
36 void apply(Object& object) override;
37 void apply(BindGraphicsPipeline& bindPipeline) override;
38 void apply(View& view) override;
39 };
40 VSG_type_name(UpdateGraphicsPipelines);
41
43 class VSG_DECLSPEC WindowResizeHandler : public Inherit<Visitor, WindowResizeHandler>
44 {
45 public:
46 ref_ptr<Context> context;
47 VkRect2D renderArea;
48 VkExtent2D previous_extent;
49 VkExtent2D new_extent;
50 std::set<std::pair<const Object*, uint32_t>> visited;
51
52 WindowResizeHandler();
53
54 template<typename T, typename R>
55 T scale_parameter(T original, R extentOriginal, R extentNew)
56 {
57 if (original == static_cast<T>(extentOriginal)) return static_cast<T>(extentNew);
58 return static_cast<T>(static_cast<float>(original) * static_cast<float>(extentNew) / static_cast<float>(extentOriginal) + 0.5f);
59 }
60
61 void scale_rect(VkRect2D& rect);
62
64 bool visit(const Object* object, uint32_t index = 0);
65
66 void apply(BindGraphicsPipeline& bindPipeline) override;
67 void apply(Object& object) override;
68 void apply(ClearAttachments& clearAttachments) override;
69 void apply(View& view) override;
70 };
71 VSG_type_name(WindowResizeHandler);
72
73} // namespace vsg
vsg::BindGraphicsPipeline
BindGraphicsPipeline state command encapsulates the vkCmdBindPipeline call for a GraphicsPipeline.
Definition GraphicsPipeline.h:109
vsg::ClearAttachments
ClearAttachments command encapsulates vkCmdClearAttachments functionality and associated settings.
Definition ClearAttachments.h:22
vsg::Inherit
Definition Inherit.h:28
vsg::Object
Definition Object.h:60
vsg::UpdateGraphicsPipelines
Definition WindowResizeHandler.h:27
vsg::View
View is a Group class that pairs a Camera that defines the view with a subgraph that defines the scen...
Definition View.h:36
vsg::WindowResizeHandler
WindowResizeHandler class for updating viewport/scissor and attachments to fit with new window dimens...
Definition WindowResizeHandler.h:44
vsg::WindowResizeHandler::visit
bool visit(const Object *object, uint32_t index=0)
return true if the object was visited
vsg::ref_ptr
Definition ref_ptr.h:22