diff --git a/src/OpenGl/OpenGl_ShaderStates.cxx b/src/OpenGl/OpenGl_ShaderStates.cxx index c9bce15d29..d973809de7 100755 --- a/src/OpenGl/OpenGl_ShaderStates.cxx +++ b/src/OpenGl/OpenGl_ShaderStates.cxx @@ -22,7 +22,8 @@ // purpose : Creates new OCCT state // ======================================================================= OpenGl_StateInterface::OpenGl_StateInterface() -: myIndex (0) +: myIndex (0), + myNextIndex (1) { // } @@ -42,7 +43,9 @@ Standard_Size OpenGl_StateInterface::Index() const // ======================================================================= void OpenGl_StateInterface::Update() { - ++myIndex; + myStateStack.Push (myIndex); + myIndex = myNextIndex; + ++myNextIndex; } // ======================================================================= @@ -51,9 +54,14 @@ void OpenGl_StateInterface::Update() // ======================================================================= void OpenGl_StateInterface::Revert() { - if (myIndex > 0) + if (!myStateStack.IsEmpty()) { - --myIndex; + myIndex = myStateStack.Top(); + myStateStack.Pop(); + } + else + { + myIndex = 0; } } diff --git a/src/OpenGl/OpenGl_ShaderStates.hxx b/src/OpenGl/OpenGl_ShaderStates.hxx index 9d10d6fb43..80126a93a0 100755 --- a/src/OpenGl/OpenGl_ShaderStates.hxx +++ b/src/OpenGl/OpenGl_ShaderStates.hxx @@ -21,6 +21,8 @@ #include #include +#include + //! Defines interface for OpenGL state. class OpenGl_StateInterface { @@ -40,7 +42,9 @@ public: protected: - Standard_Size myIndex; //!< Current state index + Standard_Size myIndex; //!< Current state index + Standard_Size myNextIndex; //!< Next state index + NCollection_Stack myStateStack; //!< Stack of previous states. };