Added get_load_error function. Needed to know if the file was properly loaded or not before using a shader.

This commit is contained in:
aignacio_sf 2006-02-10 20:35:59 +00:00
parent bcb1ff0418
commit ffbde58774
3 changed files with 34 additions and 20 deletions

View File

@ -57,6 +57,16 @@ get_loaded() const {
return _loaded; return _loaded;
} }
////////////////////////////////////////////////////////////////////
// Function: Shader::get_load_error
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE bool Shader::
get_load_error() const {
return _load_error;
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: Shader::get_preprocessor // Function: Shader::get_preprocessor
// Access: Published // Access: Published

View File

@ -30,6 +30,7 @@ Shader::MakeTable Shader::_make_table;
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
Shader:: Shader::
Shader() { Shader() {
this -> _load_error = false;
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -80,6 +81,7 @@ load(const Filename &file, int preprocessor) {
if (!vfs->read_file(file, result->_body, true)) { if (!vfs->read_file(file, result->_body, true)) {
cerr << "Could not read shader file: " << file << "\n"; cerr << "Could not read shader file: " << file << "\n";
result->_body = ""; result->_body = "";
result->_load_error = true;
} }
_load_table[key] = result; _load_table[key] = result;
return result; return result;

View File

@ -42,6 +42,7 @@ PUBLISHED:
INLINE const string &get_body() const; INLINE const string &get_body() const;
INLINE int get_preprocessor() const; INLINE int get_preprocessor() const;
INLINE bool get_loaded() const; INLINE bool get_loaded() const;
INLINE bool get_load_error() const;
PT(ShaderExpansion) macroexpand(const RenderState *context) const; PT(ShaderExpansion) macroexpand(const RenderState *context) const;
@ -54,6 +55,7 @@ private:
Filename _file; Filename _file;
string _body; string _body;
bool _loaded; bool _loaded;
bool _load_error;
int _preprocessor; int _preprocessor;
PT(ShaderExpansion) _fixed_expansion; PT(ShaderExpansion) _fixed_expansion;