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 <
UT/UT_ValArray.h
>
17
18
#include "
RE_ContextSpecificObject.h
"
19
#include "
RE_Render.h
"
20
#include "
RE_Server.h
"
21
22
template
<
class
CObj>
23
class
RE_ContextSpecificTable
24
{
25
public
:
26
RE_ContextSpecificTable
() {}
27
~RE_ContextSpecificTable
()
28
{
29
for
(
int
i=0; i<myObjects.
entries
(); i++)
30
if
(myObjects(i))
31
{
32
// avoid an attempt to clear the GL object, since deleting
33
// the table implies we're exiting and contexts are not
34
// likely to be valid. Use clear() if you need to free
35
// the GL objects themselves.
36
if
(
RE_Server::isAppExiting
())
37
myObjects(i)->clearContext();
38
delete
myObjects(i);
39
}
40
}
41
42
CObj *
get
(
RE_Render
*
r
)
43
{
44
int
id
=
r
->getContextID();
45
RE_ContextSpecificObject
*obj = myObjects.
forcedRef
(
id
);
46
if
(!obj)
47
{
48
obj = myObjects(
id
) =
new
CObj;
49
obj->
init
(
r
);
50
}
51
52
return
static_cast<
CObj *
>
(obj);
53
}
54
CObj *
peek
(
RE_Render
*
r
)
55
{
56
int
id
= r->
getContextID
();
57
if
(
id
< myObjects.
entries
())
58
return
static_cast<CObj *>(myObjects(
id
));
59
return
nullptr
;
60
}
61
62
void
free
(
RE_Render
*
r
)
63
{
64
int
id
= r->
getContextID
();
65
66
if
(
id
>= myObjects.
entries
())
67
return
;
68
69
delete
myObjects(
id
);
70
myObjects(
id
) =
nullptr
;
71
}
72
73
void
clear
()
74
{
75
for
(
int
i=0; i<myObjects.
entries
(); i++)
76
{
77
delete
myObjects(i);
78
myObjects(i) =
nullptr
;
79
}
80
myObjects.
entries
(0);
81
}
82
83
/// Returns the amount of main memory (NOT graphics memory!)
84
/// owned by this RE_ContextSpecificTable.
85
int64
getMemoryUsage
(
bool
inclusive)
const
86
{
87
int64
mem = inclusive ?
sizeof
(*this) : 0;
88
mem += myObjects.
getMemoryUsage
(
false
);
89
return
mem;
90
}
91
92
private
:
93
UT_ValArray<RE_ContextSpecificObject *>
myObjects;
94
95
friend
class
RE_OGLRender
;
96
};
97
98
#endif
RE_ContextSpecificTable
Definition:
RE_ContextSpecificTable.h:23
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:657
RE_OGLRender::getContextID
int getContextID() const
Definition:
RE_OGLRender.h:118
RE_ContextSpecificTable::getMemoryUsage
int64 getMemoryUsage(bool inclusive) const
Definition:
RE_ContextSpecificTable.h:85
RE_ContextSpecificTable::RE_ContextSpecificTable
RE_ContextSpecificTable()
Definition:
RE_ContextSpecificTable.h:26
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
int64
long long int64
Definition:
SYS_Types.h:116
RE_ContextSpecificTable::peek
CObj * peek(RE_Render *r)
Definition:
RE_ContextSpecificTable.h:54
UT_Array::entries
exint entries() const
Alias of size(). size() is preferred.
Definition:
UT_Array.h:648
RE_ContextSpecificObject
Definition:
RE_ContextSpecificObject.h:25
RE_ContextSpecificTable::free
void free(RE_Render *r)
Definition:
RE_ContextSpecificTable.h:62
RE_ContextSpecificTable::clear
void clear()
Definition:
RE_ContextSpecificTable.h:73
r
GLboolean r
Definition:
glcorearb.h:1222
UT_Array::forcedRef
T & forcedRef(exint i)
Definition:
UT_Array.h:801
RE_ContextSpecificTable::~RE_ContextSpecificTable
~RE_ContextSpecificTable()
Definition:
RE_ContextSpecificTable.h:27
RE_OGLRender
Definition:
RE_OGLRender.h:112
RE
RE_ContextSpecificTable.h
Generated on Thu Nov 21 2024 02:45:37 for HDK by
1.8.6