<div>Hi OSG guys,</div><div><br></div><div>last setMode call is wrong.</div><div>It <b>works with/without</b> the following stament:</div><div>masterCamera->getOrCreateStateSet()->setMode(GL_SCISSOR_TEST, GL_TRUE);</div><div>I am confused.</div><div>Any way it works.</div><div><br></div><div>Best regards,</div><div>Deping</div><div><br></div><div id="origbody"><div style="background: #f2f2f2;">----- Original Message -----<br>From: <cdp97531@sina.com><br>To: "osg-users" <osg-users@lists.openscenegraph.org><br>Subject: Camera clear color<br>Date: 2018-11-29 16:32<br></div><br><div>Hi OSG developers,</div><div><br></div><div>I am using OSG a lot now. OSG is great indeed.</div><div>But I encountered a problem:</div><div>There are one active master camera and one active slave camera which has its own scene graph.</div><div>The 2 cameras shares the same GraphicsContext.</div><div>Slave camera's viewport is contained in master camera's viewport.</div><div>I want slave camera's viewport has a different background color, so I write:</div><div><br></div><div><div>    masterCamera->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);</div><div>    masterCamera->setClearColor(osg::Vec4f(0.2f, 0.2f, 0.4f, 1.0f)); // blue</div></div><div><br></div><div><div>    slaveCamera->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);</div><div>    slaveCamera->setClearColor(osg::Vec4f(0.4f, 0.2f, 0.2f, 1.0f)); // orange</div></div><div><br></div><div>But all view area is orange.</div><div>I know glClear will clear whole color buffer.</div><div>But <span style="font-family: "Segoe UI", SegoeUI, "Segoe WP", "Helvetica Neue", Helvetica, Tahoma, Arial, sans-serif; font-size: 16px;"> GL spec says that scissor test affect the operation of </span><span class="" style="font-weight: 600; box-sizing: inherit; outline: none; font-family: "Segoe UI", SegoeUI, "Segoe WP", "Helvetica Neue", Helvetica, Tahoma, Arial, sans-serif; font-size: 16px;">glClear</span><span style="font-family: "Segoe UI", SegoeUI, "Segoe WP", "Helvetica Neue", Helvetica, Tahoma, Arial, sans-serif; font-size: 16px;">.</span></div><div><span style="font-family: "Segoe UI", SegoeUI, "Segoe WP", "Helvetica Neue", Helvetica, Tahoma, Arial, sans-serif; font-size: 16px;">After I add the following statement, it works:</span></div><div><div><font face="Segoe UI, SegoeUI, Segoe WP, Helvetica Neue, Helvetica, Tahoma, Arial, sans-serif">    </font>slaveCamera<font face="Segoe UI, SegoeUI, Segoe WP, Helvetica Neue, Helvetica, Tahoma, Arial, sans-serif">->getOrCreateStateSet()->setMode(osg::StateAttribute::SCISSOR, osg::StateAttribute::ON);</font></div></div><div><img src="cid:part1.5bffa704e25697b_201811"></div><div>Is this a bug of OSG?</div><div><br></div><div>It seems that OSG has enable scissor test:</div><div><div>void RenderStage::drawImplementation(osg::RenderInfo& renderInfo,RenderLeaf*& previous)</div></div><div>{</div><div>...</div><div>    glScissor( static_cast<int>(_viewport->x()),</div><div>               static_cast<int>(_viewport->y()),</div><div>               static_cast<int>(_viewport->width()),</div><div>               static_cast<int>(_viewport->height()) );</div><div>    //cout << "    clearing "<<this<< "  "<<_viewport->x()<<","<< _viewport->y()<<","<< _viewport->width()<<","<< _viewport->height()<<std::endl;</div><div>    <b>state.applyMode( GL_SCISSOR_TEST, true );</b></div><div>}</div><div><br></div><div>Thanks,</div><div>Deping</div></div>