Debian Codegraph @

3rdparty/osgXR/src/OpenXR/SwapchainGroupSubImage.h

raw symbols SCIP
1 // SPDX-License-Identifier: LGPL-2.1-only
2 // Copyright (C) 2021 James Hogan <[email protected]>
3
4 #ifndef OSGXR_OPENXR_SWAPCHAIN_GROUP_SUB_IMAGE
5 #define OSGXR_OPENXR_SWAPCHAIN_GROUP_SUB_IMAGE 1
6
7 #include "SwapchainGroup.h"
8
9 #include <osg/ref_ptr>
10
11 #include <openxr/openxr.h>
12
13 namespace osgXR {
14
15 namespace OpenXR {
16
17 class SwapchainGroupSubImage
18 {
19 public:
20 SwapchainGroupSubImage(SwapchainGroup *group) :
21 _group(group),
22 _x(0),
23 _y(0),
24 _width(group->getWidth()),
25 _height(group->getHeight()),
26 _arrayIndex(0)
27 {
28 }
29
30 SwapchainGroupSubImage(SwapchainGroup *group,
31 const System::ViewConfiguration::View::Viewport &vp) :
32 _group(group),
33 _x(vp.x),
34 _y(vp.y),
35 _width(vp.width),
36 _height(vp.height),
37 _arrayIndex(vp.arrayIndex)
38 {
39 }
40
41 bool valid() const
42 {
43 return _group->valid();
44 }
45
46 bool depthValid() const
47 {
48 return _group->depthValid();
49 }
50
51 osg::ref_ptr<SwapchainGroup> getSwapchainGroup() const
52 {
53 return _group;
54 }
55
56 uint32_t getX() const
57 {
58 return _x;
59 }
60
61 uint32_t getY() const
62 {
63 return _y;
64 }
65
66 uint32_t getWidth() const
67 {
68 return _width;
69 }
70
71 uint32_t getHeight() const
72 {
73 return _height;
74 }
75
76 uint32_t getArrayIndex() const
77 {
78 return _arrayIndex;
79 }
80
81 void getXrSubImage(XrSwapchainSubImage *out) const
82 {
83 out->swapchain = _group->getXrSwapchain();
84 out->imageRect.offset = { (int32_t)_x,
85 (int32_t)_y };
86 out->imageRect.extent = { (int32_t)_width,
87 (int32_t)_height };
88 out->imageArrayIndex = _arrayIndex;
89 }
90
91 void getDepthXrSubImage(XrSwapchainSubImage *out) const
92 {
93 out->swapchain = _group->getDepthXrSwapchain();
94 out->imageRect.offset = { (int32_t)_x,
95 (int32_t)_y };
96 out->imageRect.extent = { (int32_t)_width,
97 (int32_t)_height };
98 out->imageArrayIndex = _arrayIndex;
99 }
100
101 protected:
102 osg::ref_ptr<SwapchainGroup> _group;
103 uint32_t _x;
104 uint32_t _y;
105 uint32_t _width;
106 uint32_t _height;
107 uint32_t _arrayIndex;
108 };
109
110 }
111
112 }
113
114 #endif