Preperation for adding stereo support direclty into osgViewer.

This commit is contained in:
Robert Osfield
2013-04-15 14:21:32 +00:00
parent bc288d23dc
commit 34a6b38983
7 changed files with 239 additions and 131 deletions

View File

@@ -15,6 +15,7 @@
#define OSG_DisplaySettings 1
#include <osg/Referenced>
#include <osg/Matrixd>
#include <osg/ref_ptr>
#include <string>
@@ -184,6 +185,11 @@ class OSG_EXPORT DisplaySettings : public osg::Referenced
void setSerializeDrawDispatch(bool serializeDrawDispatch) { _serializeDrawDispatch = serializeDrawDispatch; }
bool getSerializeDrawDispatch() const { return _serializeDrawDispatch; }
void setUseSceneViewForStereoHint(bool hint) { _useSceneViewForStereoHint = hint; }
bool getUseSceneViewForStereoHint() const { return _useSceneViewForStereoHint; }
/** Set the hint for the total number of threads in the DatbasePager set up, inclusive of the number of http dedicated threads.*/
void setNumOfDatabaseThreadsHint(unsigned int numThreads) { _numDatabaseThreadsHint = numThreads; }
@@ -278,6 +284,22 @@ class OSG_EXPORT DisplaySettings : public osg::Referenced
/** Get the hint of the profile mask to use in when creating graphic contexts.*/
unsigned int getGLContextProfileMask() const { return _glContextProfileMask; }
/** helper function for computing the left eye projection matrix.*/
virtual osg::Matrixd computeLeftEyeProjectionImplementation(const osg::Matrixd& projection) const;
/** helper function for computing the left eye view matrix.*/
virtual osg::Matrixd computeLeftEyeViewImplementation(const osg::Matrixd& view, double eyeSeperationScale=1.0) const;
/** helper function for computing the right eye view matrix.*/
virtual osg::Matrixd computeRightEyeProjectionImplementation(const osg::Matrixd& projection) const;
/** helper function for computing the right eye view matrix.*/
virtual osg::Matrixd computeRightEyeViewImplementation(const osg::Matrixd& view, double eyeSeperationScale=1.0) const;
protected:
virtual ~DisplaySettings();
@@ -313,6 +335,7 @@ class OSG_EXPORT DisplaySettings : public osg::Referenced
bool _compileContextsHint;
bool _serializeDrawDispatch;
bool _useSceneViewForStereoHint;
unsigned int _numDatabaseThreadsHint;
unsigned int _numHttpDatabaseThreadsHint;

View File

@@ -64,6 +64,18 @@ class OSG_EXPORT Viewport : public StateAttribute
return 0; // passed all the above comparison macros, must be equal.
}
Viewport& operator = (const Viewport& rhs)
{
if (&rhs==this) return *this;
_x = rhs._x;
_y = rhs._y;
_width = rhs._width;
_height = rhs._height;
return *this;
}
inline void setViewport(value_type x,value_type y,value_type width,value_type height)
{
_x = x;

View File

@@ -406,8 +406,6 @@ class OSGUTIL_EXPORT SceneView : public osg::Object, public osg::CullSettings
inline const osg::FrameStamp* getFrameStamp() const { return _frameStamp.get(); }
inline osg::Matrixd computeLeftEyeProjection(const osg::Matrixd& projection) const
{
if (_computeStereoMatricesCallback.valid()) return _computeStereoMatricesCallback->computeLeftEyeProjection(projection);
@@ -432,12 +430,19 @@ class OSGUTIL_EXPORT SceneView : public osg::Object, public osg::CullSettings
else return computeRightEyeViewImplementation(view);
}
/** helper function for computing the left eye projection matrix.*/
virtual osg::Matrixd computeLeftEyeProjectionImplementation(const osg::Matrixd& projection) const;
/** helper function for computing the left eye view matrix.*/
virtual osg::Matrixd computeLeftEyeViewImplementation(const osg::Matrixd& view) const;
/** helper function for computing the right eye view matrix.*/
virtual osg::Matrixd computeRightEyeProjectionImplementation(const osg::Matrixd& projection) const;
/** helper function for computing the right eye view matrix.*/
virtual osg::Matrixd computeRightEyeViewImplementation(const osg::Matrixd& view) const;
/** Inherit the local cull settings variable from a specified CullSettings object, according to the inheritance mask.*/
virtual void inheritCullSettings(const osg::CullSettings& settings) { inheritCullSettings(settings, _inheritanceMask); }

View File

@@ -86,6 +86,7 @@ class OSGVIEWER_EXPORT Renderer : public osg::GraphicsOperation
bool _done;
bool _graphicsThreadDoesCull;
bool _compileOnNextDraw;
bool _serializeDraw;
osg::ref_ptr<osgUtil::SceneView> _sceneView[2];