@@ -394,6 +394,8 @@ void DispatchDrawCallback::drawImplementation(osg::RenderInfo& renderInfo, const
394394 // Ensure initialization happened
395395 if (!initialized || !scmCamera) return ;
396396 if (!_renderer->gpuOrganizationReady ()) return ;
397+ glPushAttrib (GL_ALL_ATTRIB_BITS );
398+ glPushClientAttrib (GL_CLIENT_ALL_ATTRIB_BITS );
397399
398400 if (allowLodUpdate) {
399401 lamure::ren::cut_database* cuts = lamure::ren::cut_database::get_instance ();
@@ -456,7 +458,10 @@ void DispatchDrawCallback::drawImplementation(osg::RenderInfo& renderInfo, const
456458 }
457459 }
458460
459- if (drawable) drawable->drawImplementation (renderInfo);
461+ if (drawable)
462+ drawable->drawImplementation (renderInfo);
463+ glPopClientAttrib ();
464+ glPopAttrib ();
460465}
461466
462467void CutsDrawCallback::drawImplementation (osg::RenderInfo& renderInfo, const osg::Drawable* drawable) const
@@ -470,6 +475,8 @@ void CutsDrawCallback::drawImplementation(osg::RenderInfo& renderInfo, const osg
470475 if (!plugin->getSettings ().lod_update || plugin->isRebuildInProgress ()) {
471476 return ;
472477 }
478+ glPushAttrib (GL_ALL_ATTRIB_BITS );
479+ glPushClientAttrib (GL_CLIENT_ALL_ATTRIB_BITS );
473480
474481 int ctx = renderInfo.getContextID ();
475482 const uint64_t frameNo = frameNumberFromRenderInfo (renderInfo);
@@ -509,7 +516,10 @@ void CutsDrawCallback::drawImplementation(osg::RenderInfo& renderInfo, const osg
509516 m_renderer->noteContextUpdateMs (ctx, frameNo, elapsedMs (tContextStart));
510517 }
511518
512- if (drawable) drawable->drawImplementation (renderInfo);
519+ if (drawable)
520+ drawable->drawImplementation (renderInfo);
521+ glPopClientAttrib ();
522+ glPopAttrib ();
513523}
514524
515525
@@ -521,11 +531,15 @@ void PointsDrawCallback::drawImplementation(osg::RenderInfo& renderInfo, const o
521531 Lamure* plugin = m_renderer->getPlugin ();
522532 if (!plugin) return ;
523533
534+
524535 const uint64_t frameNo = frameNumberFromRenderInfo (renderInfo);
525536 int ctx = renderInfo.getContextID ();
526537 const osg::Camera* cam = renderInfo.getCurrentCamera ();
527538
528- if (!m_renderer->beginFrame (ctx)) return ;
539+ if (!m_renderer->beginFrame (ctx))
540+ return ;
541+ glPushAttrib (GL_ALL_ATTRIB_BITS );
542+ glPushClientAttrib (GL_CLIENT_ALL_ATTRIB_BITS );
529543
530544 bool pixelMetricsActive = false ;
531545 bool stateCaptured = false ;
@@ -540,6 +554,8 @@ void PointsDrawCallback::drawImplementation(osg::RenderInfo& renderInfo, const o
540554 before.restore ();
541555 stateCaptured = false ;
542556 }
557+ glPopClientAttrib ();
558+ glPopAttrib ();
543559 };
544560
545561 const auto & settings = plugin->getSettings ();
@@ -1173,6 +1189,8 @@ void BoundingBoxDrawCallback::drawImplementation(osg::RenderInfo& renderInfo, co
11731189 return ;
11741190 }
11751191
1192+ glPushAttrib (GL_ALL_ATTRIB_BITS );
1193+ glPushClientAttrib (GL_CLIENT_ALL_ATTRIB_BITS );
11761194 GLuint boxVao = 0 ;
11771195 {
11781196 std::lock_guard<std::mutex> callbackLock (res.callback_mutex );
@@ -1192,7 +1210,10 @@ void BoundingBoxDrawCallback::drawImplementation(osg::RenderInfo& renderInfo, co
11921210 }
11931211 }
11941212 }
1195- if (boxVao == 0 ) {
1213+ if (boxVao == 0 )
1214+ {
1215+ glPopClientAttrib ();
1216+ glPopAttrib ();
11961217 return ;
11971218 }
11981219
@@ -1211,19 +1232,28 @@ void BoundingBoxDrawCallback::drawImplementation(osg::RenderInfo& renderInfo, co
12111232 osg::Matrixd model_osg;
12121233 osg::Matrixd view_osg;
12131234 osg::Matrixd proj_osg;
1214- if (!m_renderer->getModelViewProjectionFromRenderInfo (renderInfo, drawableParent, model_osg, view_osg, proj_osg)) {
1235+ if (!m_renderer->getModelViewProjectionFromRenderInfo (renderInfo, drawableParent, model_osg, view_osg, proj_osg))
1236+ {
1237+ glPopClientAttrib ();
1238+ glPopAttrib ();
12151239 return ;
12161240 }
12171241 scm::math::mat4 model_matrix = LamureUtil::matConv4F (model_osg);
12181242
12191243 lamure::ren::cut& cut = cuts->get_cut (context_id, view_id, data->modelId );
12201244 const auto & renderable = cut.complete_set ();
1221- if (renderable.empty ()) {
1245+ if (renderable.empty ())
1246+ {
1247+ glPopClientAttrib ();
1248+ glPopAttrib ();
12221249 return ;
12231250 }
12241251
12251252 const auto it = m_renderer->m_bvh_node_vertex_offsets .find (data->modelId );
1226- if (it == m_renderer->m_bvh_node_vertex_offsets .end ()) {
1253+ if (it == m_renderer->m_bvh_node_vertex_offsets .end ())
1254+ {
1255+ glPopClientAttrib ();
1256+ glPopAttrib ();
12271257 return ;
12281258 }
12291259
@@ -1284,6 +1314,8 @@ void BoundingBoxDrawCallback::drawImplementation(osg::RenderInfo& renderInfo, co
12841314 glBindBuffer (GL_ELEMENT_ARRAY_BUFFER , static_cast <GLuint>(prevElementBuffer));
12851315
12861316 m_renderer->noteContextRenderCounts (ctx, frameNo, 0 , 0 , rendered_bounding_boxes);
1317+ glPopClientAttrib ();
1318+ glPopAttrib ();
12871319}
12881320
12891321
@@ -2094,6 +2126,9 @@ InitDrawCallback::InitDrawCallback(Lamure* plugin)
20942126
20952127void InitDrawCallback::drawImplementation (osg::RenderInfo& renderInfo, const osg::Drawable* drawable) const
20962128{
2129+
2130+ glPushAttrib (GL_ALL_ATTRIB_BITS );
2131+ glPushClientAttrib (GL_CLIENT_ALL_ATTRIB_BITS );
20972132 int ctx = renderInfo.getContextID ();
20982133 osg::Camera* cam = renderInfo.getCurrentCamera ();
20992134 if (!cam) {
@@ -2182,6 +2217,9 @@ void InitDrawCallback::drawImplementation(osg::RenderInfo& renderInfo, const osg
21822217 }
21832218
21842219 if (drawable) { drawable->drawImplementation (renderInfo); }
2220+
2221+ glPopClientAttrib ();
2222+ glPopAttrib ();
21852223}
21862224
21872225StatsDrawCallback::StatsDrawCallback (Lamure *plugin, osgText::Text *label, osgText::Text *values)
0 commit comments