}
if (!aNewKey.IsEmpty()
- && theCtx->GetResource<Handle(OpenGl_PointSprite)> (aNewKey, mySprite)
- && theCtx->GetResource<Handle(OpenGl_PointSprite)> (aNewKeyA, mySpriteA))
+ && theCtx->GetResource<Handle(OpenGl_PointSprite)> (aNewKeyA, mySpriteA) // alpha sprite could be shared
+ && theCtx->GetResource<Handle(OpenGl_PointSprite)> (aNewKey, mySprite))
{
// reuse shared resource
if (!mySprite->IsDisplayList())
return;
}
+ const bool hadAlreadyAlpha = !mySpriteA.IsNull();
+ if (!hadAlreadyAlpha)
+ {
+ mySpriteA = new OpenGl_PointSprite();
+ }
mySprite = new OpenGl_PointSprite();
- mySpriteA = new OpenGl_PointSprite();
if (!aNewKey.IsEmpty())
{
theCtx->ShareResource (aNewKey, mySprite);
- theCtx->ShareResource (aNewKeyA, mySpriteA);
+ if (!hadAlreadyAlpha)
+ {
+ theCtx->ShareResource (aNewKeyA, mySpriteA);
+ }
}
if (!theCtx.IsNull()
myMarkerSize = Max ((Standard_ShortReal )anImage->Width(),(Standard_ShortReal )anImage->Height());
mySprite->Init (theCtx, *anImage.operator->(), Graphic3d_TOT_2D);
- if (anImageA.IsNull()
- && mySprite->GetFormat() != GL_ALPHA8
- && !aNewMarkerImage.IsNull())
- {
- anImageA = aNewMarkerImage->GetImageAlpha();
- }
- if (!anImageA.IsNull())
+ if (!hadAlreadyAlpha)
{
- mySpriteA->Init (theCtx, *anImageA.operator->(), Graphic3d_TOT_2D);
+ if (anImageA.IsNull()
+ && mySprite->GetFormat() != GL_ALPHA8
+ && !aNewMarkerImage.IsNull())
+ {
+ anImageA = aNewMarkerImage->GetImageAlpha();
+ }
+ if (!anImageA.IsNull())
+ {
+ mySpriteA->Init (theCtx, *anImageA.operator->(), Graphic3d_TOT_2D);
+ }
}
}
else
{
mySprite.Nullify(); // we need nullify all handles before ReleaseResource() call
mySpriteA.Nullify();
- theCtx->ReleaseResource (mySpriteKey);
- theCtx->ReleaseResource (mySpriteAKey);
+ theCtx->ReleaseResource (mySpriteKey, Standard_True);
+ theCtx->ReleaseResource (mySpriteAKey, Standard_True);
}
}
mySprite.Nullify();