Hi Frank, Thanks for the reply! I'll try setting up something similar in my application.
On Fri, Jul 6, 2012 at 3:52 PM, Frank Kane <[email protected]> wrote: > From what I've read, captureCurrentState just returns the current state > attributes in OSG - it's not actually capturing the current GL state. > > But, you could flip the problem on its head and capture the actual OpenGL > state just prior to calling your library, and then restoring it when your > library is done with its drawing. Here is some code to start from that > catches most of the stuff that's likely to change; for completeness, you'd > want to capture all of the state documented at > http://www.khronos.org/opengles/sdk/1.1/docs/man/glGet.xml as well. > > > Code: > > typedef struct glState_S { > GLboolean depthTest, blend, cullFace; > GLboolean dither, colorLogicOp, polygonOffsetLine, polygonOffsetFill; > GLboolean polygonOffsetPoint, polygonSmooth, scissorTest, stencilTest; > } glState; > > static std::stack<glState> stateStack; > > SILVERLININGDLL_API bool PushAllState(void) > { > glState state; > > state.blend = glIsEnabled(GL_BLEND); > state.depthTest = glIsEnabled(GL_DEPTH_TEST); > state.cullFace = glIsEnabled(GL_CULL_FACE); > state.dither = glIsEnabled(GL_DITHER); > state.polygonOffsetFill = glIsEnabled(GL_POLYGON_OFFSET_FILL); > state.scissorTest = glIsEnabled(GL_SCISSOR_TEST); > state.stencilTest = glIsEnabled(GL_STENCIL_TEST); > > stateStack.push(state); > > CheckError(__LINE__); > > return true; > } > > SILVERLININGDLL_API bool PopAllState(void) > { > if (!stateStack.empty()) { > glState state = stateStack.top(); > > if (state.blend) glEnable(GL_BLEND); else glDisable(GL_BLEND); > if (state.depthTest) glEnable(GL_DEPTH_TEST); else > glDisable(GL_DEPTH_TEST); > if (state.cullFace) glEnable(GL_CULL_FACE); else > glDisable(GL_CULL_FACE); > if (state.dither) glEnable(GL_DITHER); else glDisable(GL_DITHER); > if (state.polygonOffsetFill) glEnable(GL_POLYGON_OFFSET_FILL); else > glDisable(GL_POLYGON_OFFSET_FILL); > if (state.scissorTest) glEnable(GL_SCISSOR_TEST); else > glDisable(GL_SCISSOR_TEST); > if (state.stencilTest) glEnable(GL_STENCIL_TEST); else > glDisable(GL_STENCIL_TEST); > > stateStack.pop(); > } > > CheckError(__LINE__); > > return true; > } > > > > > Best regards, > Frank Kane > Founder, Sundog Software LLC > > ------------------ > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=48737#48737 > > > > > > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

