0025213: Visualization, TKOpenGl - do not use deprecated built-ins in GLSL shaders
[occt.git] / src / OpenGl / OpenGl_ShaderManager.hxx
index 0e494eb..1da56c2 100755 (executable)
@@ -1,11 +1,11 @@
 // Created on: 2013-09-26
 // Created by: Denis BOGOLEPOV
-// Copyright (c) 2013 OPEN CASCADE SAS
+// Copyright (c) 2013-2014 OPEN CASCADE SAS
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
@@ -25,6 +25,8 @@
 #include <OpenGl_ShaderProgram.hxx>
 #include <OpenGl_ShaderStates.hxx>
 
+class OpenGl_View;
+
 //! List of shader programs.
 typedef NCollection_Sequence<Handle(OpenGl_ShaderProgram)> OpenGl_ShaderProgramList;
 
@@ -90,10 +92,10 @@ public:
   Standard_EXPORT const OpenGl_ProjectionState& ProjectionState() const;
 
   //! Updates state of OCCT projection transform.
-  Standard_EXPORT void UpdateProjectionStateTo (const Tmatrix3& theProjectionMatrix);
+  Standard_EXPORT void UpdateProjectionStateTo (const Tmatrix3* theProjectionMatrix);
 
   //! Reverts state of OCCT projection transform.
-  Standard_EXPORT void RevertProjectionStateTo (const Tmatrix3& theProjectionMatrix);
+  Standard_EXPORT void RevertProjectionStateTo (const Tmatrix3* theProjectionMatrix);
 
   //! Pushes current state of OCCT projection transform to specified program.
   Standard_EXPORT void PushProjectionState (const Handle(OpenGl_ShaderProgram)& theProgram) const;
@@ -104,10 +106,10 @@ public:
   Standard_EXPORT const OpenGl_ModelWorldState& ModelWorldState() const;
 
   //! Updates state of OCCT model-world transform.
-  Standard_EXPORT void UpdateModelWorldStateTo (const Tmatrix3& theModelWorldMatrix);
+  Standard_EXPORT void UpdateModelWorldStateTo (const Tmatrix3* theModelWorldMatrix);
 
   //! Reverts state of OCCT model-world transform.
-  Standard_EXPORT void RevertModelWorldStateTo (const Tmatrix3& theModelWorldMatrix);
+  Standard_EXPORT void RevertModelWorldStateTo (const Tmatrix3* theModelWorldMatrix);
 
   //! Pushes current state of OCCT model-world transform to specified program.
   Standard_EXPORT void PushModelWorldState (const Handle(OpenGl_ShaderProgram)& theProgram) const;
@@ -118,10 +120,10 @@ public:
   Standard_EXPORT const OpenGl_WorldViewState& WorldViewState() const;
 
   //! Updates state of OCCT world-view transform.
-  Standard_EXPORT void UpdateWorldViewStateTo (const Tmatrix3& theWorldViewMatrix);
+  Standard_EXPORT void UpdateWorldViewStateTo (const Tmatrix3* theWorldViewMatrix);
 
   //! Reverts state of OCCT world-view transform.
-  Standard_EXPORT void RevertWorldViewStateTo (const Tmatrix3& theWorldViewMatrix);
+  Standard_EXPORT void RevertWorldViewStateTo (const Tmatrix3* theWorldViewMatrix);
 
   //! Pushes current state of OCCT world-view transform to specified program.
   Standard_EXPORT void PushWorldViewState (const Handle(OpenGl_ShaderProgram)& theProgram) const;
@@ -165,6 +167,19 @@ public:
     myContext = theCtx;
   }
 
+  //! Sets last view manger used with.
+  //! Helps to handle matrix states in multi-view configurations.
+  void SetLastView (const OpenGl_View* theLastView)
+  {
+    myLastView = theLastView;
+  }
+
+  //! Returns true when provided view is the same as cached one.
+  bool IsSameView (const OpenGl_View* theView) const
+  {
+    return myLastView == theView;
+  }
+
 protected:
 
   OpenGl_ShaderProgramList myProgramList;  //!< The list of shader programs
@@ -172,8 +187,7 @@ protected:
 
 private:
 
-  Standard_Boolean         myIsPP;         //!< Is any program object bound (programmable pipeline)?
-
+  const OpenGl_View*       myLastView;     //!< Pointer to the last view shader manager used with.
 };
 
 #endif // _OpenGl_ShaderManager_HeaderFile