Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

MaterialPool Class Reference

The MaterialPool (there is only one in the universe) serves to unify different pointers to the same Material, so we do not (a) waste memory with many different Material objects that are all equivalent, and (b) waste time switching the graphics engine between different Material states that are really the same thing. More...

#include <materialPool.h>

List of all members.

Static Public Member Functions

const Materialget_material (const ConstPointerTo< Material > &temp)
int garbage_collect ()
 Releases only those materials in the pool that have a reference count of exactly 1; i.e.

void list_contents (ostream &out)
 Lists the contents of the material pool to the indicated output stream.


Private Types

typedef pset< ConstPointerTo<
Material >, IndirectCompareTo<
Material > > 
Materials

Private Member Functions

 MaterialPool ()
 The constructor is not intended to be called directly; there's only supposed to be one MaterialPool in the universe and it constructs itself.

const Materialns_get_material (const ConstPointerTo< Material > &temp)
 The nonstatic implementation of get_material().

int ns_garbage_collect ()
 The nonstatic implementation of garbage_collect().

void ns_list_contents (ostream &out)
 The nonstatic implementation of list_contents().


Static Private Member Functions

MaterialPool * get_ptr ()
 Initializes and/or returns the global pointer to the one MaterialPool object in the system.


Private Attributes

Materials _materials

Static Private Attributes

MaterialPool * _global_ptr = (MaterialPool *)NULL


Detailed Description

The MaterialPool (there is only one in the universe) serves to unify different pointers to the same Material, so we do not (a) waste memory with many different Material objects that are all equivalent, and (b) waste time switching the graphics engine between different Material states that are really the same thing.

The idea is to create a temporary Material representing the lighting state you want to apply, then call get_material(), passing in your temporary Material. The return value will be a constant Material object that should be modified (because it is now shared among many different geometries), that is the same as the temporary Material pointer you supplied but may be a different pointer.

Definition at line 71 of file materialPool.h.


Member Typedef Documentation

typedef pset< ConstPointerTo< Material >, IndirectCompareTo<Material> > MaterialPool::Materials [private]
 

Definition at line 87 of file materialPool.h.


Constructor & Destructor Documentation

MaterialPool::MaterialPool  )  [inline, private]
 

The constructor is not intended to be called directly; there's only supposed to be one MaterialPool in the universe and it constructs itself.

Definition at line 119 of file materialPool.I.


Member Function Documentation

int MaterialPool::garbage_collect  )  [inline, static]
 

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.

Definition at line 87 of file materialPool.I.

const Material* MaterialPool::get_material const ConstPointerTo< Material > &  temp  )  [inline, static]
 

Referenced by NodePath::set_color_off().

MaterialPool * MaterialPool::get_ptr  )  [static, private]
 

Initializes and/or returns the global pointer to the one MaterialPool object in the system.

Definition at line 104 of file materialPool.cxx.

void MaterialPool::list_contents ostream &  out  )  [inline, static]
 

Lists the contents of the material pool to the indicated output stream.

Definition at line 102 of file materialPool.I.

int MaterialPool::ns_garbage_collect  )  [private]
 

The nonstatic implementation of garbage_collect().

Definition at line 52 of file materialPool.cxx.

const Material * MaterialPool::ns_get_material const ConstPointerTo< Material > &  temp  )  [private]
 

The nonstatic implementation of get_material().

Definition at line 38 of file materialPool.cxx.

References _materials, and ReferenceCount::get_ref_count().

void MaterialPool::ns_list_contents ostream &  out  )  [private]
 

The nonstatic implementation of list_contents().

Definition at line 83 of file materialPool.cxx.

References _global_ptr, and NULL.


Member Data Documentation

MaterialPool * MaterialPool::_global_ptr = (MaterialPool *)NULL [static, private]
 

Definition at line 26 of file materialPool.cxx.

Referenced by ns_list_contents().

Materials MaterialPool::_materials [private]
 

Definition at line 88 of file materialPool.h.

Referenced by ns_get_material().


The documentation for this class was generated from the following files:
Generated on Fri May 2 00:52:08 2003 for Panda by doxygen1.3