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