// =======================================================================
void OpenGl_AspectText::Release (const Handle(OpenGl_Context)& theContext)
{
- if (!myResources.ShaderProgram.IsNull() && !theContext.IsNull())
+ if (!myResources.ShaderProgram.IsNull()
+ && !theContext.IsNull())
{
- theContext->ShaderManager()->Unregister (myResources.ShaderProgram);
+ theContext->ShaderManager()->Unregister (myResources.ShaderProgramId,
+ myResources.ShaderProgram);
}
myResources.ShaderProgramId.Clear();
myResources.ResetShader();
// function : BuildShader
// purpose :
// =======================================================================
-void OpenGl_AspectText::Resources::BuildShader (const Handle(OpenGl_Workspace)& theWS,
+void OpenGl_AspectText::Resources::BuildShader (const Handle(OpenGl_Workspace)& theWS,
const Handle(Graphic3d_ShaderProgram)& theShader)
{
const Handle(OpenGl_Context)& aContext = theWS->GetGlContext();
-
if (!aContext->IsGlGreaterEqual (2, 0))
+ {
return;
+ }
// release old shader program resources
if (!ShaderProgram.IsNull())
{
- aContext->ShaderManager()->Unregister (ShaderProgram);
+ aContext->ShaderManager()->Unregister (ShaderProgramId, ShaderProgram);
}
-
- ShaderProgramId = theShader.IsNull() ? THE_EMPTY_KEY : theShader->GetId();
-
- if (!theShader.IsNull())
+ if (theShader.IsNull())
{
- if (!aContext->GetResource<Handle(OpenGl_ShaderProgram)> (ShaderProgramId, ShaderProgram))
- {
- ShaderProgram = aContext->ShaderManager()->Create (theShader);
- if (!ShaderProgramId.IsEmpty())
- {
- aContext->ShareResource (ShaderProgramId, ShaderProgram);
- }
- }
- }
- else
- {
- ShaderProgram.Nullify();
+ return;
}
+
+ aContext->ShaderManager()->Create (theShader, ShaderProgramId, ShaderProgram);
}