0023428: Extend OpenGl_Context to use Geometry Shaders extension
[occt.git] / src / OpenGl / OpenGl_Resource.hxx
1 // Created on: 2011-03-18
2 // Created by: Anton POLETAEV
3 // Copyright (c) 2011-2012 OPEN CASCADE SAS
4 //
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.
9 //
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.
12 //
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.
19
20 #ifndef _OpenGl_Resource_H__
21 #define _OpenGl_Resource_H__
22
23 #include <Standard_Transient.hxx>
24 #include <Handle_Standard_Transient.hxx>
25
26 class Standard_Transient;
27 class Handle(Standard_Type);
28 class OpenGl_Context;
29
30 //! Interface for OpenGl resource with following meaning:
31 //!  - object can be constructed at any time;
32 //!  - should be explicitly Initialized within active OpenGL context;
33 //!  - should be explicitly Released    within active OpenGL context (virtual Release() method);
34 //!  - can be destroyed at any time.
35 //! Destruction of object with unreleased GPU resources will cause leaks
36 //! which will be ignored in release mode and will immediately stop program execution in debug mode using assert.
37 class OpenGl_Resource : public Standard_Transient
38 {
39
40 public:
41
42   //! Empty constructor
43   Standard_EXPORT OpenGl_Resource();
44
45   //! Destructor. Inheritors should call Clean (NULL) within it.
46   Standard_EXPORT virtual ~OpenGl_Resource();
47
48   //! Release GPU resources.
49   //! Notice that implementation should be SAFE for several consecutive calls
50   //! (thus should invalidate internal structures / ids to avoid multiple-free errors).
51   //! @param theGlCtx - bound GL context, shouldn't be NULL.
52   Standard_EXPORT virtual void Release (const OpenGl_Context* theGlCtx) = 0;
53
54 private:
55
56   //! Copy should be performed only within Handles!
57   OpenGl_Resource            (const OpenGl_Resource& );
58   OpenGl_Resource& operator= (const OpenGl_Resource& );
59
60 public:
61
62   DEFINE_STANDARD_RTTI(OpenGl_Resource) // Type definition
63
64 };
65
66 DEFINE_STANDARD_HANDLE(OpenGl_Resource, Standard_Transient)
67
68 #endif // _OpenGl_Resource_H__