1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-06-05 11:24:17 +03:00

0024687: TKOpenGl shader programs - same view state for different v3d views

OpenGl_ShaderManager::IsSameView() - add const
This commit is contained in:
duv 2014-03-20 14:39:23 +04:00 committed by bugmaster
parent 1704c57631
commit e6804ff7c0
3 changed files with 41 additions and 3 deletions

View File

@ -33,8 +33,9 @@ IMPLEMENT_STANDARD_RTTIEXT(OpenGl_ShaderManager, Standard_Transient)
// purpose : Creates new empty shader manager // purpose : Creates new empty shader manager
// ======================================================================= // =======================================================================
OpenGl_ShaderManager::OpenGl_ShaderManager (OpenGl_Context* theContext) OpenGl_ShaderManager::OpenGl_ShaderManager (OpenGl_Context* theContext)
: myContext (theContext), : myContext (theContext),
myIsPP (Standard_False) myIsPP (Standard_False),
myLastView (NULL)
{ {
// //
} }

View File

@ -25,6 +25,8 @@
#include <OpenGl_ShaderProgram.hxx> #include <OpenGl_ShaderProgram.hxx>
#include <OpenGl_ShaderStates.hxx> #include <OpenGl_ShaderStates.hxx>
class OpenGl_View;
//! List of shader programs. //! List of shader programs.
typedef NCollection_Sequence<Handle(OpenGl_ShaderProgram)> OpenGl_ShaderProgramList; typedef NCollection_Sequence<Handle(OpenGl_ShaderProgram)> OpenGl_ShaderProgramList;
@ -165,6 +167,19 @@ public:
myContext = theCtx; 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: protected:
OpenGl_ShaderProgramList myProgramList; //!< The list of shader programs OpenGl_ShaderProgramList myProgramList; //!< The list of shader programs
@ -173,7 +188,7 @@ protected:
private: private:
Standard_Boolean myIsPP; //!< Is any program object bound (programmable pipeline)? 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 #endif // _OpenGl_ShaderManager_HeaderFile

View File

@ -421,6 +421,19 @@ void OpenGl_View::Render (const Handle(OpenGl_PrinterContext)& thePrintContext,
} }
} }
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 // Step 2: Redraw background
// ==================================== // ====================================
@ -624,6 +637,15 @@ void OpenGl_View::Render (const Handle(OpenGl_PrinterContext)& thePrintContext,
} }
delete[] aOldPlanes; delete[] aOldPlanes;
// ==============================================================
// Step 8: Keep shader manager informed about last View
// ==============================================================
if (!aManager.IsNull())
{
aManager->SetLastView (this);
}
} }
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/