Commit | Line | Data |
---|---|---|
b311480e | 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 | ||
5e27df78 | 20 | #ifndef _OpenGl_Resource_H__ |
21 | #define _OpenGl_Resource_H__ | |
161c4476 | 22 | |
5e27df78 | 23 | #include <Standard_Transient.hxx> |
24 | #include <Handle_Standard_Transient.hxx> | |
161c4476 K |
25 | |
26 | class Standard_Transient; | |
27 | class Handle(Standard_Type); | |
5e27df78 | 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 | |
161c4476 K |
38 | { |
39 | ||
40 | public: | |
41 | ||
5e27df78 | 42 | //! Empty constructor |
43 | Standard_EXPORT OpenGl_Resource(); | |
161c4476 | 44 | |
5e27df78 | 45 | //! Destructor. Inheritors should call Clean (NULL) within it. |
46 | Standard_EXPORT virtual ~OpenGl_Resource(); | |
161c4476 | 47 | |
5e27df78 | 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; | |
161c4476 | 53 | |
5e27df78 | 54 | private: |
161c4476 | 55 | |
5e27df78 | 56 | //! Copy should be performed only within Handles! |
57 | OpenGl_Resource (const OpenGl_Resource& ); | |
58 | OpenGl_Resource& operator= (const OpenGl_Resource& ); | |
161c4476 | 59 | |
3946774d | 60 | public: |
61 | ||
62 | DEFINE_STANDARD_RTTI(OpenGl_Resource) // Type definition | |
63 | ||
161c4476 K |
64 | }; |
65 | ||
5e27df78 | 66 | DEFINE_STANDARD_HANDLE(OpenGl_Resource, Standard_Transient) |
161c4476 | 67 | |
5e27df78 | 68 | #endif // _OpenGl_Resource_H__ |