| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#ifndef OSGXR_SWAPCHAIN |
| 5 |
#define OSGXR_SWAPCHAIN 1 |
| 6 |
|
| 7 |
#include <osgXR/SubImage> |
| 8 |
#include <osgXR/Swapchain> |
| 9 |
|
| 10 |
#include "OpenXR/Session.h" |
| 11 |
#include "OpenXR/SwapchainGroupSubImage.h" |
| 12 |
|
| 13 |
#include "XRState.h" |
| 14 |
|
| 15 |
#include <osg/Camera> |
| 16 |
#include <osg/observer_ptr> |
| 17 |
|
| 18 |
namespace osgXR { |
| 19 |
|
| 20 |
class XRState; |
| 21 |
|
| 22 |
class Swapchain::Private |
| 23 |
{ |
| 24 |
public: |
| 25 |
|
| 26 |
static Private *get(Swapchain *pub) |
| 27 |
{ |
| 28 |
return pub->_private.get(); |
| 29 |
} |
| 30 |
|
| 31 |
Private(uint32_t width, uint32_t height); |
| 32 |
virtual ~Private(); |
| 33 |
|
| 34 |
void attachToCamera(std::shared_ptr<Private> &self, |
| 35 |
osg::Camera *camera); |
| 36 |
void attachToMirror(std::shared_ptr<Private> &self, |
| 37 |
osg::StateSet *stateSet); |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
void preferRGBEncoding(Encoding encoding); |
| 42 |
void allowRGBEncoding(Encoding encoding); |
| 43 |
void setRGBBits(unsigned int rgbBits); |
| 44 |
unsigned int getRGBBits() const; |
| 45 |
void setAlphaBits(unsigned int alphaBits); |
| 46 |
unsigned int getAlphaBits() const; |
| 47 |
|
| 48 |
void setWidth(uint32_t width); |
| 49 |
uint32_t getWidth() const; |
| 50 |
void setHeight(uint32_t height); |
| 51 |
uint32_t getHeight() const; |
| 52 |
|
| 53 |
void setForcedAlpha(float alpha); |
| 54 |
void disableForcedAlpha(); |
| 55 |
float getForcedAlpha() const; |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
bool setup(XRState *state, OpenXR::Session *session); |
| 61 |
|
| 62 |
|
| 63 |
bool sync(); |
| 64 |
|
| 65 |
|
| 66 |
void cleanupSession(); |
| 67 |
|
| 68 |
|
| 69 |
bool valid() const; |
| 70 |
|
| 71 |
|
| 72 |
bool released() const; |
| 73 |
|
| 74 |
void initialDrawCallback(osg::RenderInfo &renderInfo); |
| 75 |
void preDrawCallback(osg::RenderInfo &renderInfo); |
| 76 |
void postDrawCallback(osg::RenderInfo &renderInfo); |
| 77 |
|
| 78 |
void incNumDrawPasses() |
| 79 |
{ |
| 80 |
++_numDrawPasses; |
| 81 |
} |
| 82 |
void decNumDrawPasses() |
| 83 |
{ |
| 84 |
--_numDrawPasses; |
| 85 |
} |
| 86 |
|
| 87 |
OpenXR::SwapchainGroupSubImage convertSubImage(const SubImage &subImage) const; |
| 88 |
|
| 89 |
protected: |
| 90 |
|
| 91 |
|
| 92 |
uint32_t _preferredRGBEncodingMask; |
| 93 |
uint32_t _allowedRGBEncodingMask; |
| 94 |
int _rgbBits; |
| 95 |
int _alphaBits; |
| 96 |
|
| 97 |
|
| 98 |
uint32_t _width; |
| 99 |
uint32_t _height; |
| 100 |
|
| 101 |
|
| 102 |
float _forcedAlpha; |
| 103 |
|
| 104 |
unsigned int _numDrawPasses; |
| 105 |
bool _updated; |
| 106 |
|
| 107 |
|
| 108 |
std::list<osg::observer_ptr<osg::StateSet>> _stateSets; |
| 109 |
|
| 110 |
|
| 111 |
osg::observer_ptr<XRState> _state; |
| 112 |
osg::observer_ptr<OpenXR::Session> _session; |
| 113 |
osg::ref_ptr<XRState::XRSwapchain> _swapchain; |
| 114 |
}; |
| 115 |
|
| 116 |
} |
| 117 |
|
| 118 |
#endif |