0027105: Make code ISO-compliant [-Wpedantic fixes]
[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//
d5f74e42 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
973c2be1 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
4f953fa9 19#include <Standard_Type.hxx>
161c4476
K
20
21class Standard_Transient;
5e27df78 22class 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.
31class OpenGl_Resource : public Standard_Transient
161c4476
K
32{
33
34public:
35
5e27df78 36 //! Empty constructor
37 Standard_EXPORT OpenGl_Resource();
161c4476 38
5e27df78 39 //! Destructor. Inheritors should call Clean (NULL) within it.
40 Standard_EXPORT virtual ~OpenGl_Resource();
161c4476 41
5e27df78 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.
10b9c7df 46 Standard_EXPORT virtual void Release (OpenGl_Context* theGlCtx) = 0;
161c4476 47
5e27df78 48private:
161c4476 49
5e27df78 50 //! Copy should be performed only within Handles!
51 OpenGl_Resource (const OpenGl_Resource& );
52 OpenGl_Resource& operator= (const OpenGl_Resource& );
161c4476 53
3946774d 54public:
55
92efcf78 56 DEFINE_STANDARD_RTTIEXT(OpenGl_Resource,Standard_Transient) // Type definition
3946774d 57
161c4476
K
58};
59
5e27df78 60DEFINE_STANDARD_HANDLE(OpenGl_Resource, Standard_Transient)
161c4476 61
5e27df78 62#endif // _OpenGl_Resource_H__