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:
parent
1704c57631
commit
e6804ff7c0
@ -34,7 +34,8 @@ IMPLEMENT_STANDARD_RTTIEXT(OpenGl_ShaderManager, Standard_Transient)
|
|||||||
// =======================================================================
|
// =======================================================================
|
||||||
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)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user