From ca1028006decda08ad37b13755a8f6c086189cda Mon Sep 17 00:00:00 2001 From: duv Date: Tue, 18 Mar 2014 15:22:31 +0400 Subject: [PATCH] 0024354: TKOpenGl - location modification of multi-connected shape has no effect when object is drawn by GLSL program --- src/OpenGl/OpenGl_ShaderStates.cxx | 16 ++++++++++++---- src/OpenGl/OpenGl_ShaderStates.hxx | 6 +++++- 2 files changed, 17 insertions(+), 5 deletions(-) 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. };