1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-16 10:08:36 +03:00

0024348: TKOpenGl - the same GLSL program can not be re-assigned

Reset shader id in OpenGl aspects.
Setup/retrieve shader program within getters/setters of Graphic3d_Group/Graphic3d_Structure (add missing ones).
This commit is contained in:
kgv 2013-11-13 21:04:52 +04:00 committed by bugmaster
parent c90e941f78
commit f85399e5df
10 changed files with 96 additions and 63 deletions

View File

@ -715,26 +715,31 @@ void Graphic3d_Group::GroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d
Aspect_TypeOfDisplayText ADisplayType; Aspect_TypeOfDisplayText ADisplayType;
Quantity_Color AColorSubTitle; Quantity_Color AColorSubTitle;
if (MyCGroup.ContextLine.IsSet) { if (MyCGroup.ContextLine.IsSet)
{
R = Standard_Real (MyCGroup.ContextLine.Color.r); R = Standard_Real (MyCGroup.ContextLine.Color.r);
G = Standard_Real (MyCGroup.ContextLine.Color.g); G = Standard_Real (MyCGroup.ContextLine.Color.g);
B = Standard_Real (MyCGroup.ContextLine.Color.b); B = Standard_Real (MyCGroup.ContextLine.Color.b);
ALType = Aspect_TypeOfLine (MyCGroup.ContextLine.LineType); ALType = Aspect_TypeOfLine (MyCGroup.ContextLine.LineType);
AWidth = Standard_Real (MyCGroup.ContextLine.Width); AWidth = Standard_Real (MyCGroup.ContextLine.Width);
CTXL->SetShaderProgram (MyCGroup.ContextLine.ShaderProgram);
} }
else { else
{
R = Standard_Real (MyCGroup.Struct->ContextLine.Color.r); R = Standard_Real (MyCGroup.Struct->ContextLine.Color.r);
G = Standard_Real (MyCGroup.Struct->ContextLine.Color.g); G = Standard_Real (MyCGroup.Struct->ContextLine.Color.g);
B = Standard_Real (MyCGroup.Struct->ContextLine.Color.b); B = Standard_Real (MyCGroup.Struct->ContextLine.Color.b);
ALType = Aspect_TypeOfLine (MyCGroup.Struct->ContextLine.LineType); ALType = Aspect_TypeOfLine (MyCGroup.Struct->ContextLine.LineType);
AWidth = Standard_Real (MyCGroup.Struct->ContextLine.Width); AWidth = Standard_Real (MyCGroup.Struct->ContextLine.Width);
CTXL->SetShaderProgram (MyCGroup.Struct->ContextLine.ShaderProgram);
} }
AColor.SetValues (R, G, B, Quantity_TOC_RGB); AColor.SetValues (R, G, B, Quantity_TOC_RGB);
CTXL->SetColor (AColor); CTXL->SetColor (AColor);
CTXL->SetType (ALType); CTXL->SetType (ALType);
CTXL->SetWidth (AWidth); CTXL->SetWidth (AWidth);
if (MyCGroup.ContextText.IsSet) { if (MyCGroup.ContextText.IsSet)
{
R = Standard_Real (MyCGroup.ContextText.Color.r); R = Standard_Real (MyCGroup.ContextText.Color.r);
G = Standard_Real (MyCGroup.ContextText.Color.g); G = Standard_Real (MyCGroup.ContextText.Color.g);
B = Standard_Real (MyCGroup.ContextText.Color.b); B = Standard_Real (MyCGroup.ContextText.Color.b);
@ -746,8 +751,10 @@ void Graphic3d_Group::GroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d
ASpace = Standard_Real (MyCGroup.ContextText.Space); ASpace = Standard_Real (MyCGroup.ContextText.Space);
AStyleT = Aspect_TypeOfStyleText (MyCGroup.ContextText.Style); AStyleT = Aspect_TypeOfStyleText (MyCGroup.ContextText.Style);
ADisplayType= Aspect_TypeOfDisplayText (MyCGroup.ContextText.DisplayType); ADisplayType= Aspect_TypeOfDisplayText (MyCGroup.ContextText.DisplayType);
CTXT->SetShaderProgram (MyCGroup.ContextText.ShaderProgram);
} }
else { else
{
R = Standard_Real (MyCGroup.Struct->ContextText.Color.r); R = Standard_Real (MyCGroup.Struct->ContextText.Color.r);
G = Standard_Real (MyCGroup.Struct->ContextText.Color.g); G = Standard_Real (MyCGroup.Struct->ContextText.Color.g);
B = Standard_Real (MyCGroup.Struct->ContextText.Color.b); B = Standard_Real (MyCGroup.Struct->ContextText.Color.b);
@ -759,6 +766,7 @@ void Graphic3d_Group::GroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d
ASpace = Standard_Real (MyCGroup.Struct->ContextText.Space); ASpace = Standard_Real (MyCGroup.Struct->ContextText.Space);
AStyleT = Aspect_TypeOfStyleText (MyCGroup.Struct->ContextText.Style); AStyleT = Aspect_TypeOfStyleText (MyCGroup.Struct->ContextText.Style);
ADisplayType = Aspect_TypeOfDisplayText (MyCGroup.Struct->ContextText.DisplayType); ADisplayType = Aspect_TypeOfDisplayText (MyCGroup.Struct->ContextText.DisplayType);
CTXT->SetShaderProgram (MyCGroup.Struct->ContextText.ShaderProgram);
} }
AColor.SetValues (R, G, B, Quantity_TOC_RGB); AColor.SetValues (R, G, B, Quantity_TOC_RGB);
AColorSubTitle.SetValues (Rs, Gs, Bs, Quantity_TOC_RGB); AColorSubTitle.SetValues (Rs, Gs, Bs, Quantity_TOC_RGB);
@ -770,31 +778,36 @@ void Graphic3d_Group::GroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d
CTXT->SetDisplayType (ADisplayType); CTXT->SetDisplayType (ADisplayType);
CTXT->SetColorSubTitle (AColorSubTitle); CTXT->SetColorSubTitle (AColorSubTitle);
if (MyCGroup.ContextMarker.IsSet) { if (MyCGroup.ContextMarker.IsSet)
{
R = Standard_Real (MyCGroup.ContextMarker.Color.r); R = Standard_Real (MyCGroup.ContextMarker.Color.r);
G = Standard_Real (MyCGroup.ContextMarker.Color.g); G = Standard_Real (MyCGroup.ContextMarker.Color.g);
B = Standard_Real (MyCGroup.ContextMarker.Color.b); B = Standard_Real (MyCGroup.ContextMarker.Color.b);
AMType = MyCGroup.ContextMarker.MarkerType; AMType = MyCGroup.ContextMarker.MarkerType;
AScale = Standard_Real (MyCGroup.ContextMarker.Scale); AScale = Standard_Real (MyCGroup.ContextMarker.Scale);
CTXT->SetShaderProgram (MyCGroup.ContextMarker.ShaderProgram);
if (AMType == Aspect_TOM_USERDEFINED) if (AMType == Aspect_TOM_USERDEFINED)
{ {
CTXM->SetBitMap (MyMarkWidth, MyMarkHeight, MyMarkArray); CTXM->SetBitMap (MyMarkWidth, MyMarkHeight, MyMarkArray);
} }
} }
else { else
{
R = Standard_Real (MyCGroup.Struct->ContextMarker.Color.r); R = Standard_Real (MyCGroup.Struct->ContextMarker.Color.r);
G = Standard_Real (MyCGroup.Struct->ContextMarker.Color.g); G = Standard_Real (MyCGroup.Struct->ContextMarker.Color.g);
B = Standard_Real (MyCGroup.Struct->ContextMarker.Color.b); B = Standard_Real (MyCGroup.Struct->ContextMarker.Color.b);
AMType = MyCGroup.Struct->ContextMarker.MarkerType; AMType = MyCGroup.Struct->ContextMarker.MarkerType;
AScale = Standard_Real (MyCGroup.Struct->ContextMarker.Scale); AScale = Standard_Real (MyCGroup.Struct->ContextMarker.Scale);
CTXT->SetShaderProgram (MyCGroup.Struct->ContextMarker.ShaderProgram);
} }
AColor.SetValues (R, G, B, Quantity_TOC_RGB); AColor.SetValues (R, G, B, Quantity_TOC_RGB);
CTXM->SetColor (AColor); CTXM->SetColor (AColor);
CTXM->SetType (AMType); CTXM->SetType (AMType);
CTXM->SetScale (AScale); CTXM->SetScale (AScale);
if (MyCGroup.ContextFillArea.IsSet) { if (MyCGroup.ContextFillArea.IsSet)
{
// Interior // Interior
AStyle = Aspect_InteriorStyle (MyCGroup.ContextFillArea.Style); AStyle = Aspect_InteriorStyle (MyCGroup.ContextFillArea.Style);
R = Standard_Real (MyCGroup.ContextFillArea.IntColor.r); R = Standard_Real (MyCGroup.ContextFillArea.IntColor.r);
@ -939,6 +952,7 @@ void Graphic3d_Group::GroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d
{ {
CTXF->SetTextureMapOff(); CTXF->SetTextureMapOff();
} }
CTXF->SetShaderProgram (MyCGroup.ContextFillArea.ShaderProgram);
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
CTXF->SetPolygonOffsets(MyCGroup.ContextFillArea.PolygonOffsetMode, CTXF->SetPolygonOffsets(MyCGroup.ContextFillArea.PolygonOffsetMode,
@ -946,7 +960,8 @@ void Graphic3d_Group::GroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d
MyCGroup.ContextFillArea.PolygonOffsetUnits); MyCGroup.ContextFillArea.PolygonOffsetUnits);
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
} }
else { else
{
// Interior // Interior
AStyle = Aspect_InteriorStyle (MyCGroup.Struct->ContextFillArea.Style); AStyle = Aspect_InteriorStyle (MyCGroup.Struct->ContextFillArea.Style);
R = Standard_Real (MyCGroup.Struct->ContextFillArea.IntColor.r); R = Standard_Real (MyCGroup.Struct->ContextFillArea.IntColor.r);
@ -1091,6 +1106,7 @@ void Graphic3d_Group::GroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d
{ {
CTXF->SetTextureMapOff(); CTXF->SetTextureMapOff();
} }
CTXF->SetShaderProgram (MyCGroup.Struct->ContextFillArea.ShaderProgram);
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
CTXF->SetPolygonOffsets(MyCGroup.Struct->ContextFillArea.PolygonOffsetMode, CTXF->SetPolygonOffsets(MyCGroup.Struct->ContextFillArea.PolygonOffsetMode,

View File

@ -750,8 +750,8 @@ Handle(Graphic3d_AspectLine3d) Graphic3d_Structure::Line3dAspect () const {
ALType = Aspect_TypeOfLine (MyCStructure.ContextLine.LineType); ALType = Aspect_TypeOfLine (MyCStructure.ContextLine.LineType);
AWidth = Standard_Real (MyCStructure.ContextLine.Width); AWidth = Standard_Real (MyCStructure.ContextLine.Width);
Handle(Graphic3d_AspectLine3d) CTXL = Handle(Graphic3d_AspectLine3d) CTXL = new Graphic3d_AspectLine3d (AColor, ALType, AWidth);
new Graphic3d_AspectLine3d (AColor, ALType, AWidth); CTXL->SetShaderProgram (MyCStructure.ContextLine.ShaderProgram);
return CTXL; return CTXL;
@ -778,8 +778,8 @@ Handle(Graphic3d_AspectText3d) Graphic3d_Structure::Text3dAspect () const {
AStyle = Aspect_TypeOfStyleText (MyCStructure.ContextText.Style); AStyle = Aspect_TypeOfStyleText (MyCStructure.ContextText.Style);
ADisplayType = Aspect_TypeOfDisplayText (MyCStructure.ContextText.DisplayType); ADisplayType = Aspect_TypeOfDisplayText (MyCStructure.ContextText.DisplayType);
Handle(Graphic3d_AspectText3d) CTXT = Handle(Graphic3d_AspectText3d) CTXT = new Graphic3d_AspectText3d (AColor, AFont, AnExpansion, ASpace,AStyle,ADisplayType);
new Graphic3d_AspectText3d (AColor, AFont, AnExpansion, ASpace,AStyle,ADisplayType); CTXT->SetShaderProgram (MyCStructure.ContextText.ShaderProgram);
return CTXT; return CTXT;
@ -800,8 +800,8 @@ Handle(Graphic3d_AspectMarker3d) Graphic3d_Structure::Marker3dAspect () const {
AMType = MyCStructure.ContextMarker.MarkerType; AMType = MyCStructure.ContextMarker.MarkerType;
AScale = Standard_Real (MyCStructure.ContextMarker.Scale); AScale = Standard_Real (MyCStructure.ContextMarker.Scale);
Handle(Graphic3d_AspectMarker3d) CTXM = Handle(Graphic3d_AspectMarker3d) CTXM = new Graphic3d_AspectMarker3d (AMType, AColor, AScale);
new Graphic3d_AspectMarker3d (AMType, AColor, AScale); CTXM->SetShaderProgram (MyCStructure.ContextMarker.ShaderProgram);
return CTXM; return CTXM;
@ -984,6 +984,7 @@ Graphic3d_MATERIAL_PHYSIC : Graphic3d_MATERIAL_ASPECT;
{ {
CTXF->SetTextureMapOff(); CTXF->SetTextureMapOff();
} }
CTXF->SetShaderProgram (MyCStructure.ContextFillArea.ShaderProgram);
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
CTXF->SetPolygonOffsets(MyCStructure.ContextFillArea.PolygonOffsetMode, CTXF->SetPolygonOffsets(MyCStructure.ContextFillArea.PolygonOffsetMode,
@ -1020,6 +1021,7 @@ void Graphic3d_Structure::SetPrimitivesAspect (const Handle(Graphic3d_AspectLine
MyCStructure.ContextLine.Color.b = float (B); MyCStructure.ContextLine.Color.b = float (B);
MyCStructure.ContextLine.LineType = int (ALType); MyCStructure.ContextLine.LineType = int (ALType);
MyCStructure.ContextLine.Width = float (AWidth); MyCStructure.ContextLine.Width = float (AWidth);
MyCStructure.ContextLine.ShaderProgram = CTX->ShaderProgram();
MyCStructure.ContextLine.IsDef = 1; MyCStructure.ContextLine.IsDef = 1;
MyGraphicDriver->ContextStructure (MyCStructure); MyGraphicDriver->ContextStructure (MyCStructure);
@ -1215,6 +1217,7 @@ void Graphic3d_Structure::SetPrimitivesAspect (const Handle(Graphic3d_AspectFill
MyCStructure.ContextFillArea.Texture.TextureMap = CTX->TextureMap(); MyCStructure.ContextFillArea.Texture.TextureMap = CTX->TextureMap();
MyCStructure.ContextFillArea.Texture.doTextureMap = CTX->TextureMapState() ? 1 : 0; MyCStructure.ContextFillArea.Texture.doTextureMap = CTX->TextureMapState() ? 1 : 0;
MyCStructure.ContextFillArea.ShaderProgram = CTX->ShaderProgram();
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
Standard_Integer aPolyMode; Standard_Integer aPolyMode;
@ -1274,6 +1277,7 @@ void Graphic3d_Structure::SetPrimitivesAspect (const Handle(Graphic3d_AspectText
MyCStructure.ContextText.TextZoomable = ATextZoomable; MyCStructure.ContextText.TextZoomable = ATextZoomable;
MyCStructure.ContextText.TextAngle = float (ATextAngle); MyCStructure.ContextText.TextAngle = float (ATextAngle);
MyCStructure.ContextText.TextFontAspect = int (ATextFontAspect); MyCStructure.ContextText.TextFontAspect = int (ATextFontAspect);
MyCStructure.ContextText.ShaderProgram = CTX->ShaderProgram();
MyCStructure.ContextText.IsDef = 1; MyCStructure.ContextText.IsDef = 1;
@ -1307,6 +1311,7 @@ void Graphic3d_Structure::SetPrimitivesAspect (const Handle(Graphic3d_AspectMark
MyCStructure.ContextMarker.Color.b = float (B); MyCStructure.ContextMarker.Color.b = float (B);
MyCStructure.ContextMarker.MarkerType = AMType; MyCStructure.ContextMarker.MarkerType = AMType;
MyCStructure.ContextMarker.Scale = float (AScale); MyCStructure.ContextMarker.Scale = float (AScale);
MyCStructure.ContextMarker.ShaderProgram = CTX->ShaderProgram();
MyCStructure.ContextMarker.IsDef = 1; MyCStructure.ContextMarker.IsDef = 1;
MyGraphicDriver->ContextStructure (MyCStructure); MyGraphicDriver->ContextStructure (MyCStructure);
@ -2071,6 +2076,7 @@ void Graphic3d_Structure::UpdateStructure (const Handle(Graphic3d_AspectLine3d)&
MyCStructure.ContextLine.Color.b = float (B); MyCStructure.ContextLine.Color.b = float (B);
MyCStructure.ContextLine.LineType = int (ALType); MyCStructure.ContextLine.LineType = int (ALType);
MyCStructure.ContextLine.Width = float (AWidth); MyCStructure.ContextLine.Width = float (AWidth);
MyCStructure.ContextLine.ShaderProgram = CTXL->ShaderProgram();
CTXM->Values (AColor, AMType, AScale); CTXM->Values (AColor, AMType, AScale);
AColor.Values (R, G, B, Quantity_TOC_RGB); AColor.Values (R, G, B, Quantity_TOC_RGB);
@ -2080,6 +2086,7 @@ void Graphic3d_Structure::UpdateStructure (const Handle(Graphic3d_AspectLine3d)&
MyCStructure.ContextMarker.Color.b = float (B); MyCStructure.ContextMarker.Color.b = float (B);
MyCStructure.ContextMarker.MarkerType = AMType; MyCStructure.ContextMarker.MarkerType = AMType;
MyCStructure.ContextMarker.Scale = float (AScale); MyCStructure.ContextMarker.Scale = float (AScale);
MyCStructure.ContextMarker.ShaderProgram = CTXM->ShaderProgram();
CTXT->Values (AColor, AFont, AnExpansion, ASpace,AStyleT,ADisplayType,AColorSubTitle,ATextZoomable,ATextAngle,ATextFontAspect); CTXT->Values (AColor, AFont, AnExpansion, ASpace,AStyleT,ADisplayType,AColorSubTitle,ATextZoomable,ATextAngle,ATextFontAspect);
AColor.Values (R, G, B, Quantity_TOC_RGB); AColor.Values (R, G, B, Quantity_TOC_RGB);
@ -2099,6 +2106,7 @@ void Graphic3d_Structure::UpdateStructure (const Handle(Graphic3d_AspectLine3d)&
MyCStructure.ContextText.TextZoomable = ATextZoomable; MyCStructure.ContextText.TextZoomable = ATextZoomable;
MyCStructure.ContextText.TextAngle = float (ATextAngle); MyCStructure.ContextText.TextAngle = float (ATextAngle);
MyCStructure.ContextText.TextFontAspect = int (ATextFontAspect); MyCStructure.ContextText.TextFontAspect = int (ATextFontAspect);
MyCStructure.ContextText.ShaderProgram = CTXT->ShaderProgram();
@ -2264,6 +2272,7 @@ void Graphic3d_Structure::UpdateStructure (const Handle(Graphic3d_AspectLine3d)&
MyCStructure.ContextFillArea.Texture.TextureMap = CTXF->TextureMap(); MyCStructure.ContextFillArea.Texture.TextureMap = CTXF->TextureMap();
MyCStructure.ContextFillArea.Texture.doTextureMap = CTXF->TextureMapState() ? 1 : 0; MyCStructure.ContextFillArea.Texture.doTextureMap = CTXF->TextureMapState() ? 1 : 0;
MyCStructure.ContextFillArea.ShaderProgram = CTXF->ShaderProgram();
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
Standard_Integer aPolyMode; Standard_Integer aPolyMode;

View File

@ -226,7 +226,7 @@ void OpenGl_AspectFace::SetAspect (const CALL_DEF_CONTEXTFILLAREA& theAspect)
const TCollection_AsciiString& aTextureKey = myTexture.IsNull() ? THE_EMPTY_KEY : myTexture->GetId(); const TCollection_AsciiString& aTextureKey = myTexture.IsNull() ? THE_EMPTY_KEY : myTexture->GetId();
if (aTextureKey.IsEmpty() || myResources.TextureId != aTextureKey) if (aTextureKey.IsEmpty() || myResources.TextureId != aTextureKey)
{ {
myResources.ResetTexture(); myResources.ResetTextureReadiness();
} }
// update shader program binding // update shader program binding
@ -235,7 +235,7 @@ void OpenGl_AspectFace::SetAspect (const CALL_DEF_CONTEXTFILLAREA& theAspect)
const TCollection_AsciiString& aShaderKey = myShaderProgram.IsNull() ? THE_EMPTY_KEY : myShaderProgram->GetId(); const TCollection_AsciiString& aShaderKey = myShaderProgram.IsNull() ? THE_EMPTY_KEY : myShaderProgram->GetId();
if (aShaderKey.IsEmpty() || myResources.ShaderProgramId != aShaderKey) if (aShaderKey.IsEmpty() || myResources.ShaderProgramId != aShaderKey)
{ {
myResources.ResetShader(); myResources.ResetShaderReadiness();
} }
} }
@ -411,7 +411,7 @@ void OpenGl_AspectFace::Release (const Handle(OpenGl_Context)& theContext)
myResources.Texture.Nullify(); myResources.Texture.Nullify();
} }
myResources.TextureId.Clear(); myResources.TextureId.Clear();
myResources.ResetTexture(); myResources.ResetTextureReadiness();
if (!myResources.ShaderProgram.IsNull() if (!myResources.ShaderProgram.IsNull()
&& !theContext.IsNull()) && !theContext.IsNull())
@ -420,7 +420,7 @@ void OpenGl_AspectFace::Release (const Handle(OpenGl_Context)& theContext)
myResources.ShaderProgram); myResources.ShaderProgram);
} }
myResources.ShaderProgramId.Clear(); myResources.ShaderProgramId.Clear();
myResources.ResetShader(); myResources.ResetShaderReadiness();
} }
// ======================================================================= // =======================================================================
@ -484,6 +484,8 @@ void OpenGl_AspectFace::Resources::BuildShader (const Handle(OpenGl_Workspace)&
if (!ShaderProgram.IsNull()) if (!ShaderProgram.IsNull())
{ {
aContext->ShaderManager()->Unregister (ShaderProgramId, ShaderProgram); aContext->ShaderManager()->Unregister (ShaderProgramId, ShaderProgram);
ShaderProgramId.Clear();
ShaderProgram.Nullify();
} }
if (theShader.IsNull()) if (theShader.IsNull())
{ {

View File

@ -249,8 +249,8 @@ protected:
Standard_Boolean IsShaderReady () const { return myIsShaderReady; } Standard_Boolean IsShaderReady () const { return myIsShaderReady; }
void SetTextureReady() { myIsTextureReady = Standard_True; } void SetTextureReady() { myIsTextureReady = Standard_True; }
void SetShaderReady () { myIsShaderReady = Standard_True; } void SetShaderReady () { myIsShaderReady = Standard_True; }
void ResetTexture() { myIsTextureReady = Standard_False; } void ResetTextureReadiness() { myIsTextureReady = Standard_False; }
void ResetShader () { myIsShaderReady = Standard_False; } void ResetShaderReadiness () { myIsShaderReady = Standard_False; }
void BuildTexture (const Handle(OpenGl_Workspace)& theWS, const Handle(Graphic3d_TextureMap)& theTexture); void BuildTexture (const Handle(OpenGl_Workspace)& theWS, const Handle(Graphic3d_TextureMap)& theTexture);
void BuildShader (const Handle(OpenGl_Workspace)& theWS, const Handle(Graphic3d_ShaderProgram)& theShader); void BuildShader (const Handle(OpenGl_Workspace)& theWS, const Handle(Graphic3d_ShaderProgram)& theShader);

View File

@ -70,7 +70,7 @@ void OpenGl_AspectLine::SetAspect (const CALL_DEF_CONTEXTLINE &theAspect)
const TCollection_AsciiString& aShaderKey = myShaderProgram.IsNull() ? THE_EMPTY_KEY : myShaderProgram->GetId(); const TCollection_AsciiString& aShaderKey = myShaderProgram.IsNull() ? THE_EMPTY_KEY : myShaderProgram->GetId();
if (aShaderKey.IsEmpty() || myResources.ShaderProgramId != aShaderKey) if (aShaderKey.IsEmpty() || myResources.ShaderProgramId != aShaderKey)
{ {
myResources.ResetShader(); myResources.ResetShaderReadiness();
} }
} }
@ -96,7 +96,7 @@ void OpenGl_AspectLine::Release (const Handle(OpenGl_Context)& theContext)
myResources.ShaderProgram); myResources.ShaderProgram);
} }
myResources.ShaderProgramId.Clear(); myResources.ShaderProgramId.Clear();
myResources.ResetShader(); myResources.ResetShaderReadiness();
} }
// ======================================================================= // =======================================================================
@ -116,6 +116,8 @@ void OpenGl_AspectLine::Resources::BuildShader (const Handle(OpenGl_Workspace)&
if (!ShaderProgram.IsNull()) if (!ShaderProgram.IsNull())
{ {
aContext->ShaderManager()->Unregister (ShaderProgramId, ShaderProgram); aContext->ShaderManager()->Unregister (ShaderProgramId, ShaderProgram);
ShaderProgramId.Clear();
ShaderProgram.Nullify();
} }
if (theShader.IsNull()) if (theShader.IsNull())
{ {

View File

@ -75,7 +75,7 @@ protected:
Standard_Boolean IsShaderReady() const { return myIsShaderReady; } Standard_Boolean IsShaderReady() const { return myIsShaderReady; }
void SetShaderReady() { myIsShaderReady = Standard_True; } void SetShaderReady() { myIsShaderReady = Standard_True; }
void ResetShader () { myIsShaderReady = Standard_False; } void ResetShaderReadiness() { myIsShaderReady = Standard_False; }
void BuildShader (const Handle(OpenGl_Workspace)& theWS, const Handle(Graphic3d_ShaderProgram)& theShader); void BuildShader (const Handle(OpenGl_Workspace)& theWS, const Handle(Graphic3d_ShaderProgram)& theShader);

View File

@ -1482,11 +1482,11 @@ void OpenGl_AspectMarker::SetAspect (const CALL_DEF_CONTEXTMARKER& theAspect)
if (aSpriteKey.IsEmpty() || myResources.SpriteKey != aSpriteKey) if (aSpriteKey.IsEmpty() || myResources.SpriteKey != aSpriteKey)
{ {
myResources.ResetSprite(); myResources.ResetSpriteReadiness();
} }
if (aSpriteAKey.IsEmpty() || myResources.SpriteAKey != aSpriteAKey) if (aSpriteAKey.IsEmpty() || myResources.SpriteAKey != aSpriteAKey)
{ {
myResources.ResetSprite(); myResources.ResetSpriteReadiness();
} }
// update shader program resource bindings // update shader program resource bindings
@ -1494,7 +1494,7 @@ void OpenGl_AspectMarker::SetAspect (const CALL_DEF_CONTEXTMARKER& theAspect)
if (aShaderKey.IsEmpty() || myResources.ShaderProgramId != aShaderKey) if (aShaderKey.IsEmpty() || myResources.ShaderProgramId != aShaderKey)
{ {
myResources.ResetShader(); myResources.ResetShaderReadiness();
} }
} }
@ -1535,7 +1535,7 @@ void OpenGl_AspectMarker::Release (const Handle(OpenGl_Context)& theCtx)
} }
myResources.SpriteKey.Clear(); myResources.SpriteKey.Clear();
myResources.SpriteAKey.Clear(); myResources.SpriteAKey.Clear();
myResources.ResetSprite(); myResources.ResetSpriteReadiness();
if (!myResources.ShaderProgram.IsNull() && !theCtx.IsNull()) if (!myResources.ShaderProgram.IsNull() && !theCtx.IsNull())
{ {
@ -1543,7 +1543,7 @@ void OpenGl_AspectMarker::Release (const Handle(OpenGl_Context)& theCtx)
myResources.ShaderProgram); myResources.ShaderProgram);
} }
myResources.ShaderProgramId.Clear(); myResources.ShaderProgramId.Clear();
myResources.ResetShader(); myResources.ResetShaderReadiness();
} }
// ======================================================================= // =======================================================================
@ -1909,6 +1909,8 @@ void OpenGl_AspectMarker::Resources::BuildShader (const Handle(OpenGl_Workspace)
if (!ShaderProgram.IsNull()) if (!ShaderProgram.IsNull())
{ {
aContext->ShaderManager()->Unregister (ShaderProgramId, ShaderProgram); aContext->ShaderManager()->Unregister (ShaderProgramId, ShaderProgram);
ShaderProgramId.Clear();
ShaderProgram.Nullify();
} }
if (theShader.IsNull()) if (theShader.IsNull())
{ {

View File

@ -132,8 +132,8 @@ protected: //! @name OpenGl resources
Standard_Boolean IsShaderReady() const { return myIsShaderReady; } Standard_Boolean IsShaderReady() const { return myIsShaderReady; }
void SetSpriteReady() { myIsSpriteReady = Standard_True; } void SetSpriteReady() { myIsSpriteReady = Standard_True; }
void SetShaderReady() { myIsShaderReady = Standard_True; } void SetShaderReady() { myIsShaderReady = Standard_True; }
void ResetSprite () { myIsSpriteReady = Standard_False; } void ResetSpriteReadiness() { myIsSpriteReady = Standard_False; }
void ResetShader () { myIsShaderReady = Standard_False; } void ResetShaderReadiness() { myIsShaderReady = Standard_False; }
void BuildSprites (const Handle(OpenGl_Workspace)& theWS, void BuildSprites (const Handle(OpenGl_Workspace)& theWS,
const Handle(Graphic3d_MarkerImage)& theMarkerImage, const Handle(Graphic3d_MarkerImage)& theMarkerImage,

View File

@ -88,7 +88,7 @@ void OpenGl_AspectText::SetAspect (const CALL_DEF_CONTEXTTEXT& theAspect)
if (aShaderKey.IsEmpty() || myResources.ShaderProgramId != aShaderKey) if (aShaderKey.IsEmpty() || myResources.ShaderProgramId != aShaderKey)
{ {
myResources.ResetShader(); myResources.ResetShaderReadiness();
} }
} }
@ -114,7 +114,7 @@ void OpenGl_AspectText::Release (const Handle(OpenGl_Context)& theContext)
myResources.ShaderProgram); myResources.ShaderProgram);
} }
myResources.ShaderProgramId.Clear(); myResources.ShaderProgramId.Clear();
myResources.ResetShader(); myResources.ResetShaderReadiness();
} }
// ======================================================================= // =======================================================================
@ -134,6 +134,8 @@ void OpenGl_AspectText::Resources::BuildShader (const Handle(OpenGl_Workspace)&
if (!ShaderProgram.IsNull()) if (!ShaderProgram.IsNull())
{ {
aContext->ShaderManager()->Unregister (ShaderProgramId, ShaderProgram); aContext->ShaderManager()->Unregister (ShaderProgramId, ShaderProgram);
ShaderProgramId.Clear();
ShaderProgram.Nullify();
} }
if (theShader.IsNull()) if (theShader.IsNull())
{ {

View File

@ -157,7 +157,7 @@ protected:
Standard_Boolean IsShaderReady() const { return myIsShaderReady; } Standard_Boolean IsShaderReady() const { return myIsShaderReady; }
void SetShaderReady() { myIsShaderReady = Standard_True; } void SetShaderReady() { myIsShaderReady = Standard_True; }
void ResetShader () { myIsShaderReady = Standard_False; } void ResetShaderReadiness() { myIsShaderReady = Standard_False; }
void BuildShader (const Handle(OpenGl_Workspace)& theWS, const Handle(Graphic3d_ShaderProgram)& theShader); void BuildShader (const Handle(OpenGl_Workspace)& theWS, const Handle(Graphic3d_ShaderProgram)& theShader);