1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

0032117: Visualization, TKOpenGl - assert in OpenGl_AspectsSprite due to implicit destruction of existing resource

RGBA and Alpha markers are now handled independently within OpenGl_AspectsSprite::build().
This commit is contained in:
kgv 2021-02-05 20:38:15 +03:00 committed by bugmaster
parent 00a72254dc
commit 665dc9e50b

View File

@ -206,9 +206,16 @@ void OpenGl_AspectsSprite::build (const Handle(OpenGl_Context)& theCtx,
Handle(OpenGl_PointSprite)& aSprite = mySprite; Handle(OpenGl_PointSprite)& aSprite = mySprite;
Handle(OpenGl_PointSprite)& aSpriteA = mySpriteA; Handle(OpenGl_PointSprite)& aSpriteA = mySpriteA;
if (!aNewKey.IsEmpty() if (!aNewKey.IsEmpty())
&& theCtx->GetResource<Handle(OpenGl_PointSprite)> (aNewKeyA, aSpriteA) // alpha sprite could be shared {
&& theCtx->GetResource<Handle(OpenGl_PointSprite)> (aNewKey, aSprite)) theCtx->GetResource<Handle(OpenGl_PointSprite)> (aNewKeyA, aSpriteA); // alpha sprite could be shared
theCtx->GetResource<Handle(OpenGl_PointSprite)> (aNewKey, aSprite);
}
const bool hadAlreadyRGBA = !aSprite.IsNull();
const bool hadAlreadyAlpha = !aSpriteA.IsNull();
if (hadAlreadyRGBA
&& hadAlreadyAlpha)
{ {
// reuse shared resource // reuse shared resource
if (!aSprite->IsDisplayList()) if (!aSprite->IsDisplayList())
@ -218,15 +225,20 @@ void OpenGl_AspectsSprite::build (const Handle(OpenGl_Context)& theCtx,
return; return;
} }
const bool hadAlreadyAlpha = !aSpriteA.IsNull();
if (!hadAlreadyAlpha) if (!hadAlreadyAlpha)
{ {
aSpriteA = new OpenGl_PointSprite (aNewKeyA); aSpriteA = new OpenGl_PointSprite (aNewKeyA);
} }
aSprite = new OpenGl_PointSprite (aNewKey); if (!hadAlreadyRGBA)
{
aSprite = new OpenGl_PointSprite (aNewKey);
}
if (!aNewKey.IsEmpty()) if (!aNewKey.IsEmpty())
{ {
theCtx->ShareResource (aNewKey, aSprite); if (!hadAlreadyRGBA)
{
theCtx->ShareResource (aNewKey, aSprite);
}
if (!hadAlreadyAlpha) if (!hadAlreadyAlpha)
{ {
theCtx->ShareResource (aNewKeyA, aSpriteA); theCtx->ShareResource (aNewKeyA, aSpriteA);
@ -249,7 +261,10 @@ void OpenGl_AspectsSprite::build (const Handle(OpenGl_Context)& theCtx,
Handle(Image_PixMap) anImage = aNewMarkerImage->GetImage(); Handle(Image_PixMap) anImage = aNewMarkerImage->GetImage();
theMarkerSize = Max ((Standard_ShortReal )anImage->Width(),(Standard_ShortReal )anImage->Height()); theMarkerSize = Max ((Standard_ShortReal )anImage->Width(),(Standard_ShortReal )anImage->Height());
aSprite->Init (theCtx, *anImage, Graphic3d_TOT_2D, true); if (!hadAlreadyRGBA)
{
aSprite->Init (theCtx, *anImage, Graphic3d_TOT_2D, true);
}
if (!hadAlreadyAlpha) if (!hadAlreadyAlpha)
{ {
if (Handle(Image_PixMap) anImageA = aSprite->GetFormat() != GL_ALPHA ? aNewMarkerImage->GetImageAlpha() : Handle(Image_PixMap)()) if (Handle(Image_PixMap) anImageA = aSprite->GetFormat() != GL_ALPHA ? aNewMarkerImage->GetImageAlpha() : Handle(Image_PixMap)())