Panda3D
Static Public Member Functions | List of all members
ShaderPool Class Reference

This is the preferred interface for loading shaders for the TextNode system. More...

#include "shaderPool.h"

Static Public Member Functions

static void add_shader (const Filename &filename, Shader *shader)
 Adds the indicated already-loaded shader to the pool. More...
 
static CPT (Shader) load_shader(const Filename &filename)
 
static int garbage_collect ()
 Releases only those shaders in the pool that have a reference count of exactly 1; i.e. More...
 
static bool has_shader (const Filename &filename)
 Returns true if the shader has ever been loaded, false otherwise. More...
 
static void list_contents (std::ostream &out)
 Lists the contents of the shader pool to the indicated output stream. More...
 
static void release_all_shaders ()
 Releases all shaders in the pool and restores the pool to the empty state. More...
 
static void release_shader (const Filename &filename)
 Removes the indicated shader from the pool, indicating it will never be loaded again; the shader may then be freed. More...
 
static bool verify_shader (const Filename &filename)
 Loads the given filename up into a shader, if it has not already been loaded, and returns true to indicate success, or false to indicate failure. More...
 
static void write (std::ostream &out)
 Lists the contents of the shader pool to the indicated output stream. More...
 

Detailed Description

This is the preferred interface for loading shaders for the TextNode system.

It is similar to ModelPool and TexturePool in that it unifies references to the same filename.

Definition at line 28 of file shaderPool.h.

Member Function Documentation

◆ add_shader()

void ShaderPool::add_shader ( const Filename filename,
Shader shader 
)
inlinestatic

Adds the indicated already-loaded shader to the pool.

The shader will always replace any previously-loaded shader in the pool that had the same filename.

Definition at line 50 of file shaderPool.I.

◆ garbage_collect()

int ShaderPool::garbage_collect ( )
inlinestatic

Releases only those shaders in the pool that have a reference count of exactly 1; i.e.

only those shaders that are not being used outside of the pool. Returns the number of shaders released.

Definition at line 79 of file shaderPool.I.

◆ has_shader()

bool ShaderPool::has_shader ( const Filename filename)
inlinestatic

Returns true if the shader has ever been loaded, false otherwise.

Definition at line 18 of file shaderPool.I.

◆ list_contents()

void ShaderPool::list_contents ( std::ostream &  out)
inlinestatic

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

Definition at line 87 of file shaderPool.I.

◆ release_all_shaders()

void ShaderPool::release_all_shaders ( )
inlinestatic

Releases all shaders in the pool and restores the pool to the empty state.

Definition at line 69 of file shaderPool.I.

◆ release_shader()

void ShaderPool::release_shader ( const Filename filename)
inlinestatic

Removes the indicated shader from the pool, indicating it will never be loaded again; the shader may then be freed.

If this function is never called, a reference count will be maintained on every shader every loaded, and shaders will never be freed.

Definition at line 61 of file shaderPool.I.

◆ verify_shader()

bool ShaderPool::verify_shader ( const Filename filename)
inlinestatic

Loads the given filename up into a shader, if it has not already been loaded, and returns true to indicate success, or false to indicate failure.

If this returns true, it is guaranteed that a subsequent call to load_shader() with the same shader name will return a valid Shader pointer.

Definition at line 29 of file shaderPool.I.

◆ write()

void ShaderPool::write ( std::ostream &  out)
static

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

Definition at line 28 of file shaderPool.cxx.


The documentation for this class was generated from the following files: