c***@sina.com
2018-11-29 08:32:38 UTC
Hi OSG developers,
I am using OSG a lot now. OSG is great indeed.But I encountered a problem:There are one active master camera and one active slave camera which has its own scene graph.The 2 cameras shares the same GraphicsContext.Slave camera's viewport is contained in master camera's viewport.I want slave camera's viewport has a different background color, so I write:
masterCamera->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); masterCamera->setClearColor(osg::Vec4f(0.2f, 0.2f, 0.4f, 1.0f)); // blue
slaveCamera->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); slaveCamera->setClearColor(osg::Vec4f(0.4f, 0.2f, 0.2f, 1.0f)); // orange
But all view area is orange.I know glClear will clear whole color buffer.But GL spec says that scissor test affect the operation of glClear.After I add the following statement, it works: slaveCamera->getOrCreateStateSet()->setMode(osg::StateAttribute::SCISSOR, osg::StateAttribute::ON);Is this a bug of OSG?
It seems that OSG has enable scissor test:void RenderStage::drawImplementation(osg::RenderInfo& renderInfo,RenderLeaf*& previous){... glScissor( static_cast<int>(_viewport->x()), static_cast<int>(_viewport->y()), static_cast<int>(_viewport->width()), static_cast<int>(_viewport->height()) ); //cout << " clearing "<<this<< " "<<_viewport->x()<<","<< _viewport->y()<<","<< _viewport->width()<<","<< _viewport->height()<<std::endl; state.applyMode( GL_SCISSOR_TEST, true );}
Thanks,Deping
I am using OSG a lot now. OSG is great indeed.But I encountered a problem:There are one active master camera and one active slave camera which has its own scene graph.The 2 cameras shares the same GraphicsContext.Slave camera's viewport is contained in master camera's viewport.I want slave camera's viewport has a different background color, so I write:
masterCamera->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); masterCamera->setClearColor(osg::Vec4f(0.2f, 0.2f, 0.4f, 1.0f)); // blue
slaveCamera->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); slaveCamera->setClearColor(osg::Vec4f(0.4f, 0.2f, 0.2f, 1.0f)); // orange
But all view area is orange.I know glClear will clear whole color buffer.But GL spec says that scissor test affect the operation of glClear.After I add the following statement, it works: slaveCamera->getOrCreateStateSet()->setMode(osg::StateAttribute::SCISSOR, osg::StateAttribute::ON);Is this a bug of OSG?
It seems that OSG has enable scissor test:void RenderStage::drawImplementation(osg::RenderInfo& renderInfo,RenderLeaf*& previous){... glScissor( static_cast<int>(_viewport->x()), static_cast<int>(_viewport->y()), static_cast<int>(_viewport->width()), static_cast<int>(_viewport->height()) ); //cout << " clearing "<<this<< " "<<_viewport->x()<<","<< _viewport->y()<<","<< _viewport->width()<<","<< _viewport->height()<<std::endl; state.applyMode( GL_SCISSOR_TEST, true );}
Thanks,Deping