Added a default StateSet to osg::View's master Camera. Wired up osgViewer::Viewer so
that the master Camera's StateSet is passed to osgUtil::SceneView to use as its global StateSet.
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
*/
|
||||
#include <osg/View>
|
||||
#include <osg/Notify>
|
||||
#include <osg/TexEnv>
|
||||
|
||||
using namespace osg;
|
||||
|
||||
@@ -20,8 +21,12 @@ View::View()
|
||||
// osg::notify(osg::NOTICE)<<"Constructing osg::View"<<std::endl;
|
||||
|
||||
setCamera(new osg::Camera);
|
||||
|
||||
_camera->setProjectionMatrixAsFrustum(-0.325, 0.325, -0.26, 0.26, 1.0f,10000.0f);
|
||||
_camera->setClearColor(osg::Vec4f(0.2f, 0.2f, 0.4f, 1.0f));
|
||||
|
||||
osg::StateSet* stateset = _camera->getOrCreateStateSet();
|
||||
stateset->setGlobalDefaults();
|
||||
}
|
||||
|
||||
View::~View()
|
||||
|
||||
@@ -155,7 +155,8 @@ void SceneView::setDefaults(unsigned int options)
|
||||
_camera->getProjectionMatrix().makePerspective(50.0f,1.4f,1.0f,10000.0f);
|
||||
_camera->getViewMatrix().makeIdentity();
|
||||
|
||||
_globalStateSet = new osg::StateSet;
|
||||
if (!_globalStateSet) _globalStateSet = new osg::StateSet;
|
||||
else _globalStateSet->clear();
|
||||
|
||||
if ((options & HEADLIGHT) || (options & SKY_LIGHT))
|
||||
{
|
||||
@@ -215,17 +216,6 @@ void SceneView::setDefaults(unsigned int options)
|
||||
_cullVisitor->setRenderStage(_renderStage.get());
|
||||
|
||||
_globalStateSet->setGlobalDefaults();
|
||||
|
||||
|
||||
// enable depth testing by default.
|
||||
_globalStateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::ON);
|
||||
|
||||
#if 0
|
||||
// set up an alphafunc by default to speed up blending operations.
|
||||
osg::AlphaFunc* alphafunc = new osg::AlphaFunc;
|
||||
alphafunc->setFunction(osg::AlphaFunc::GREATER,1.0f);
|
||||
_globalStateSet->setAttributeAndModes(alphafunc, osg::StateAttribute::OFF);
|
||||
#endif
|
||||
|
||||
// set up an texture environment by default to speed up blending operations.
|
||||
osg::TexEnv* texenv = new osg::TexEnv;
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include <osgViewer/View>
|
||||
#include <osgViewer/GraphicsWindow>
|
||||
|
||||
#include <osgUtil/SceneView>
|
||||
#include <osg/io_utils>
|
||||
|
||||
#include <osgUtil/IntersectionVisitor>
|
||||
|
||||
@@ -454,6 +454,7 @@ void Viewer::setUpRenderingSupport()
|
||||
osgUtil::SceneView* sceneView = new osgUtil::SceneView;
|
||||
_cameraSceneViewMap[_camera] = sceneView;
|
||||
|
||||
sceneView->setGlobalStateSet(_camera->getStateSet());
|
||||
sceneView->setDefaults();
|
||||
sceneView->setDisplaySettings(ds);
|
||||
sceneView->setCamera(_camera.get());
|
||||
@@ -472,6 +473,7 @@ void Viewer::setUpRenderingSupport()
|
||||
osgUtil::SceneView* sceneView = new osgUtil::SceneView;
|
||||
_cameraSceneViewMap[slave._camera] = sceneView;
|
||||
|
||||
sceneView->setGlobalStateSet(_camera->getStateSet());
|
||||
sceneView->setDefaults();
|
||||
sceneView->setCamera(slave._camera.get());
|
||||
sceneView->setDisplaySettings(ds);
|
||||
|
||||
Reference in New Issue
Block a user