summaryrefslogtreecommitdiff
path: root/inc/OpenGl_Resource.hxx
blob: 9bb9a44b59ee2ceb881a36e5fe768b6d5d755b79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// File:      OpenGl_Resource.hxx
// Created:   18.03.11 9:20:00
// Author:    Anton POLETAEV

#ifndef _OPENGL_RESOURCE_H
#define _OPENGL_RESOURCE_H

#include <OpenGl_ResourceCleaner.hxx>
#include <MMgt_TShared.hxx>
#include <Standard.hxx>
#include <Standard_DefineHandle.hxx>
#include <Handle_MMgt_TShared.hxx>

class Standard_Transient;
class Handle(Standard_Type);
class Handle(MMgt_TShared);
class OpenGl_ResourceCleaner;

//! Class represents basic OpenGl memory resource, which
//! could be removed only if appropriate context is avaliable;
//! The cleaning procedure is done by OpenGl_ResourceCleaner
class OpenGl_Resource : public MMgt_TShared
{

public:

  //! Constructor
  OpenGl_Resource() : myId(0) { }
 
  //! Constructor 
  OpenGl_Resource(GLuint theId) : myId(theId) { }

  //! Copy constructor
  OpenGl_Resource(const OpenGl_Resource& theBase) : myId(theBase.myId) { }

  //! Copy operation
  OpenGl_Resource& operator = (const OpenGl_Resource& theBase)
  {
    this->myId = theBase.myId;
    return *this; 
  }

  //! Destructor
  virtual ~OpenGl_Resource() { }

  //! method clean() is accessible only by OpenGl_ResourceCleaner
  friend class OpenGl_ResourceCleaner;

protected:

  //! Clean procedure, should be called only by OpenGl_ResourceCleaner;
  //! Each type of resource has its own cleaning procedure
  virtual void Clean() = 0;

protected:

  GLuint myId; // Id of OpenGl memory resource

};

DEFINE_STANDARD_HANDLE(OpenGl_Resource,MMgt_TShared)

#endif