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