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