Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 2011-08-05 |
2 | // Created by: Sergey ZERCHANINOV | |
973c2be1 | 3 | // Copyright (c) 2011-2014 OPEN CASCADE SAS |
b311480e | 4 | // |
973c2be1 | 5 | // This file is part of Open CASCADE Technology software library. |
b311480e | 6 | // |
d5f74e42 | 7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published | |
973c2be1 | 9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT | |
11 | // distribution for complete text of the license and disclaimer of any warranty. | |
b311480e | 12 | // |
973c2be1 | 13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. | |
b311480e | 15 | |
2166f0fa SK |
16 | #ifndef OpenGl_Element_Header |
17 | #define OpenGl_Element_Header | |
18 | ||
4269bd1b | 19 | #include <OpenGl_RenderFilter.hxx> |
1b661a81 | 20 | #include <Standard_Type.hxx> |
2166f0fa | 21 | |
c04c30b3 | 22 | class OpenGl_Workspace; |
23 | class OpenGl_Context; | |
24 | ||
a174a3c5 | 25 | //! Base interface for drawable elements. |
2166f0fa SK |
26 | class OpenGl_Element |
27 | { | |
5e27df78 | 28 | public: |
2166f0fa | 29 | |
a174a3c5 | 30 | Standard_EXPORT OpenGl_Element(); |
5e27df78 | 31 | |
32 | virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const = 0; | |
33 | ||
34 | //! Release GPU resources. | |
10b9c7df | 35 | //! Pointer to the context is used because this method might be called |
36 | //! when the context is already being destroyed and usage of a handle | |
37 | //! would be unsafe | |
38 | virtual void Release (OpenGl_Context* theContext) = 0; | |
39 | ||
40 | //! Pointer to the context is used because this method might be called | |
41 | //! when the context is already being destroyed and usage of a handle | |
42 | //! would be unsafe | |
5e27df78 | 43 | template <typename theResource_t> |
10b9c7df | 44 | static void Destroy (OpenGl_Context* theContext, |
45 | theResource_t*& theElement) | |
5e27df78 | 46 | { |
47 | if (theElement == NULL) | |
48 | { | |
49 | return; | |
50 | } | |
51 | ||
52 | theElement->Release (theContext); | |
53 | OpenGl_Element* anElement = theElement; | |
54 | delete anElement; | |
55 | theElement = NULL; | |
56 | } | |
57 | ||
64c6d8df | 58 | public: |
59 | ||
60 | //! Return TRUE if primitive type generates shaded triangulation (to be used in filters). | |
61 | virtual Standard_Boolean IsFillDrawMode() const { return false; } | |
62 | ||
eaac0866 | 63 | //! Update parameters of the drawable elements. |
64 | virtual void SynchronizeAspects() {} | |
65 | ||
5e27df78 | 66 | protected: |
67 | ||
a174a3c5 | 68 | Standard_EXPORT virtual ~OpenGl_Element(); |
5e27df78 | 69 | |
70 | public: | |
2166f0fa | 71 | |
1c35b92f | 72 | DEFINE_STANDARD_ALLOC |
5e27df78 | 73 | |
2166f0fa SK |
74 | }; |
75 | ||
a174a3c5 | 76 | #endif // OpenGl_Element_Header |