00001 // Filename: materialPool.I 00002 // Created by: drose (30Apr01) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: MaterialPool::get_material 00018 // Access: Public, Static 00019 // Description: Returns a Material pointer that represents the 00020 // same material described by temp, except that it is a 00021 // shared pointer. 00022 // 00023 // Each call to get_material() passing an equivalent 00024 // Material pointer will return the same shared pointer. 00025 // 00026 // If you modify the shared pointer, it will 00027 // automatically disassociate it from the pool. 00028 // 00029 // Also, the return value may be a different pointer 00030 // than that passed in, or it may be the same pointer. 00031 // In either case, the passed in pointer has now been 00032 // sacrificed to the greater good and should not be used 00033 // again (like any other PointerTo, it will be freed 00034 // when the last reference count is removed). 00035 //////////////////////////////////////////////////////////////////// 00036 INLINE Material *MaterialPool:: 00037 get_material(Material *temp) { 00038 return get_global_ptr()->ns_get_material(temp); 00039 } 00040 00041 //////////////////////////////////////////////////////////////////// 00042 // Function: MaterialPool::release_material 00043 // Access: Published, Static 00044 // Description: Removes the indicated material from the pool. 00045 //////////////////////////////////////////////////////////////////// 00046 INLINE void MaterialPool:: 00047 release_material(Material *material) { 00048 get_global_ptr()->ns_release_material(material); 00049 } 00050 00051 //////////////////////////////////////////////////////////////////// 00052 // Function: MaterialPool::release_all_materials 00053 // Access: Published, Static 00054 // Description: Releases all materials in the pool and restores the 00055 // pool to the empty state. 00056 //////////////////////////////////////////////////////////////////// 00057 INLINE void MaterialPool:: 00058 release_all_materials() { 00059 get_global_ptr()->ns_release_all_materials(); 00060 } 00061 00062 //////////////////////////////////////////////////////////////////// 00063 // Function: MaterialPool::garbage_collect 00064 // Access: Public, Static 00065 // Description: Releases only those materials in the pool that have a 00066 // reference count of exactly 1; i.e. only those 00067 // materials that are not being used outside of the pool. 00068 // Returns the number of materials released. 00069 //////////////////////////////////////////////////////////////////// 00070 INLINE int MaterialPool:: 00071 garbage_collect() { 00072 return get_global_ptr()->ns_garbage_collect(); 00073 } 00074 00075 //////////////////////////////////////////////////////////////////// 00076 // Function: MaterialPool::list_contents 00077 // Access: Public, Static 00078 // Description: Lists the contents of the material pool to the 00079 // indicated output stream. 00080 //////////////////////////////////////////////////////////////////// 00081 INLINE void MaterialPool:: 00082 list_contents(ostream &out) { 00083 get_global_ptr()->ns_list_contents(out); 00084 } 00085 00086 //////////////////////////////////////////////////////////////////// 00087 // Function: MaterialPool::Constructor 00088 // Access: Private 00089 // Description: The constructor is not intended to be called 00090 // directly; there's only supposed to be one MaterialPool 00091 // in the universe and it constructs itself. 00092 //////////////////////////////////////////////////////////////////// 00093 INLINE MaterialPool:: 00094 MaterialPool() { 00095 }