[osg-users] Camera clear color

cdp97531 at sina.com cdp97531 at sina.com
Thu Nov 29 00:44:53 PST 2018


Hi OSG guys,
last setMode call is wrong.It works with/without the following stament:masterCamera->getOrCreateStateSet()->setMode(GL_SCISSOR_TEST, GL_TRUE);I am confused.Any way it works.
Best regards,Deping
----- Original Message -----
From: <cdp97531 at sina.com>
To: "osg-users" <osg-users at lists.openscenegraph.org>
Subject: Camera clear color
Date: 2018-11-29 16:32

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20181129/2704f358/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ??1.png
Type: image/png
Size: 11406 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20181129/2704f358/attachment.png>


More information about the osg-users mailing list