// purpose : Creates new empty shader manager
// =======================================================================
OpenGl_ShaderManager::OpenGl_ShaderManager (OpenGl_Context* theContext)
-: myContext (theContext),
- myIsPP (Standard_False)
+: myContext (theContext),
+ myIsPP (Standard_False),
+ myLastView (NULL)
{
//
}
#include <OpenGl_ShaderProgram.hxx>
#include <OpenGl_ShaderStates.hxx>
+class OpenGl_View;
+
//! List of shader programs.
typedef NCollection_Sequence<Handle(OpenGl_ShaderProgram)> OpenGl_ShaderProgramList;
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
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
}
}
+ if (!aManager.IsNull())
+ {
+ if (!aManager->IsSameView (this))
+ {
+ // Force update camera states
+ myProjectionState = myCamera->ProjectionState();
+ aManager->UpdateProjectionStateTo ((const Tmatrix3*)myCamera->ProjectionMatrixF().GetData());
+
+ myModelViewState = myCamera->ModelViewState();
+ aManager->UpdateWorldViewStateTo ((const Tmatrix3*)myCamera->OrientationMatrixF().GetData());
+ }
+ }
+
// ====================================
// Step 2: Redraw background
// ====================================
}
delete[] aOldPlanes;
+
+ // ==============================================================
+ // Step 8: Keep shader manager informed about last View
+ // ==============================================================
+
+ if (!aManager.IsNull())
+ {
+ aManager->SetLastView (this);
+ }
}
/*----------------------------------------------------------------------*/