Panda3D
materialPool.I
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file materialPool.I
10  * @author drose
11  * @date 2001-04-30
12  */
13 
14 /**
15  * Returns a Material pointer that represents the same material described by
16  * temp, except that it is a shared pointer.
17  *
18  * Each call to get_material() passing an equivalent Material pointer will
19  * return the same shared pointer.
20  *
21  * If you modify the shared pointer, it will automatically disassociate it
22  * from the pool.
23  *
24  * Also, the return value may be a different pointer than that passed in, or
25  * it may be the same pointer. In either case, the passed in pointer has now
26  * been sacrificed to the greater good and should not be used again (like any
27  * other PointerTo, it will be freed when the last reference count is
28  * removed).
29  */
32  return get_global_ptr()->ns_get_material(temp);
33 }
34 
35 /**
36  * Removes the indicated material from the pool.
37  */
38 INLINE void MaterialPool::
40  get_global_ptr()->ns_release_material(material);
41 }
42 
43 /**
44  * Releases all materials in the pool and restores the pool to the empty
45  * state.
46  */
47 INLINE void MaterialPool::
49  get_global_ptr()->ns_release_all_materials();
50 }
51 
52 /**
53  * Releases only those materials in the pool that have a reference count of
54  * exactly 1; i.e. only those materials that are not being used outside of
55  * the pool. Returns the number of materials released.
56  */
57 INLINE int MaterialPool::
59  return get_global_ptr()->ns_garbage_collect();
60 }
61 
62 /**
63  * Lists the contents of the material pool to the indicated output stream.
64  */
65 INLINE void MaterialPool::
66 list_contents(std::ostream &out) {
67  get_global_ptr()->ns_list_contents(out);
68 }
69 
70 /**
71  * The constructor is not intended to be called directly; there's only
72  * supposed to be one MaterialPool in the universe and it constructs itself.
73  */
74 INLINE MaterialPool::
75 MaterialPool() {
76 }
static Material * get_material(Material *temp)
Returns a Material pointer that represents the same material described by temp, except that it is a s...
Definition: materialPool.I:31
static void release_all_materials()
Releases all materials in the pool and restores the pool to the empty state.
Definition: materialPool.I:48
static int garbage_collect()
Releases only those materials in the pool that have a reference count of exactly 1; i....
Definition: materialPool.I:58
static void list_contents(std::ostream &out)
Lists the contents of the material pool to the indicated output stream.
Definition: materialPool.I:66
static void release_material(Material *temp)
Removes the indicated material from the pool.
Definition: materialPool.I:39
Defines the way an object appears in the presence of lighting.
Definition: material.h:43