void Render (const Handle(OpenGl_Workspace) &theWorkspace) const;
- virtual void Release (const Handle(OpenGl_Context)& theContext)
+ virtual void Release (OpenGl_Context* theContext)
{
//
}
// function : Release
// purpose :
// =======================================================================
-void OpenGl_AspectFace::Release (const Handle(OpenGl_Context)& theContext)
+void OpenGl_AspectFace::Release (OpenGl_Context* theContext)
{
if (!myResources.Texture.IsNull())
{
- if (!theContext.IsNull())
+ if (theContext)
{
if (myResources.TextureId.IsEmpty())
{
myResources.ResetTextureReadiness();
if (!myResources.ShaderProgram.IsNull()
- && !theContext.IsNull())
+ && theContext)
{
theContext->ShaderManager()->Unregister (myResources.ShaderProgramId,
myResources.ShaderProgram);
}
Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
- Standard_EXPORT virtual void Release (const Handle(OpenGl_Context)& theContext);
+ Standard_EXPORT virtual void Release (OpenGl_Context* theContext);
protected:
// function : Release
// purpose :
// =======================================================================
-void OpenGl_AspectLine::Release (const Handle(OpenGl_Context)& theContext)
+void OpenGl_AspectLine::Release (OpenGl_Context* theContext)
{
if (!myResources.ShaderProgram.IsNull()
- && !theContext.IsNull())
+ && theContext)
{
theContext->ShaderManager()->Unregister (myResources.ShaderProgramId,
myResources.ShaderProgram);
}
Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
- Standard_EXPORT virtual void Release (const Handle(OpenGl_Context)& theContext);
+ Standard_EXPORT virtual void Release (OpenGl_Context* theContext);
protected:
// function : Release
// purpose :
// =======================================================================
-void OpenGl_AspectMarker::Release (const Handle(OpenGl_Context)& theCtx)
+void OpenGl_AspectMarker::Release (OpenGl_Context* theCtx)
{
if (!myResources.Sprite.IsNull())
{
- if (!theCtx.IsNull())
+ if (theCtx)
{
if (myResources.SpriteKey.IsEmpty())
{
myResources.SpriteAKey.Clear();
myResources.ResetSpriteReadiness();
- if (!myResources.ShaderProgram.IsNull() && !theCtx.IsNull())
+ if (!myResources.ShaderProgram.IsNull() && theCtx)
{
theCtx->ShaderManager()->Unregister (myResources.ShaderProgramId,
myResources.ShaderProgram);
}
Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
- Standard_EXPORT virtual void Release (const Handle(OpenGl_Context)& theContext);
+ Standard_EXPORT virtual void Release (OpenGl_Context* theContext);
protected: //! @name ordinary aspect properties
// function : Release
// purpose :
// =======================================================================
-void OpenGl_AspectText::Release (const Handle(OpenGl_Context)& theContext)
+void OpenGl_AspectText::Release (OpenGl_Context* theContext)
{
if (!myResources.ShaderProgram.IsNull()
- && !theContext.IsNull())
+ && theContext)
{
theContext->ShaderManager()->Unregister (myResources.ShaderProgramId,
myResources.ShaderProgram);
}
Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
- Standard_EXPORT virtual void Release (const Handle(OpenGl_Context)& theContext);
+ Standard_EXPORT virtual void Release (OpenGl_Context* theContext);
protected:
// function : Release
// purpose :
// =======================================================================
-void OpenGl_CappingPlaneResource::Release (const OpenGl_Context* theContext)
+void OpenGl_CappingPlaneResource::Release (OpenGl_Context* theContext)
{
OpenGl_Element::Destroy (theContext, myAspect);
myEquationMod = (unsigned int )-1;
// no more used
if (myAspect != NULL && aCappingAsp.IsNull())
{
- OpenGl_Element::Destroy (theContext, myAspect);
+ OpenGl_Element::Destroy (theContext.operator->(), myAspect);
myAspectMod = myPlaneRoot->MCountAspect();
return;
}
//! Release associated OpenGl resources.
//! @param theContext [in] the resource context.
- Standard_EXPORT void Release (const OpenGl_Context* theContext);
+ Standard_EXPORT void Release (OpenGl_Context* theContext);
//! @return aspect face for rendering capping surface.
inline const OpenGl_AspectFace* AspectFace() const { return myAspect; }
virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const = 0;
//! Release GPU resources.
- virtual void Release (const Handle(OpenGl_Context)& theContext) = 0;
-
+ //! Pointer to the context is used because this method might be called
+ //! when the context is already being destroyed and usage of a handle
+ //! would be unsafe
+ virtual void Release (OpenGl_Context* theContext) = 0;
+
+ //! Pointer to the context is used because this method might be called
+ //! when the context is already being destroyed and usage of a handle
+ //! would be unsafe
template <typename theResource_t>
- static void Destroy (const Handle(OpenGl_Context)& theContext,
- theResource_t*& theElement)
+ static void Destroy (OpenGl_Context* theContext,
+ theResource_t*& theElement)
{
if (theElement == NULL)
{
// function : Release
// purpose :
// =======================================================================
-void OpenGl_Flipper::Release (const Handle(OpenGl_Context)& )
+void OpenGl_Flipper::Release (OpenGl_Context*)
{
//
}
void SetOptions (const Standard_Boolean theIsEnabled) { myIsEnabled = theIsEnabled; }
Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
- Standard_EXPORT virtual void Release (const Handle(OpenGl_Context)& theCtx);
+ Standard_EXPORT virtual void Release (OpenGl_Context* theCtx);
public:
// function : Release
// purpose :
// =======================================================================
-void OpenGl_Font::Release (const OpenGl_Context* theCtx)
+void OpenGl_Font::Release (OpenGl_Context* theCtx)
{
if (myTextures.IsEmpty())
{
Standard_EXPORT virtual ~OpenGl_Font();
//! Destroy object - will release GPU memory if any
- Standard_EXPORT virtual void Release (const OpenGl_Context* theCtx);
+ Standard_EXPORT virtual void Release (OpenGl_Context* theCtx);
//! @return key of shared resource
inline const TCollection_AsciiString& ResourceKey() const
// function : Release
// purpose :
// =======================================================================
-void OpenGl_FrameBuffer::Release (const OpenGl_Context* theGlCtx)
+void OpenGl_FrameBuffer::Release (OpenGl_Context* theGlCtx)
{
if (isValidFrameBuffer())
{
Standard_EXPORT virtual ~OpenGl_FrameBuffer();
//! Destroy object - will release GPU memory if any.
- Standard_EXPORT virtual void Release (const OpenGl_Context* theGlCtx);
+ Standard_EXPORT virtual void Release (OpenGl_Context* theGlCtx);
//! Textures width.
GLsizei GetSizeX() const
// function : Release
// purpose :
// =======================================================================
-void OpenGl_GraduatedTrihedron::Release (const Handle(OpenGl_Context)& theCtx)
+void OpenGl_GraduatedTrihedron::Release (OpenGl_Context* theCtx)
{
myLabelX.Release (theCtx);
myLabelY.Release (theCtx);
OpenGl_GraduatedTrihedron (const Graphic3d_CGraduatedTrihedron& theData);
virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
- virtual void Release (const Handle(OpenGl_Context)& theCtx);
+ virtual void Release (OpenGl_Context* theCtx);
protected:
OpenGl_Structure* aStruct = aStructIt.ChangeValue();
aStruct->ReleaseGlResources (aCtx);
}
- myTempText->Release (aCtx);
+ myTempText->Release (aCtx.operator->());
myDeviceLostFlag = !myMapOfStructure.IsEmpty();
}
while (myFirst != NULL)
{
OpenGl_ElementNode* aNext = myFirst->next;
- OpenGl_Element::Destroy (theGlCtx, myFirst->elem);
+ OpenGl_Element::Destroy (theGlCtx.operator->(), myFirst->elem);
delete myFirst;
myFirst = aNext;
}
myLast = NULL;
- OpenGl_Element::Destroy (theGlCtx, myAspectLine);
- OpenGl_Element::Destroy (theGlCtx, myAspectFace);
- OpenGl_Element::Destroy (theGlCtx, myAspectMarker);
- OpenGl_Element::Destroy (theGlCtx, myAspectText);
+ OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectLine);
+ OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectFace);
+ OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectMarker);
+ OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectText);
}
// function : Release
// purpose :
// =======================================================================
-void OpenGl_LineAttributes::Release (const OpenGl_Context* theGlCtx)
+void OpenGl_LineAttributes::Release (OpenGl_Context* theGlCtx)
{
// Delete line styles
if (myLinestyleBase != 0)
virtual ~OpenGl_LineAttributes();
void Init (const Handle(OpenGl_Context)& theGlCtx);
- virtual void Release (const OpenGl_Context* theGlCtx);
+ virtual void Release (OpenGl_Context* theGlCtx);
void SetTypeOfLine (const Aspect_TypeOfLine theType) const;
// function : Release
// purpose :
// =======================================================================
-void OpenGl_PointSprite::Release (const OpenGl_Context* theGlCtx)
+void OpenGl_PointSprite::Release (OpenGl_Context* theGlCtx)
{
if (myBitmapList != 0)
{
Standard_EXPORT virtual ~OpenGl_PointSprite();
//! Destroy object - will release GPU memory if any.
- Standard_EXPORT virtual void Release (const OpenGl_Context* theCtx);
+ Standard_EXPORT virtual void Release (OpenGl_Context* theCtx);
//! @return true if this is display list bitmap
inline Standard_Boolean IsDisplayList() const
// function : Release
// purpose :
// =======================================================================
-void OpenGl_PrimitiveArray::Release (const Handle(OpenGl_Context)& theContext)
+void OpenGl_PrimitiveArray::Release (OpenGl_Context* theContext)
{
if (!myVboIndices.IsNull())
{
- if (!theContext.IsNull())
+ if (theContext)
{
theContext->DelayedRelease (myVboIndices);
}
}
if (!myVboAttribs.IsNull())
{
- if (!theContext.IsNull())
+ if (theContext)
{
theContext->DelayedRelease (myVboAttribs);
}
//! Render primitives to the window
virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
- virtual void Release (const Handle(OpenGl_Context)& theContext);
+ virtual void Release (OpenGl_Context* theContext);
//! @return primitive type (GL_LINES, GL_TRIANGLES and others)
GLint DrawMode() const { return myDrawMode; }
//! Notice that implementation should be SAFE for several consecutive calls
//! (thus should invalidate internal structures / ids to avoid multiple-free errors).
//! @param theGlCtx - bound GL context, shouldn't be NULL.
- Standard_EXPORT virtual void Release (const OpenGl_Context* theGlCtx) = 0;
+ Standard_EXPORT virtual void Release (OpenGl_Context* theGlCtx) = 0;
private:
// function : Release
// purpose : Destroys shader object
// =======================================================================
-void OpenGl_ShaderObject::Release (const OpenGl_Context* theCtx)
+void OpenGl_ShaderObject::Release (OpenGl_Context* theCtx)
{
if (myShaderID == NO_SHADER)
{
Standard_EXPORT Standard_Boolean Create (const Handle(OpenGl_Context)& theCtx);
//! Destroys shader object.
- Standard_EXPORT virtual void Release (const OpenGl_Context* theCtx);
+ Standard_EXPORT virtual void Release (OpenGl_Context* theCtx);
//! Returns type of shader object.
GLenum Type() const { return myType; }
// function : Release
// purpose : Destroys shader program
// =======================================================================
-void OpenGl_ShaderProgram::Release (const OpenGl_Context* theCtx)
+void OpenGl_ShaderProgram::Release (OpenGl_Context* theCtx)
{
if (myProgramID == NO_PROGRAM)
{
Standard_EXPORT Standard_Boolean Create (const Handle(OpenGl_Context)& theCtx);
//! Destroys shader program.
- Standard_EXPORT virtual void Release (const OpenGl_Context* theCtx);
+ Standard_EXPORT virtual void Release (OpenGl_Context* theCtx);
//! Attaches shader object to the program object.
Standard_EXPORT Standard_Boolean AttachShader (const Handle(OpenGl_Context)& theCtx,
// function : Release
// purpose :
// =======================================================================
-void OpenGl_StencilTest::Release (const Handle(OpenGl_Context)&)
+void OpenGl_StencilTest::Release (OpenGl_Context*)
{
//
}
//! Render primitives to the window
virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
- virtual void Release (const Handle(OpenGl_Context)& theContext);
+ virtual void Release (OpenGl_Context* theContext);
void SetOptions (const Standard_Boolean theIsEnabled);
}
//! Release graphical resources
- virtual void Release (const Handle(OpenGl_Context)& )
+ virtual void Release (OpenGl_Context*)
{
//
}
{
// Release groups
Clear (theGlCtx);
- OpenGl_Element::Destroy (theGlCtx, myAspectLine);
- OpenGl_Element::Destroy (theGlCtx, myAspectFace);
- OpenGl_Element::Destroy (theGlCtx, myAspectMarker);
- OpenGl_Element::Destroy (theGlCtx, myAspectText);
+ OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectLine);
+ OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectFace);
+ OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectMarker);
+ OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectText);
clearHighlightColor (theGlCtx);
// Remove from connected list of ancestor
}
if (myAspectLine != NULL)
{
- myAspectLine->Release (theGlCtx);
+ myAspectLine->Release (theGlCtx.operator->());
}
if (myAspectFace != NULL)
{
- myAspectFace->Release (theGlCtx);
+ myAspectFace->Release (theGlCtx.operator->());
}
if (myAspectMarker != NULL)
{
- myAspectMarker->Release (theGlCtx);
+ myAspectMarker->Release (theGlCtx.operator->());
}
if (myAspectText != NULL)
{
- myAspectText->Release (theGlCtx);
+ myAspectText->Release (theGlCtx.operator->());
}
if (!myHighlightBox.IsNull())
{
- myHighlightBox->Release (theGlCtx);
+ myHighlightBox->Release (theGlCtx.operator->());
}
}
{
if (myParams.Height != theFontSize)
{
- Release (theCtx);
+ Release (theCtx.operator->());
}
myParams.Height = theFontSize;
}
const Standard_Utf8Char* theText,
const OpenGl_Vec3& thePoint)
{
- releaseVbos (theCtx);
+ releaseVbos (theCtx.operator->());
myIs2d = false;
myPoint = thePoint;
myString.FromUnicode (theText);
{
if (myParams.Height != theParams.Height)
{
- Release (theCtx);
+ Release (theCtx.operator->());
}
else
{
- releaseVbos (theCtx);
+ releaseVbos (theCtx.operator->());
}
myIs2d = false;
myParams = theParams;
{
if (myParams.Height != theParams.Height)
{
- Release (theCtx);
+ Release (theCtx.operator->());
}
else
{
- releaseVbos (theCtx);
+ releaseVbos (theCtx.operator->());
}
myIs2d = true;
myParams = theParams;
// function : releaseVbos
// purpose :
// =======================================================================
-void OpenGl_Text::releaseVbos (const Handle(OpenGl_Context)& theCtx)
+void OpenGl_Text::releaseVbos (OpenGl_Context* theCtx)
{
for (Standard_Integer anIter = 0; anIter < myVertsVbo.Length(); ++anIter)
{
Handle(OpenGl_VertexBuffer)& aVerts = myVertsVbo.ChangeValue (anIter);
Handle(OpenGl_VertexBuffer)& aTCrds = myTCrdsVbo.ChangeValue (anIter);
- if (!theCtx.IsNull())
+ if (theCtx)
{
theCtx->DelayedRelease (aVerts);
theCtx->DelayedRelease (aTCrds);
// function : Release
// purpose :
// =======================================================================
-void OpenGl_Text::Release (const Handle(OpenGl_Context)& theCtx)
+void OpenGl_Text::Release (OpenGl_Context* theCtx)
{
releaseVbos (theCtx);
if (!myFont.IsNull())
Handle(OpenGl_Context) aCtx = theCtx;
const TCollection_AsciiString aKey = myFont->ResourceKey();
myFont.Nullify();
- aCtx->ReleaseResource (aKey, Standard_True);
+ if (aCtx)
+ aCtx->ReleaseResource (aKey, Standard_True);
}
}
&& !myFont->ResourceKey().IsEqual (aFontKey))
{
// font changed
- const_cast<OpenGl_Text* > (this)->Release (theCtx);
+ const_cast<OpenGl_Text* > (this)->Release (theCtx.operator->());
}
if (myFont.IsNull())
const Standard_Integer theFontSize);
Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
- Standard_EXPORT virtual void Release (const Handle(OpenGl_Context)& theContext);
+ Standard_EXPORT virtual void Release (OpenGl_Context* theContext);
public: //! @name methods for compatibility with layers
private:
//! Release cached VBO resources
- void releaseVbos (const Handle(OpenGl_Context)& theCtx);
+ void releaseVbos (OpenGl_Context* theCtx);
//! Setup matrix.
void setupMatrix (const Handle(OpenGl_PrinterContext)& thePrintCtx,
// function : Release
// purpose :
// =======================================================================
-void OpenGl_Texture::Release (const OpenGl_Context* theGlCtx)
+void OpenGl_Texture::Release (OpenGl_Context* theGlCtx)
{
if (myTextureId == NO_TEXTURE)
{
Standard_EXPORT bool Create (const Handle(OpenGl_Context)& theCtx);
//! Destroy object - will release GPU memory if any.
- Standard_EXPORT virtual void Release (const OpenGl_Context* theCtx);
+ Standard_EXPORT virtual void Release (OpenGl_Context* theCtx);
//! Bind this Texture to specified unit.
Standard_EXPORT void Bind (const Handle(OpenGl_Context)& theCtx,
// function : Release
// purpose :
// =======================================================================
-void OpenGl_TextureBufferArb::Release (const OpenGl_Context* theGlCtx)
+void OpenGl_TextureBufferArb::Release (OpenGl_Context* theGlCtx)
{
if (myTextureId != NO_TEXTURE)
{
}
//! Destroy object - will release GPU memory if any.
- Standard_EXPORT virtual void Release (const OpenGl_Context* theGlCtx);
+ Standard_EXPORT virtual void Release (OpenGl_Context* theGlCtx);
//! Creates VBO and Texture names (ids) if not yet generated.
//! Data should be initialized by another method.
// function : Release
// purpose :
// =======================================================================
-void OpenGl_Trihedron::Release (const Handle(OpenGl_Context)& theCtx)
+void OpenGl_Trihedron::Release (OpenGl_Context* theCtx)
{
myLabelX.Release (theCtx);
myLabelY.Release (theCtx);
const Standard_Boolean theAsWireframe);
virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
- virtual void Release (const Handle(OpenGl_Context)& theCtx);
+ virtual void Release (OpenGl_Context* theCtx);
protected:
// function : Release
// purpose :
// =======================================================================
-void OpenGl_VertexBuffer::Release (const OpenGl_Context* theGlCtx)
+void OpenGl_VertexBuffer::Release (OpenGl_Context* theGlCtx)
{
if (myBufferId == NO_BUFFER)
{
Standard_EXPORT bool Create (const Handle(OpenGl_Context)& theGlCtx);
//! Destroy object - will release GPU memory if any.
- Standard_EXPORT virtual void Release (const OpenGl_Context* theGlCtx);
+ Standard_EXPORT virtual void Release (OpenGl_Context* theGlCtx);
//! Bind this VBO.
Standard_EXPORT void Bind (const Handle(OpenGl_Context)& theGlCtx) const;
void OpenGl_View::ReleaseGlResources (const Handle(OpenGl_Context)& theCtx)
{
- OpenGl_Element::Destroy (theCtx, myTrihedron);
- OpenGl_Element::Destroy (theCtx, myGraduatedTrihedron);
+ OpenGl_Element::Destroy (theCtx.operator->(), myTrihedron);
+ OpenGl_Element::Destroy (theCtx.operator->(), myGraduatedTrihedron);
if (!myTextureEnv.IsNull())
{
const Standard_Real theScale,
const Standard_Boolean theAsWireframe)
{
- OpenGl_Element::Destroy (theCtx, myTrihedron);
+ OpenGl_Element::Destroy (theCtx.operator->(), myTrihedron);
myTrihedron = new OpenGl_Trihedron (thePosition, theColor, theScale, theAsWireframe);
}
void OpenGl_View::TriedronErase (const Handle(OpenGl_Context)& theCtx)
{
- OpenGl_Element::Destroy (theCtx, myTrihedron);
+ OpenGl_Element::Destroy (theCtx.operator->(), myTrihedron);
}
/*----------------------------------------------------------------------*/
void OpenGl_View::GraduatedTrihedronDisplay (const Handle(OpenGl_Context)& theCtx,
const Graphic3d_CGraduatedTrihedron& theData)
{
- OpenGl_Element::Destroy (theCtx, myGraduatedTrihedron);
+ OpenGl_Element::Destroy (theCtx.operator->(), myGraduatedTrihedron);
myGraduatedTrihedron = new OpenGl_GraduatedTrihedron (theData);
}
void OpenGl_View::GraduatedTrihedronErase (const Handle(OpenGl_Context)& theCtx)
{
- OpenGl_Element::Destroy (theCtx, myGraduatedTrihedron);
+ OpenGl_Element::Destroy (theCtx.operator->(), myGraduatedTrihedron);
}
/*----------------------------------------------------------------------*/
myIObj->Render(theWorkspace);
}
- virtual void Release (const Handle(OpenGl_Context)&)
+ virtual void Release (OpenGl_Context*)
{
//
}