1 // Created on: 2011-08-05
2 // Created by: Sergey ZERCHANINOV
3 // Copyright (c) 2011-2012 OPEN CASCADE SAS
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
20 #ifndef OpenGl_Element_Header
21 #define OpenGl_Element_Header
23 #include <Handle_OpenGl_Context.hxx>
24 #include <Handle_OpenGl_Workspace.hxx>
25 #include <OpenGl_RenderFilter.hxx>
27 //! Base interface for drawable elements.
32 Standard_EXPORT OpenGl_Element();
34 virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const = 0;
36 //! Release GPU resources.
37 virtual void Release (const Handle(OpenGl_Context)& theContext) = 0;
39 template <typename theResource_t>
40 static void Destroy (const Handle(OpenGl_Context)& theContext,
41 theResource_t*& theElement)
43 if (theElement == NULL)
48 theElement->Release (theContext);
49 OpenGl_Element* anElement = theElement;
56 //! Render element if it passes the filtering procedure. This method should
57 //! be used for elements which can be used in scope of rendering algorithms.
58 //! E.g. elements of groups during recursive rendering.
59 //! If render filter is null, pure rendering is performed.
60 //! @param theWorkspace [in] the rendering workspace.
61 //! @param theFilter [in] the rendering filter to check whether the element
62 //! should be rendered or not.
63 //! @return True if element passes the filering check and is rendered.
64 inline Standard_Boolean
65 RenderFiltered (const Handle(OpenGl_Workspace)& theWorkspace,
66 const Handle(OpenGl_RenderFilter)& theFilter) const
68 if (!theFilter.IsNull() && !theFilter->CanRender (this))
70 return Standard_False;
73 Render (theWorkspace);
80 Standard_EXPORT virtual ~OpenGl_Element();
88 #endif // OpenGl_Element_Header