2020-01-09 23:10:09 +00:00
|
|
|
#ifndef MWVR_OPENRXTEXTURE_H
|
|
|
|
#define MWVR_OPENRXTEXTURE_H
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <osg/Group>
|
|
|
|
#include <osg/Camera>
|
|
|
|
#include <osgViewer/Viewer>
|
|
|
|
|
|
|
|
#include "openxrmanager.hpp"
|
|
|
|
|
|
|
|
namespace MWVR
|
|
|
|
{
|
|
|
|
class OpenXRTextureBuffer : public osg::Referenced
|
|
|
|
{
|
|
|
|
public:
|
2020-01-26 19:06:47 +00:00
|
|
|
OpenXRTextureBuffer(osg::ref_ptr<osg::State> state, std::size_t width, std::size_t height, uint32_t msaaSamples);
|
2020-01-09 23:10:09 +00:00
|
|
|
~OpenXRTextureBuffer();
|
|
|
|
|
|
|
|
void destroy(osg::State* state);
|
|
|
|
|
|
|
|
auto width() const { return mWidth; }
|
|
|
|
auto height() const { return mHeight; }
|
2020-01-26 19:06:47 +00:00
|
|
|
auto msaaSamples() const { return mSamples; }
|
2020-01-09 23:10:09 +00:00
|
|
|
|
2020-01-23 23:14:23 +00:00
|
|
|
void beginFrame(osg::GraphicsContext* gc);
|
2020-01-26 19:06:47 +00:00
|
|
|
void endFrame(osg::GraphicsContext* gc, uint32_t blitTarget);
|
2020-01-09 23:10:09 +00:00
|
|
|
|
|
|
|
void writeToJpg(osg::State& state, std::string filename);
|
|
|
|
|
2020-01-23 23:14:23 +00:00
|
|
|
uint32_t fbo(void) const { return mFBO; }
|
|
|
|
|
2020-01-26 19:06:47 +00:00
|
|
|
//! Blit to region in currently bound draw fbo
|
2020-01-23 23:14:23 +00:00
|
|
|
void blit(osg::GraphicsContext* gc, int x, int y, int w, int h);
|
2020-01-09 23:10:09 +00:00
|
|
|
|
2020-01-23 23:14:23 +00:00
|
|
|
private:
|
2020-01-09 23:10:09 +00:00
|
|
|
// Set aside a weak pointer to the constructor state to use when freeing FBOs, if no state is given to destroy()
|
|
|
|
osg::observer_ptr<osg::State> mState;
|
|
|
|
|
|
|
|
// Metadata
|
|
|
|
std::size_t mWidth = 0;
|
|
|
|
std::size_t mHeight = 0;
|
|
|
|
|
2020-01-26 19:06:47 +00:00
|
|
|
// Render Target
|
2020-01-09 23:10:09 +00:00
|
|
|
uint32_t mFBO = 0;
|
2020-01-26 19:06:47 +00:00
|
|
|
uint32_t mBlitFBO = 0;
|
|
|
|
uint32_t mDepthBuffer = 0;
|
|
|
|
uint32_t mColorBuffer = 0;
|
|
|
|
uint32_t mSamples = 0;
|
|
|
|
uint32_t mTextureTarget = 0;
|
2020-01-09 23:10:09 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|