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