Panda3D
 All Classes Functions Variables Enumerations
shaderPool.I
00001 // Filename: shaderPool.I
00002 // Created by:  aignacio (Mar06)
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: ShaderPool::has_shader
00018 //       Access: Public, Static
00019 //  Description: Returns true if the shader has ever been loaded,
00020 //               false otherwise.
00021 ////////////////////////////////////////////////////////////////////
00022 INLINE bool ShaderPool::
00023 has_shader(const Filename &filename) {
00024   return get_ptr()->ns_has_shader(filename);
00025 }
00026 
00027 ////////////////////////////////////////////////////////////////////
00028 //     Function: ShaderPool::verify_shader
00029 //       Access: Public, Static
00030 //  Description: Loads the given filename up into a shader, if it has
00031 //               not already been loaded, and returns true to indicate
00032 //               success, or false to indicate failure.  If this
00033 //               returns true, it is guaranteed that a subsequent call
00034 //               to load_shader() with the same shader name will
00035 //               return a valid Shader pointer.
00036 ////////////////////////////////////////////////////////////////////
00037 INLINE bool ShaderPool::
00038 verify_shader(const Filename &filename) {
00039   return load_shader(filename) != (Shader *)NULL;
00040 }
00041 
00042 ////////////////////////////////////////////////////////////////////
00043 //     Function: ShaderPool::load_shader
00044 //       Access: Public, Static
00045 //  Description: Loads the given filename up into a shader, if it has
00046 //               not already been loaded, and returns the new shader.
00047 //               If a shader with the same filename was previously
00048 //               loaded, returns that one instead.  If the shader
00049 //               file cannot be found, returns NULL.
00050 ////////////////////////////////////////////////////////////////////
00051 INLINE CPT(Shader) ShaderPool::
00052 load_shader(const Filename &filename) {
00053   return get_ptr()->ns_load_shader(filename);
00054 }
00055 
00056 ////////////////////////////////////////////////////////////////////
00057 //     Function: ShaderPool::add_shader
00058 //       Access: Public, Static
00059 //  Description: Adds the indicated already-loaded shader to the
00060 //               pool.  The shader will always replace any
00061 //               previously-loaded shader in the pool that had the
00062 //               same filename.
00063 ////////////////////////////////////////////////////////////////////
00064 INLINE void ShaderPool::
00065 add_shader(const Filename &filename, Shader *shader) {
00066   get_ptr()->ns_add_shader(filename, shader);
00067 }
00068 
00069 ////////////////////////////////////////////////////////////////////
00070 //     Function: ShaderPool::release_shader
00071 //       Access: Public, Static
00072 //  Description: Removes the indicated shader from the pool,
00073 //               indicating it will never be loaded again; the shader
00074 //               may then be freed.  If this function is never called,
00075 //               a reference count will be maintained on every shader
00076 //               every loaded, and shaders will never be freed.
00077 ////////////////////////////////////////////////////////////////////
00078 INLINE void ShaderPool::
00079 release_shader(const Filename &filename) {
00080   get_ptr()->ns_release_shader(filename);
00081 }
00082 
00083 ////////////////////////////////////////////////////////////////////
00084 //     Function: ShaderPool::release_all_shaders
00085 //       Access: Public, Static
00086 //  Description: Releases all shaders in the pool and restores the
00087 //               pool to the empty state.
00088 ////////////////////////////////////////////////////////////////////
00089 INLINE void ShaderPool::
00090 release_all_shaders() {
00091   get_ptr()->ns_release_all_shaders();
00092 }
00093 
00094 ////////////////////////////////////////////////////////////////////
00095 //     Function: ShaderPool::garbage_collect
00096 //       Access: Public, Static
00097 //  Description: Releases only those shaders in the pool that have a
00098 //               reference count of exactly 1; i.e. only those
00099 //               shaders that are not being used outside of the pool.
00100 //               Returns the number of shaders released.
00101 ////////////////////////////////////////////////////////////////////
00102 INLINE int ShaderPool::
00103 garbage_collect() {
00104   return get_ptr()->ns_garbage_collect();
00105 }
00106 
00107 ////////////////////////////////////////////////////////////////////
00108 //     Function: ShaderPool::list_contents
00109 //       Access: Public, Static
00110 //  Description: Lists the contents of the shader pool to the
00111 //               indicated output stream.
00112 ////////////////////////////////////////////////////////////////////
00113 INLINE void ShaderPool::
00114 list_contents(ostream &out) {
00115   get_ptr()->ns_list_contents(out);
00116 }
00117 
00118 ////////////////////////////////////////////////////////////////////
00119 //     Function: ShaderPool::Constructor
00120 //       Access: Private
00121 //  Description: The constructor is not intended to be called
00122 //               directly; there's only supposed to be one ShaderPool
00123 //               in the universe and it constructs itself.
00124 ////////////////////////////////////////////////////////////////////
00125 INLINE ShaderPool::
00126 ShaderPool() {
00127 }
 All Classes Functions Variables Enumerations