8#ifndef _OSG_OCULUSDEVICE_H_
9#define _OSG_OCULUSDEVICE_H_
14#include <OVR_CAPI_GL.h>
17#include <osg/Texture2D>
19#include <osg/FrameBufferObject>
25 OculusTextureBuffer(
const ovrSession& session, osg::ref_ptr<osg::State> state,
const ovrSizei& size,
int msaaSamples);
95 virtual void operator()(osg::RenderInfo& renderInfo)
const;
129 OculusDevice(
float nearClip,
float farClip,
const float pixelsPerDisplayPixel = 1.0f,
const float worldUnitsPerMetre = 1.0f,
const int samples = 0,
unsigned int mirrorTextureWidth = 960);
unsigned int GLuint
Definition DtGlTextureBufferObject.h:18
osg::Vec3f m_rightEyeAdjust
Definition oculusdevice.h:199
void calculateEyeAdjustment()
float m_farClip
Definition oculusdevice.h:205
float farClip() const
Definition oculusdevice.h:149
osg::Quat orientation() const
Definition oculusdevice.h:155
const float m_worldUnitsPerMetre
Definition oculusdevice.h:183
osg::Vec3 m_position
Definition oculusdevice.h:201
ovrEyeRenderDesc m_eyeRenderDesc[2]
Definition oculusdevice.h:190
unsigned int screenResolutionWidth() const
void resetSensorOrientation() const
double m_frameTiming
Definition oculusdevice.h:191
osg::Matrix projectionMatrixLeft() const
ovrVector3f m_viewOffset[2]
Definition oculusdevice.h:195
osg::ref_ptr< OculusTextureBuffer > m_textureBuffer[2]
Definition oculusdevice.h:185
osg::Vec3f m_leftEyeAdjust
Definition oculusdevice.h:198
float m_nearClip
Definition oculusdevice.h:204
osg::Matrix viewMatrixRight() const
osg::Camera * createRTTCamera(OculusDevice::Eye eye, osg::Transform::ReferenceFrame referenceFrame, const osg::Vec4 &clearColor, osg::GraphicsContext *gc=0) const
void updatePose(unsigned int frameIndex=0)
ovrPosef m_headPose[2]
Definition oculusdevice.h:192
osg::Matrix viewMatrixLeft() const
enum OculusDevice::Eye_ Eye
unsigned int screenResolutionHeight() const
ovrHmdDesc m_hmdDesc
Definition oculusdevice.h:180
void initializeEyeRenderDesc()
bool submitFrame(unsigned int frameIndex=0)
Eye_
Definition oculusdevice.h:124
@ COUNT
Definition oculusdevice.h:127
@ RIGHT
Definition oculusdevice.h:126
@ LEFT
Definition oculusdevice.h:125
float nearClip() const
Definition oculusdevice.h:148
void setPerfHudMode(int mode)
osg::Vec3 position() const
Definition oculusdevice.h:154
osg::Matrixf m_leftEyeProjectionMatrix
Definition oculusdevice.h:196
int m_samples
Definition oculusdevice.h:206
const float m_pixelsPerDisplayPixel
Definition oculusdevice.h:182
osg::Matrix projectionOffsetMatrixRight() const
osg::Matrix projectionMatrixCenter() const
osg::Matrix projectionOffsetMatrixLeft() const
void calculateProjectionMatrices()
osg::Matrix projectionMatrixRight() const
osg::Matrixf m_rightEyeProjectionMatrix
Definition oculusdevice.h:197
osg::ref_ptr< OculusMirrorTexture > m_mirrorTexture
Definition oculusdevice.h:186
unsigned int m_mirrorTextureWidth
Definition oculusdevice.h:188
OculusDevice & operator=(const OculusDevice &)
void createRenderBuffers(osg::ref_ptr< osg::State > state)
ovrLayerEyeFov m_layerEyeFov
Definition oculusdevice.h:194
OculusDevice(const OculusDevice &)
void trySetProcessAsHighPriority() const
osg::GraphicsContext::Traits * graphicsContextTraits() const
osg::Quat m_orientation
Definition oculusdevice.h:202
OculusDevice(float nearClip, float farClip, const float pixelsPerDisplayPixel=1.0f, const float worldUnitsPerMetre=1.0f, const int samples=0, unsigned int mirrorTextureWidth=960)
ovrSession m_session
Definition oculusdevice.h:179
ovrPosef m_eyeRenderPose[2]
Definition oculusdevice.h:193
Definition oculusdevice.h:214
virtual void operator()(osg::RenderInfo &renderInfo) const
GLuint m_mirrorFBO
Definition oculusdevice.h:82
const ovrSession m_session
Definition oculusdevice.h:78
GLint m_width
Definition oculusdevice.h:80
ovrMirrorTexture m_texture
Definition oculusdevice.h:79
void blitTexture(osg::GraphicsContext *gc, int width, int height)
GLint m_height
Definition oculusdevice.h:81
GLint height() const
Definition oculusdevice.h:73
GLint width() const
Definition oculusdevice.h:72
OculusMirrorTexture(ovrSession &session, osg::ref_ptr< osg::State > state, int width, int height)
virtual ~OculusMirrorTexture()
Definition oculusdevice.h:76
OculusPostDrawCallback(osg::Camera *camera, OculusTextureBuffer *textureBuffer)
Definition oculusdevice.h:105
virtual void operator()(osg::RenderInfo &renderInfo) const
osg::observer_ptr< osg::Camera > m_camera
Definition oculusdevice.h:113
osg::observer_ptr< OculusTextureBuffer > m_textureBuffer
Definition oculusdevice.h:114
osg::observer_ptr< osg::Camera > m_camera
Definition oculusdevice.h:97
osg::observer_ptr< OculusTextureBuffer > m_textureBuffer
Definition oculusdevice.h:98
virtual void operator()(osg::RenderInfo &renderInfo) const
OculusPreDrawCallback(osg::Camera *camera, OculusTextureBuffer *textureBuffer)
Definition oculusdevice.h:89
Definition oculusdevice.h:23
GLuint m_Oculus_FBO
Definition oculusdevice.h:53
GLuint m_MSAA_ColorTex
Definition oculusdevice.h:55
virtual ~OculusTextureBuffer()
Definition oculusdevice.h:39
GLuint myDownsampleShader
Definition oculusdevice.h:61
GLuint myCurrentTextureId
Definition oculusdevice.h:59
int textureWidth() const
Definition oculusdevice.h:27
GLuint createProgram(const std::string &name)
void setEnableTextureBlit(bool set, int x, int y)
ovrTextureSwapChain m_textureSwapChain
Definition oculusdevice.h:45
bool myShouldBlitTexture
Definition oculusdevice.h:60
int samples() const
Definition oculusdevice.h:29
osg::Vec2i m_textureSize
Definition oculusdevice.h:48
OculusTextureBuffer(const ovrSession &session, osg::ref_ptr< osg::State > state, const ovrSizei &size, int msaaSamples)
ovrTextureSwapChain textureSwapChain() const
Definition oculusdevice.h:30
int m_samples
Definition oculusdevice.h:57
void onPostRender(osg::RenderInfo &renderInfo)
void blitTexture(osg::State *state, int width, int height)
void onPreRender(osg::RenderInfo &renderInfo)
int myBlitHeight
Definition oculusdevice.h:63
osg::ref_ptr< osg::Texture2D > depthBuffer() const
Definition oculusdevice.h:32
void setup(osg::State &state)
osg::ref_ptr< osg::Texture2D > m_colorBuffer
Definition oculusdevice.h:46
int myBlitWidth
Definition oculusdevice.h:62
osg::ref_ptr< osg::Texture2D > m_depthBuffer
Definition oculusdevice.h:47
void setupMSAA(osg::State &state)
GLuint m_MSAA_FBO
Definition oculusdevice.h:54
int textureHeight() const
Definition oculusdevice.h:28
const ovrSession m_session
Definition oculusdevice.h:44
osg::ref_ptr< osg::Texture2D > colorBuffer() const
Definition oculusdevice.h:31
GLuint m_MSAA_DepthTex
Definition oculusdevice.h:56