0023022: This is desirable to access OpenGl extensions and core API (1.2+) in one...
[occt.git] / src / OpenGl / OpenGl_Resource.hxx
1 // File:      OpenGl_Resource.hxx
2 // Created:   18.03.11 9:20:00
3 // Author:    Anton POLETAEV
4
5 #ifndef _OPENGL_RESOURCE_H
6 #define _OPENGL_RESOURCE_H
7
8 #include <OpenGl_GlCore11.hxx>
9
10 #include <OpenGl_ResourceCleaner.hxx>
11 #include <MMgt_TShared.hxx>
12 #include <Handle_MMgt_TShared.hxx>
13
14 class Standard_Transient;
15 class Handle(Standard_Type);
16 class Handle(MMgt_TShared);
17 class Handle(OpenGl_Context);
18 class OpenGl_ResourceCleaner;
19
20 //! Class represents basic OpenGl memory resource, which
21 //! could be removed only if appropriate context is avaliable;
22 //! The cleaning procedure is done by OpenGl_ResourceCleaner
23 class OpenGl_Resource : public MMgt_TShared
24 {
25
26 public:
27
28   //! Constructor
29   OpenGl_Resource() : myId(0) { }
30  
31   //! Constructor 
32   OpenGl_Resource(GLuint theId) : myId(theId) { }
33
34   //! Copy constructor
35   OpenGl_Resource(const OpenGl_Resource& theBase) : myId(theBase.myId) { }
36
37   //! Copy operation
38   OpenGl_Resource& operator= (const OpenGl_Resource& theBase)
39   {
40     this->myId = theBase.myId;
41     return *this; 
42   }
43
44   //! Destructor
45   virtual ~OpenGl_Resource() {}
46
47   //! method clean() is accessible only by OpenGl_ResourceCleaner
48   friend class OpenGl_ResourceCleaner;
49
50 protected:
51
52   //! Clean procedure, should be called only by OpenGl_ResourceCleaner;
53   //! Each type of resource has its own cleaning procedure
54   virtual void Clean (const Handle(OpenGl_Context)& theGlContext) = 0;
55
56 protected:
57
58   GLuint myId; // Id of OpenGl memory resource
59
60 };
61
62 DEFINE_STANDARD_HANDLE(OpenGl_Resource,MMgt_TShared)
63
64 #endif