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

panda/src/gobj/texturePool.I

Go to the documentation of this file.
00001 // Filename: texturePool.I
00002 // Created by:  drose (26Apr00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 ////////////////////////////////////////////////////////////////////
00020 //     Function: TexturePool::has_texture
00021 //       Access: Public, Static
00022 //  Description: Returns true if the texture has ever been loaded,
00023 //               false otherwise.
00024 ////////////////////////////////////////////////////////////////////
00025 INLINE bool TexturePool::
00026 has_texture(const string &filename) {
00027   return get_ptr()->ns_has_texture(filename);
00028 }
00029 
00030 ////////////////////////////////////////////////////////////////////
00031 //     Function: TexturePool::verify_texture
00032 //       Access: Public, Static
00033 //  Description: Loads the given filename up into a texture, if it has
00034 //               not already been loaded, and returns true to indicate
00035 //               success, or false to indicate failure.  If this
00036 //               returns true, it is guaranteed that a subsequent call
00037 //               to load_texture() with the same texture name will
00038 //               return a valid Texture pointer.
00039 ////////////////////////////////////////////////////////////////////
00040 INLINE bool TexturePool::
00041 verify_texture(const string &filename) {
00042   return load_texture(filename) != (Texture *)NULL;
00043 }
00044 
00045 ////////////////////////////////////////////////////////////////////
00046 //     Function: TexturePool::load_texture
00047 //       Access: Public, Static
00048 //  Description: Loads the given filename up into a texture, if it has
00049 //               not already been loaded, and returns the new texture.
00050 //               If a texture with the same filename was previously
00051 //               loaded, returns that one instead.  If the texture
00052 //               file cannot be found, returns NULL.
00053 ////////////////////////////////////////////////////////////////////
00054 INLINE Texture *TexturePool::
00055 load_texture(const string &filename, int primary_file_num_channels) {
00056   return get_ptr()->ns_load_texture(filename, primary_file_num_channels);
00057 }
00058 
00059 ////////////////////////////////////////////////////////////////////
00060 //     Function: TexturePool::load_texture
00061 //       Access: Public, Static
00062 //  Description: Loads the given filename up into a texture, if it has
00063 //               not already been loaded, and returns the new texture.
00064 //               If a texture with the same filename was previously
00065 //               loaded, returns that one instead.  If the texture
00066 //               file cannot be found, returns NULL.
00067 ////////////////////////////////////////////////////////////////////
00068 INLINE Texture *TexturePool::
00069 load_texture(const string &filename, const string &alpha_filename,
00070              int primary_file_num_channels, int alpha_file_channel) {
00071   return get_ptr()->ns_load_texture(filename, alpha_filename, 
00072                                     primary_file_num_channels,
00073                                     alpha_file_channel);
00074 }
00075 
00076 ////////////////////////////////////////////////////////////////////
00077 //     Function: TexturePool::add_texture
00078 //       Access: Public, Static
00079 //  Description: Adds the indicated already-loaded texture to the
00080 //               pool.  The texture must have a filename set for its
00081 //               name.  The texture will always replace any
00082 //               previously-loaded texture in the pool that had the
00083 //               same filename.
00084 ////////////////////////////////////////////////////////////////////
00085 INLINE void TexturePool::
00086 add_texture(Texture *texture) {
00087   get_ptr()->ns_add_texture(texture);
00088 }
00089 
00090 ////////////////////////////////////////////////////////////////////
00091 //     Function: TexturePool::release_texture
00092 //       Access: Public, Static
00093 //  Description: Removes the indicated texture from the pool,
00094 //               indicating it will never be loaded again; the texture
00095 //               may then be freed.  If this function is never called,
00096 //               a reference count will be maintained on every texture
00097 //               every loaded, and textures will never be freed.
00098 //
00099 //               The texture's name should not have been changed
00100 //               during its lifetime, or this function may fail to
00101 //               locate it in the pool.
00102 ////////////////////////////////////////////////////////////////////
00103 INLINE void TexturePool::
00104 release_texture(Texture *texture) {
00105   get_ptr()->ns_release_texture(texture);
00106 }
00107 
00108 ////////////////////////////////////////////////////////////////////
00109 //     Function: TexturePool::release_all_textures
00110 //       Access: Public, Static
00111 //  Description: Releases all textures in the pool and restores the
00112 //               pool to the empty state.
00113 ////////////////////////////////////////////////////////////////////
00114 INLINE void TexturePool::
00115 release_all_textures() {
00116   get_ptr()->ns_release_all_textures();
00117 }
00118 
00119 ////////////////////////////////////////////////////////////////////
00120 //     Function: TexturePool::garbage_collect
00121 //       Access: Public, Static
00122 //  Description: Releases only those textures in the pool that have a
00123 //               reference count of exactly 1; i.e. only those
00124 //               textures that are not being used outside of the pool.
00125 //               Returns the number of textures released.
00126 ////////////////////////////////////////////////////////////////////
00127 INLINE int TexturePool::
00128 garbage_collect() {
00129   return get_ptr()->ns_garbage_collect();
00130 }
00131 
00132 ////////////////////////////////////////////////////////////////////
00133 //     Function: TexturePool::list_contents
00134 //       Access: Public, Static
00135 //  Description: Lists the contents of the texture pool to the
00136 //               indicated output stream.
00137 ////////////////////////////////////////////////////////////////////
00138 INLINE void TexturePool::
00139 list_contents(ostream &out) {
00140   get_ptr()->ns_list_contents(out);
00141 }
00142 
00143 ////////////////////////////////////////////////////////////////////
00144 //     Function: TexturePool::Constructor
00145 //       Access: Private
00146 //  Description: The constructor is not intended to be called
00147 //               directly; there's only supposed to be one TexturePool
00148 //               in the universe and it constructs itself.
00149 ////////////////////////////////////////////////////////////////////
00150 INLINE TexturePool::
00151 TexturePool() {
00152 }

Generated on Fri May 2 00:39:45 2003 for Panda by doxygen1.3