Cleaned up the handling of the Viewport with osg::SceneView/RenderStage

and CullVisitor so that the Viewport is now managed as part as the global
stateset so that it can be pushed and popped like the rest of state without
problems.  This makes it easier to have multiple viewports within one
scene graph.
This commit is contained in:
Robert Osfield
2002-04-22 09:37:17 +00:00
parent 4b9473eda9
commit f515d67f4f
4 changed files with 21 additions and 5 deletions

3
NEWS
View File

@@ -7,7 +7,8 @@ OSG News (most significant items from ChangeLog)
>>> Support added for Solaris, texture cube mapping & muliple projections.
The OpenSceneGraph now has new Makefile systems which supports all Unix
compilation including the new addition to the family - Solaris!
compilation including the new addition to the family - Solaris! Thanks
to Sun Microsystems for providing the hardware to do the port.
Support has also been added for OpenGL's texture cube mapping which
is ideal for accurate environmental reflections and much more.

View File

@@ -1041,6 +1041,8 @@ ImpostorSprite* CullVisitor::createImpostorSprite(Impostor& node)
Viewport* new_viewport = osgNew Viewport;
new_viewport->setViewport(center_x-new_s/2,center_y-new_t/2,new_s,new_t);
rtts->setViewport(new_viewport);
dummyState->setAttribute(new_viewport);
// create the impostor sprite.

View File

@@ -43,6 +43,7 @@ void RenderStage::addToDependencyList(RenderStage* rs)
{
if (rs) _dependencyList.push_back(rs);
}
void RenderStage::draw(osg::State& state,RenderLeaf*& previous)
{
if (_stageDrawnThisFrame) return;
@@ -63,9 +64,7 @@ void RenderStage::draw(osg::State& state,RenderLeaf*& previous)
}
// set up the back buffer.
//state.applyAttribute(_viewport.get());
_viewport->apply(state);
state.applyAttribute(_viewport.get());
#define USE_SISSOR_TEST
#ifdef USE_SISSOR_TEST

View File

@@ -434,6 +434,8 @@ void SceneView::draw()
case(osg::DisplaySettings::QUAD_BUFFER):
{
_globalState->setAttribute(_viewport.get());
glDrawBuffer(GL_BACK_LEFT);
drawStage(_renderStageLeft.get());
@@ -446,6 +448,8 @@ void SceneView::draw()
case(osg::DisplaySettings::ANAGLYPHIC):
{
_globalState->setAttribute(_viewport.get());
// draw left eye.
osg::ref_ptr<osg::ColorMask> red = osgNew osg::ColorMask;
red->setMask(true,false,false,true);
@@ -481,17 +485,21 @@ void SceneView::draw()
if (_displaySettings->getSplitStereoHorizontalEyeMapping()==osg::DisplaySettings::LEFT_EYE_LEFT_VIEWPORT)
{
_globalState->setAttribute(viewportLeft.get());
_renderStageLeft->setViewport(viewportLeft.get());
drawStage(_renderStageLeft.get());
_globalState->setAttribute(viewportRight.get());
_renderStageRight->setViewport(viewportRight.get());
drawStage(_renderStageRight.get());
}
else
{
_globalState->setAttribute(viewportRight.get());
_renderStageLeft->setViewport(viewportRight.get());
drawStage(_renderStageLeft.get());
_globalState->setAttribute(viewportLeft.get());
_renderStageRight->setViewport(viewportLeft.get());
drawStage(_renderStageRight.get());
}
@@ -517,17 +525,21 @@ void SceneView::draw()
if (_displaySettings->getSplitStereoVerticalEyeMapping()==osg::DisplaySettings::LEFT_EYE_TOP_VIEWPORT)
{
_globalState->setAttribute(viewportTop.get());
_renderStageLeft->setViewport(viewportTop.get());
drawStage(_renderStageLeft.get());
_globalState->setAttribute(viewportBottom.get());
_renderStageRight->setViewport(viewportBottom.get());
drawStage(_renderStageRight.get());
}
else
{
_globalState->setAttribute(viewportBottom.get());
_renderStageLeft->setViewport(viewportBottom.get());
drawStage(_renderStageLeft.get());
_globalState->setAttribute(viewportTop.get());
_renderStageRight->setViewport(viewportTop.get());
drawStage(_renderStageRight.get());
}
@@ -543,6 +555,8 @@ void SceneView::draw()
}
else
{
_globalState->setAttribute(_viewport.get());
// bog standard draw.
drawStage(_renderStage.get());
}
@@ -643,7 +657,7 @@ void SceneView::clearArea(int x,int y,int width,int height,const osg::Vec4& colo
osg::ref_ptr<osg::Viewport> viewport = osgNew osg::Viewport;
viewport->setViewport(x,y,width,height);
viewport->apply(*_state);
_state->applyAttribute(viewport.get());
glScissor( x, y, width, height );
glEnable( GL_SCISSOR_TEST );