29 get_ptr()->ns_list_contents(out);
36 ns_has_shader(
const Filename &orig_filename) {
38 resolve_filename(filename, orig_filename);
41 Shaders::const_iterator ti;
42 ti = _shaders.find(filename);
43 if (ti != _shaders.end()) {
55 ns_load_shader(
const Filename &orig_filename) {
57 resolve_filename(filename, orig_filename);
62 Shaders::const_iterator ti;
63 ti = _shaders.find(filename);
64 if (ti != _shaders.end()) {
72 <<
"Loading shader " << filename <<
"\n";
74 Shader::ShaderLanguage lang = Shader::SL_none;
81 if (ext ==
"cg" || ext ==
"sha") {
85 }
else if (ext ==
"glsl" || ext ==
"vert" || ext ==
"frag" ||
86 ext ==
"geom" || ext ==
"tesc" || ext ==
"tese" ||
88 lang = Shader::SL_GLSL;
91 PT(
Shader) shader = Shader::load(filename, lang);
92 if (shader ==
nullptr) {
101 Shaders::const_iterator ti;
102 ti = _shaders.find(filename);
103 if (ti != _shaders.end()) {
108 _shaders[filename] = shader;
120 resolve_filename(filename, orig_filename);
124 _shaders[filename] = shader;
131 ns_release_shader(
const Filename &filename) {
134 Shaders::iterator ti;
135 ti = _shaders.find(filename);
136 if (ti != _shaders.end()) {
145 ns_release_all_shaders() {
155 ns_garbage_collect() {
158 int num_released = 0;
161 Shaders::iterator ti;
162 for (ti = _shaders.begin(); ti != _shaders.end(); ++ti) {
164 if (shader->get_ref_count() == 1) {
173 new_set.insert(new_set.end(), *ti);
177 _shaders.swap(new_set);
185 ns_list_contents(std::ostream &out)
const {
188 out << _shaders.size() <<
" shaders:\n";
189 Shaders::const_iterator ti;
190 for (ti = _shaders.begin(); ti != _shaders.end(); ++ti) {
192 out <<
" " << (*ti).first
193 <<
" (count = " << shader->get_ref_count() <<
")\n";
203 new_filename = orig_filename;
214 if (_global_ptr ==
nullptr) {
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A hierarchy of directories and files that appears to be one continuous file system,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
string downcase(const string &s)
Returns the input string with all uppercase letters converted to lowercase.
static void write(std::ostream &out)
Lists the contents of the shader pool to the indicated output stream.
bool resolve_filename(Filename &filename, const DSearchPath &searchpath, const std::string &default_extension=std::string()) const
Searches the given search path for the filename.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the preferred interface for loading shaders for the TextNode system.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The name of a file, such as a texture file or an Egg file.
Similar to MutexHolder, but for a light mutex.
static VirtualFileSystem * get_global_ptr()
Returns the default global VirtualFileSystem.
std::string get_extension() const
Returns the file extension.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
CPT(Shader) ShaderPool
The nonstatic implementation of load_shader().