From a742cb682e882608c5bff1569d5125ce425a2d8f Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 1 Nov 2005 10:42:54 +0000 Subject: [PATCH] Added RenderTargetFallback option into osg::CameraNode. --- include/osg/CameraNode | 8 +++++++- src/osg/CameraNode.cpp | 28 +++++++++++++++++++++++++--- src/osgSim/Impostor.cpp | 2 +- src/osgUtil/RenderStage.cpp | 33 +++++++++++++++++++++------------ 4 files changed, 54 insertions(+), 17 deletions(-) diff --git a/include/osg/CameraNode b/include/osg/CameraNode index 7b0d6589f..e9b14a4f2 100644 --- a/include/osg/CameraNode +++ b/include/osg/CameraNode @@ -191,9 +191,14 @@ class OSG_EXPORT CameraNode : public Transform, public CullSettings SEPERATE_WINDOW }; - void setRenderTargetImplementation(RenderTargetImplementation impl) { _renderTargetImplementation = impl; } + void setRenderTargetImplementation(RenderTargetImplementation impl); + + void setRenderTargetImplementation(RenderTargetImplementation impl, RenderTargetImplementation fallback); + RenderTargetImplementation getRenderTargetImplementation() const { return _renderTargetImplementation; } + RenderTargetImplementation getRenderTargetFallback() const { return _renderTargetFallback; } + /** Set the draw buffer used at the start of each frame draw. * Note, a buffer value of GL_NONE is used to sepecify that the rendering back-end should choose the most appropriate buffer.*/ @@ -342,6 +347,7 @@ class OSG_EXPORT CameraNode : public Transform, public CullSettings RenderBufferList _renderBufferList; RenderTargetImplementation _renderTargetImplementation; + RenderTargetImplementation _renderTargetFallback; BufferAttachmentMap _bufferAttachmentMap; ref_ptr _graphicsContext; diff --git a/src/osg/CameraNode.cpp b/src/osg/CameraNode.cpp index 4e051559e..47f156ad1 100644 --- a/src/osg/CameraNode.cpp +++ b/src/osg/CameraNode.cpp @@ -11,11 +11,10 @@ * OpenSceneGraph Public License for more details. */ #include +#include using namespace osg; - - CameraNode::CameraNode(): _clearColor(osg::Vec4(0.0f,0.0f,0.0f,1.0f)), _clearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT), @@ -23,7 +22,8 @@ CameraNode::CameraNode(): _renderOrder(POST_RENDER), _drawBuffer(GL_NONE), _readBuffer(GL_NONE), - _renderTargetImplementation(FRAME_BUFFER) + _renderTargetImplementation(FRAME_BUFFER), + _renderTargetFallback(FRAME_BUFFER) { setStateSet(new StateSet); } @@ -42,6 +42,7 @@ CameraNode::CameraNode(const CameraNode& camera,const CopyOp& copyop): _drawBuffer(camera._drawBuffer), _readBuffer(camera._readBuffer), _renderTargetImplementation(camera._renderTargetImplementation), + _renderTargetFallback(camera._renderTargetFallback), _bufferAttachmentMap(camera._bufferAttachmentMap), _postDrawCallback(camera._postDrawCallback) { @@ -52,6 +53,27 @@ CameraNode::~CameraNode() { } +void CameraNode::setRenderTargetImplementation(RenderTargetImplementation impl) +{ + _renderTargetImplementation = impl; + if (implsetViewport(0,0,new_s,new_t); // tell the camera to use OpenGL frame buffer object where supported. - camera->setRenderTargetImplementation(osg::CameraNode::FRAME_BUFFER_OBJECT); + camera->setRenderTargetImplementation(osg::CameraNode::FRAME_BUFFER_OBJECT, osg::CameraNode::FRAME_BUFFER); // set the camera to render before the main camera. camera->setRenderOrder(osg::CameraNode::PRE_RENDER); diff --git a/src/osgUtil/RenderStage.cpp b/src/osgUtil/RenderStage.cpp index d16324a3c..a0e043c00 100644 --- a/src/osgUtil/RenderStage.cpp +++ b/src/osgUtil/RenderStage.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -151,6 +152,7 @@ void RenderStage::runCameraSetUp(osg::State& state) if (!_camera) return; osg::CameraNode::RenderTargetImplementation renderTargetImplemntation = _camera->getRenderTargetImplementation(); + osg::CameraNode::RenderTargetImplementation renderTargetFallback = _camera->getRenderTargetFallback(); osg::CameraNode::BufferAttachmentMap& bufferAttachements = _camera->getBufferAttachmentMap(); @@ -170,19 +172,15 @@ void RenderStage::runCameraSetUp(osg::State& state) if (!fbo_supported) { - // fallback to using pbuffer - #ifdef _WIN32 - // Only Win32 currently support PBuffer RTT. - osg::notify(osg::INFO)<<"RenderStage::runCameraSetUp(State&): Using fallback to PIXEL_BUFFER_RTT"<