From 9208e24bd4f9af181b19c02d1ea8a0576f0c5328 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Sat, 15 Feb 2003 19:51:53 +0000 Subject: [PATCH] Fixes to RenderToTextureStage to account for the cull/draw traversal no longer using reference counting of statesets. Moved last uint reference over to unsigned int. --- src/Demos/osgpbuffer/RenderToTextureStage.cpp | 2 +- src/Demos/osgpbuffer/osgpbuffer.cpp | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Demos/osgpbuffer/RenderToTextureStage.cpp b/src/Demos/osgpbuffer/RenderToTextureStage.cpp index c24cb64b2..e63c6bd41 100644 --- a/src/Demos/osgpbuffer/RenderToTextureStage.cpp +++ b/src/Demos/osgpbuffer/RenderToTextureStage.cpp @@ -28,7 +28,7 @@ void MyRenderToTextureStage::draw(osg::State& state, osgUtil::RenderLeaf*& previ if (_pbuffer && _texture.valid()) { // Create pbuffer texture - const osg::uint contextID = state.getContextID(); + const unsigned int contextID = state.getContextID(); GLuint& handle = _texture->getTextureObject(contextID); if (handle == 0) { diff --git a/src/Demos/osgpbuffer/osgpbuffer.cpp b/src/Demos/osgpbuffer/osgpbuffer.cpp index 285418aa6..c1a6c2932 100644 --- a/src/Demos/osgpbuffer/osgpbuffer.cpp +++ b/src/Demos/osgpbuffer/osgpbuffer.cpp @@ -76,6 +76,8 @@ class MyCullCallback : public osg::NodeCallback osg::ref_ptr _subgraph; osg::ref_ptr _texture; + osg::ref_ptr _localState + }; @@ -133,9 +135,9 @@ void MyCullCallback::doPreRender(osg::Node&, osgUtil::CullVisitor& cv) cv.pushModelViewMatrix(matrix); - osg::ref_ptr dummyState = new osg::StateSet; + if (!_localState) _localState = new osg::StateSet; - cv.pushStateSet(dummyState.get()); + cv.pushStateSet(_localState.get()); { // traverse the subgraph @@ -176,10 +178,10 @@ void MyCullCallback::doPreRender(osg::Node&, osgUtil::CullVisitor& cv) osg::Viewport* new_viewport = new osg::Viewport; // new_viewport->setViewport(center_x-width/2,center_y-height/2,width,height); -new_viewport->setViewport(0,0,width,height); + new_viewport->setViewport(0,0,width,height); rtts->setViewport(new_viewport); - dummyState->setAttribute(new_viewport); + _localState->setAttribute(new_viewport); // and the render to texture stage to the current stages // dependancy list.