forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaterialPool.I
More file actions
95 lines (88 loc) · 3.85 KB
/
materialPool.I
File metadata and controls
95 lines (88 loc) · 3.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// Filename: materialPool.I
// Created by: drose (30Apr01)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// Function: MaterialPool::get_material
// Access: Public, Static
// Description: Returns a Material pointer that represents the
// same material described by temp, except that it is a
// shared pointer.
//
// Each call to get_material() passing an equivalent
// Material pointer will return the same shared pointer.
//
// If you modify the shared pointer, it will
// automatically disassociate it from the pool.
//
// Also, the return value may be a different pointer
// than that passed in, or it may be the same pointer.
// In either case, the passed in pointer has now been
// sacrificed to the greater good and should not be used
// again (like any other PointerTo, it will be freed
// when the last reference count is removed).
////////////////////////////////////////////////////////////////////
INLINE Material *MaterialPool::
get_material(Material *temp) {
return get_global_ptr()->ns_get_material(temp);
}
////////////////////////////////////////////////////////////////////
// Function: MaterialPool::release_material
// Access: Published, Static
// Description: Removes the indicated material from the pool.
////////////////////////////////////////////////////////////////////
INLINE void MaterialPool::
release_material(Material *material) {
get_global_ptr()->ns_release_material(material);
}
////////////////////////////////////////////////////////////////////
// Function: MaterialPool::release_all_materials
// Access: Published, Static
// Description: Releases all materials in the pool and restores the
// pool to the empty state.
////////////////////////////////////////////////////////////////////
INLINE void MaterialPool::
release_all_materials() {
get_global_ptr()->ns_release_all_materials();
}
////////////////////////////////////////////////////////////////////
// Function: MaterialPool::garbage_collect
// Access: Public, Static
// Description: Releases only those materials in the pool that have a
// reference count of exactly 1; i.e. only those
// materials that are not being used outside of the pool.
// Returns the number of materials released.
////////////////////////////////////////////////////////////////////
INLINE int MaterialPool::
garbage_collect() {
return get_global_ptr()->ns_garbage_collect();
}
////////////////////////////////////////////////////////////////////
// Function: MaterialPool::list_contents
// Access: Public, Static
// Description: Lists the contents of the material pool to the
// indicated output stream.
////////////////////////////////////////////////////////////////////
INLINE void MaterialPool::
list_contents(ostream &out) {
get_global_ptr()->ns_list_contents(out);
}
////////////////////////////////////////////////////////////////////
// Function: MaterialPool::Constructor
// Access: Private
// Description: The constructor is not intended to be called
// directly; there's only supposed to be one MaterialPool
// in the universe and it constructs itself.
////////////////////////////////////////////////////////////////////
INLINE MaterialPool::
MaterialPool() {
}