mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
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:
parent
bcb1ff0418
commit
ffbde58774
@ -30,7 +30,7 @@ get_file() const {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: Shader::get_body
|
// Function: Shader::get_body
|
||||||
// Access: Published
|
// Access: Published
|
||||||
// Description:
|
// Description:
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
INLINE const string &Shader::
|
INLINE const string &Shader::
|
||||||
get_body() const {
|
get_body() const {
|
||||||
@ -40,7 +40,7 @@ get_body() const {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: Shader::get_name
|
// Function: Shader::get_name
|
||||||
// Access: Published
|
// Access: Published
|
||||||
// Description:
|
// Description:
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
INLINE const string &Shader::
|
INLINE const string &Shader::
|
||||||
get_name() const {
|
get_name() const {
|
||||||
@ -50,17 +50,27 @@ get_name() const {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: Shader::get_loaded
|
// Function: Shader::get_loaded
|
||||||
// Access: Published
|
// Access: Published
|
||||||
// Description:
|
// Description:
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
INLINE bool Shader::
|
INLINE bool Shader::
|
||||||
get_loaded() const {
|
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
|
||||||
// Description:
|
// Description:
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
INLINE int Shader::
|
INLINE int Shader::
|
||||||
get_preprocessor() const {
|
get_preprocessor() const {
|
||||||
|
@ -26,16 +26,17 @@ Shader::MakeTable Shader::_make_table;
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: Shader::Constructor
|
// Function: Shader::Constructor
|
||||||
// Access: Private
|
// Access: Private
|
||||||
// Description:
|
// Description:
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
Shader::
|
Shader::
|
||||||
Shader() {
|
Shader() {
|
||||||
|
this -> _load_error = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: Shader::Destructor
|
// Function: Shader::Destructor
|
||||||
// Access: Private
|
// Access: Private
|
||||||
// Description:
|
// Description:
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
Shader::
|
Shader::
|
||||||
~Shader() {
|
~Shader() {
|
||||||
@ -51,7 +52,7 @@ Shader::
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: Shader::load
|
// Function: Shader::load
|
||||||
// Access: Published, Static
|
// Access: Published, Static
|
||||||
// Description:
|
// Description:
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
CPT(Shader) Shader::
|
CPT(Shader) Shader::
|
||||||
load(const string &file, int preprocessor) {
|
load(const string &file, int preprocessor) {
|
||||||
@ -61,7 +62,7 @@ load(const string &file, int preprocessor) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: Shader::load
|
// Function: Shader::load
|
||||||
// Access: Published, Static
|
// Access: Published, Static
|
||||||
// Description:
|
// Description:
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
CPT(Shader) Shader::
|
CPT(Shader) Shader::
|
||||||
load(const Filename &file, int preprocessor) {
|
load(const Filename &file, int preprocessor) {
|
||||||
@ -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;
|
||||||
@ -88,7 +90,7 @@ load(const Filename &file, int preprocessor) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: Shader::make
|
// Function: Shader::make
|
||||||
// Access: Published, Static
|
// Access: Published, Static
|
||||||
// Description:
|
// Description:
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
CPT(Shader) Shader::
|
CPT(Shader) Shader::
|
||||||
make(const string &body, int preprocessor) {
|
make(const string &body, int preprocessor) {
|
||||||
@ -116,7 +118,7 @@ make(const string &body, int preprocessor) {
|
|||||||
// shader text in Cg, GLSL, HLSL, or whatever. The
|
// shader text in Cg, GLSL, HLSL, or whatever. The
|
||||||
// macro preprocessor will be able to query the RenderState
|
// macro preprocessor will be able to query the RenderState
|
||||||
// and generate different shader code for different states.
|
// and generate different shader code for different states.
|
||||||
//
|
//
|
||||||
// The macroexpansion of the shader is stored in an object
|
// The macroexpansion of the shader is stored in an object
|
||||||
// of class ShaderExpansion. This is somewhat expensive
|
// of class ShaderExpansion. This is somewhat expensive
|
||||||
// to generate, so the ShaderExpansion is cached inside the
|
// to generate, so the ShaderExpansion is cached inside the
|
||||||
@ -153,7 +155,7 @@ macroexpand(const RenderState *context) const {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: Shader::register_with_read_factory
|
// Function: Shader::register_with_read_factory
|
||||||
// Access: Public, Static
|
// Access: Public, Static
|
||||||
// Description:
|
// Description:
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void Shader::
|
void Shader::
|
||||||
register_with_read_factory() {
|
register_with_read_factory() {
|
||||||
|
@ -28,7 +28,7 @@ class ShaderExpansion;
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Class : Shader
|
// Class : Shader
|
||||||
// Description :
|
// Description :
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
class EXPCL_PANDA Shader: public TypedWritableReferenceCount {
|
class EXPCL_PANDA Shader: public TypedWritableReferenceCount {
|
||||||
@ -36,37 +36,39 @@ PUBLISHED:
|
|||||||
static CPT(Shader) load(const Filename &file, int preprocessor=0);
|
static CPT(Shader) load(const Filename &file, int preprocessor=0);
|
||||||
static CPT(Shader) load(const string &file, int preprocessor=0);
|
static CPT(Shader) load(const string &file, int preprocessor=0);
|
||||||
static CPT(Shader) make(const string &body, int preprocessor=0);
|
static CPT(Shader) make(const string &body, int preprocessor=0);
|
||||||
|
|
||||||
INLINE const string &get_name() const;
|
INLINE const string &get_name() const;
|
||||||
INLINE const Filename &get_file() const;
|
INLINE const Filename &get_file() const;
|
||||||
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;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Shader();
|
Shader();
|
||||||
~Shader();
|
~Shader();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string _name;
|
string _name;
|
||||||
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;
|
||||||
|
|
||||||
typedef pair < Filename, int > LoadTableKey;
|
typedef pair < Filename, int > LoadTableKey;
|
||||||
typedef pair < string, int > MakeTableKey;
|
typedef pair < string, int > MakeTableKey;
|
||||||
|
|
||||||
typedef pmap < LoadTableKey , Shader * > LoadTable;
|
typedef pmap < LoadTableKey , Shader * > LoadTable;
|
||||||
typedef pmap < MakeTableKey , Shader * > MakeTable;
|
typedef pmap < MakeTableKey , Shader * > MakeTable;
|
||||||
|
|
||||||
static LoadTable _load_table;
|
static LoadTable _load_table;
|
||||||
static MakeTable _make_table;
|
static MakeTable _make_table;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void register_with_read_factory();
|
static void register_with_read_factory();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user