HDK
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
RE_ContextSpecificTable.h
Go to the documentation of this file.
1
/*
2
* PROPRIETARY INFORMATION. This software is proprietary to
3
* Side Effects Software Inc., and is not to be reproduced,
4
* transmitted, or disclosed in any way without written permission.
5
*
6
* NAME: RE_ContextSpecificTable.h ( RE Library, C++)
7
*
8
* COMMENTS:
9
* Contains context-specific objects, creating them as needed for new
10
* GL contexts.
11
*/
12
#ifndef RE_ContextSpecificTable_h
13
#define RE_ContextSpecificTable_h
14
15
#include "
RE_API.h
"
16
#include "
RE_ContextSpecificObject.h
"
17
#include "
RE_Render.h
"
18
#include "
RE_Server.h
"
19
20
#include <
UT/UT_NonCopyable.h
>
21
#include <
UT/UT_ValArray.h
>
22
23
template
<
class
CObj>
24
class
RE_ContextSpecificTable
25
{
26
public
:
27
RE_ContextSpecificTable
() {}
28
~RE_ContextSpecificTable
()
29
{
30
for
(
int
i=0; i<myObjects.
entries
(); i++)
31
if
(myObjects(i))
32
{
33
// avoid an attempt to clear the GL object, since deleting
34
// the table implies we're exiting and contexts are not
35
// likely to be valid. Use clear() if you need to free
36
// the GL objects themselves.
37
if
(
RE_Server::isAppExiting
())
38
myObjects(i)->clearContext();
39
delete
myObjects(i);
40
}
41
}
42
UT_NON_COPYABLE
(
RE_ContextSpecificTable
)
43
44
CObj *
get
(
RE_Render
*
r
)
45
{
46
int
id
= r->getContextID();
47
RE_ContextSpecificObject
*obj = myObjects.
forcedRef
(
id
);
48
if
(!obj)
49
{
50
obj = myObjects(
id
) =
new
CObj;
51
obj->
init
(r);
52
}
53
54
return
static_cast<
CObj *
>
(obj);
55
}
56
CObj *
peek
(
RE_Render
*
r
)
57
{
58
int
id
= r->
getContextID
();
59
if
(
id
< myObjects.
entries
())
60
return
static_cast<CObj *>(myObjects(
id
));
61
return
nullptr
;
62
}
63
64
void
free
(
RE_Render
*
r
)
65
{
66
int
id
= r->
getContextID
();
67
68
if
(
id
>= myObjects.
entries
())
69
return
;
70
71
delete
myObjects(
id
);
72
myObjects(
id
) =
nullptr
;
73
}
74
75
void
clear
()
76
{
77
for
(
int
i=0; i<myObjects.
entries
(); i++)
78
{
79
delete
myObjects(i);
80
myObjects(i) =
nullptr
;
81
}
82
myObjects.
entries
(0);
83
}
84
85
/// Returns the amount of main memory (NOT graphics memory!)
86
/// owned by this RE_ContextSpecificTable.
87
int64
getMemoryUsage
(
bool
inclusive)
const
88
{
89
int64
mem = inclusive ?
sizeof
(*this) : 0;
90
mem += myObjects.
getMemoryUsage
(
false
);
91
return
mem;
92
}
93
94
private
:
95
UT_ValArray<RE_ContextSpecificObject *>
myObjects;
96
97
friend
class
RE_OGLRender
;
98
};
99
100
#endif
RE_ContextSpecificTable
Definition:
RE_ContextSpecificTable.h:24
RE_Server.h
RE_API.h
RE_ContextSpecificObject::init
virtual bool init(RE_Render *r)=0
UT_Array::getMemoryUsage
int64 getMemoryUsage(bool inclusive=false) const
Definition:
UT_Array.h:664
RE_ContextSpecificTable::get
CObj * get(RE_Render *r)
Definition:
RE_ContextSpecificTable.h:44
RE_OGLRender::getContextID
int getContextID() const
Definition:
RE_OGLRender.h:117
RE_ContextSpecificTable::getMemoryUsage
int64 getMemoryUsage(bool inclusive) const
Definition:
RE_ContextSpecificTable.h:87
RE_ContextSpecificTable::RE_ContextSpecificTable
RE_ContextSpecificTable()
Definition:
RE_ContextSpecificTable.h:27
UT_ValArray< RE_ContextSpecificObject * >
RE_ContextSpecificObject.h
RE_Server::isAppExiting
static bool isAppExiting()
UT_ValArray.h
RE_Render.h
RE_Render
Definition:
RE_Render.h:29
UT_NON_COPYABLE
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
Definition:
UT_NonCopyable.h:31
int64
long long int64
Definition:
SYS_Types.h:116
RE_ContextSpecificTable::peek
CObj * peek(RE_Render *r)
Definition:
RE_ContextSpecificTable.h:56
UT_NonCopyable.h
UT_Array::entries
exint entries() const
Alias of size(). size() is preferred.
Definition:
UT_Array.h:655
RE_ContextSpecificObject
Definition:
RE_ContextSpecificObject.h:28
RE_ContextSpecificTable::free
void free(RE_Render *r)
Definition:
RE_ContextSpecificTable.h:64
RE_ContextSpecificTable::clear
void clear()
Definition:
RE_ContextSpecificTable.h:75
r
GLboolean r
Definition:
glcorearb.h:1222
UT_Array::forcedRef
T & forcedRef(exint i)
Definition:
UT_Array.h:808
RE_ContextSpecificTable::~RE_ContextSpecificTable
~RE_ContextSpecificTable()
Definition:
RE_ContextSpecificTable.h:28
RE_OGLRender
Definition:
RE_OGLRender.h:111
RE
RE_ContextSpecificTable.h
Generated on Wed Aug 27 2025 03:08:14 for HDK by
1.8.6