mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
Added 'auto' flag to ShaderAttrib
This commit is contained in:
parent
0cd1b7a065
commit
21436b4f4d
@ -3203,6 +3203,29 @@ set_shader_off(int priority) {
|
|||||||
set_shader(NULL, priority);
|
set_shader(NULL, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: NodePath::set_shader_auto
|
||||||
|
// Access: Published
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void NodePath::
|
||||||
|
set_shader_auto(int priority) {
|
||||||
|
nassertv_always(!is_empty());
|
||||||
|
|
||||||
|
const RenderAttrib *attrib =
|
||||||
|
node()->get_attrib(ShaderAttrib::get_class_type());
|
||||||
|
if (attrib != (const RenderAttrib *)NULL) {
|
||||||
|
priority = max(priority,
|
||||||
|
node()->get_state()->get_override(ShaderAttrib::get_class_type()));
|
||||||
|
const ShaderAttrib *sa = DCAST(ShaderAttrib, attrib);
|
||||||
|
node()->set_attrib(sa->set_shader_auto(priority));
|
||||||
|
} else {
|
||||||
|
// Create a new ShaderAttrib for this node.
|
||||||
|
CPT(ShaderAttrib) sa = DCAST(ShaderAttrib, ShaderAttrib::make());
|
||||||
|
node()->set_attrib(sa->set_shader_auto(priority));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: NodePath::clear_shader
|
// Function: NodePath::clear_shader
|
||||||
// Access: Published
|
// Access: Published
|
||||||
|
@ -572,6 +572,7 @@ PUBLISHED:
|
|||||||
|
|
||||||
void set_shader(const Shader *sha, int priority = 0);
|
void set_shader(const Shader *sha, int priority = 0);
|
||||||
void set_shader_off(int priority = 0);
|
void set_shader_off(int priority = 0);
|
||||||
|
void set_shader_auto(int priority = 0);
|
||||||
void clear_shader();
|
void clear_shader();
|
||||||
void set_shader_input(const ShaderInput *inp);
|
void set_shader_input(const ShaderInput *inp);
|
||||||
void set_shader_input(InternalName *id, Texture *tex, int priority=0);
|
void set_shader_input(InternalName *id, Texture *tex, int priority=0);
|
||||||
|
@ -35,6 +35,7 @@ INLINE ShaderAttrib::
|
|||||||
ShaderAttrib(const ShaderAttrib ©) :
|
ShaderAttrib(const ShaderAttrib ©) :
|
||||||
_shader(copy._shader),
|
_shader(copy._shader),
|
||||||
_shader_priority(copy._shader_priority),
|
_shader_priority(copy._shader_priority),
|
||||||
|
_auto_shader(copy._auto_shader),
|
||||||
_has_shader(copy._has_shader),
|
_has_shader(copy._has_shader),
|
||||||
_inputs(copy._inputs)
|
_inputs(copy._inputs)
|
||||||
{
|
{
|
||||||
@ -51,6 +52,18 @@ has_shader() const {
|
|||||||
return _has_shader;
|
return _has_shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: ShaderAttrib::auto_shader
|
||||||
|
// Access: Published
|
||||||
|
// Description: If true, then this ShaderAttrib does not contain an
|
||||||
|
// explicit shader - instead, it requests the automatic
|
||||||
|
// generation of a shader.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE bool ShaderAttrib::
|
||||||
|
auto_shader() const {
|
||||||
|
return _auto_shader;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: ShaderAttrib::get_shader_priority
|
// Function: ShaderAttrib::get_shader_priority
|
||||||
// Access: Published
|
// Access: Published
|
||||||
|
@ -42,6 +42,7 @@ make_off() {
|
|||||||
ShaderAttrib *attrib = new ShaderAttrib;
|
ShaderAttrib *attrib = new ShaderAttrib;
|
||||||
attrib->_shader = (Shader*)NULL;
|
attrib->_shader = (Shader*)NULL;
|
||||||
attrib->_shader_priority = 0;
|
attrib->_shader_priority = 0;
|
||||||
|
attrib->_auto_shader = false;
|
||||||
attrib->_has_shader = true;
|
attrib->_has_shader = true;
|
||||||
_off_attrib = return_new(attrib);
|
_off_attrib = return_new(attrib);
|
||||||
}
|
}
|
||||||
@ -61,6 +62,7 @@ make() {
|
|||||||
ShaderAttrib *attrib = new ShaderAttrib;
|
ShaderAttrib *attrib = new ShaderAttrib;
|
||||||
attrib->_shader = (Shader*)NULL;
|
attrib->_shader = (Shader*)NULL;
|
||||||
attrib->_shader_priority = 0;
|
attrib->_shader_priority = 0;
|
||||||
|
attrib->_auto_shader = false;
|
||||||
attrib->_has_shader = false;
|
attrib->_has_shader = false;
|
||||||
_null_attrib = return_new(attrib);
|
_null_attrib = return_new(attrib);
|
||||||
}
|
}
|
||||||
@ -77,6 +79,7 @@ set_shader(const Shader *s, int priority) const {
|
|||||||
ShaderAttrib *result = new ShaderAttrib(*this);
|
ShaderAttrib *result = new ShaderAttrib(*this);
|
||||||
result->_shader = s;
|
result->_shader = s;
|
||||||
result->_shader_priority = priority;
|
result->_shader_priority = priority;
|
||||||
|
result->_auto_shader = false;
|
||||||
result->_has_shader = true;
|
result->_has_shader = true;
|
||||||
return return_new(result);
|
return return_new(result);
|
||||||
}
|
}
|
||||||
@ -91,6 +94,22 @@ set_shader_off(int priority) const {
|
|||||||
ShaderAttrib *result = new ShaderAttrib(*this);
|
ShaderAttrib *result = new ShaderAttrib(*this);
|
||||||
result->_shader = NULL;
|
result->_shader = NULL;
|
||||||
result->_shader_priority = priority;
|
result->_shader_priority = priority;
|
||||||
|
result->_auto_shader = false;
|
||||||
|
result->_has_shader = true;
|
||||||
|
return return_new(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: ShaderAttrib::set_shader_auto
|
||||||
|
// Access: Published
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
CPT(RenderAttrib) ShaderAttrib::
|
||||||
|
set_shader_auto(int priority) const {
|
||||||
|
ShaderAttrib *result = new ShaderAttrib(*this);
|
||||||
|
result->_shader = NULL;
|
||||||
|
result->_shader_priority = priority;
|
||||||
|
result->_auto_shader = true;
|
||||||
result->_has_shader = true;
|
result->_has_shader = true;
|
||||||
return return_new(result);
|
return return_new(result);
|
||||||
}
|
}
|
||||||
@ -105,6 +124,7 @@ clear_shader() const {
|
|||||||
ShaderAttrib *result = new ShaderAttrib(*this);
|
ShaderAttrib *result = new ShaderAttrib(*this);
|
||||||
result->_shader = NULL;
|
result->_shader = NULL;
|
||||||
result->_shader_priority = 0;
|
result->_shader_priority = 0;
|
||||||
|
result->_auto_shader = false;
|
||||||
result->_has_shader = false;
|
result->_has_shader = false;
|
||||||
return return_new(result);
|
return return_new(result);
|
||||||
}
|
}
|
||||||
@ -437,6 +457,7 @@ compose_impl(const RenderAttrib *other) const {
|
|||||||
(over->_shader_priority >= attr->_shader_priority)) {
|
(over->_shader_priority >= attr->_shader_priority)) {
|
||||||
attr->_shader = over->_shader;
|
attr->_shader = over->_shader;
|
||||||
attr->_shader_priority = over->_shader_priority;
|
attr->_shader_priority = over->_shader_priority;
|
||||||
|
attr->_auto_shader = over->_auto_shader;
|
||||||
attr->_has_shader = over->_has_shader;
|
attr->_has_shader = over->_has_shader;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,12 +39,14 @@ private:
|
|||||||
PUBLISHED:
|
PUBLISHED:
|
||||||
static CPT(RenderAttrib) make();
|
static CPT(RenderAttrib) make();
|
||||||
static CPT(RenderAttrib) make_off();
|
static CPT(RenderAttrib) make_off();
|
||||||
|
|
||||||
INLINE bool has_shader() const;
|
INLINE bool has_shader() const;
|
||||||
|
INLINE bool auto_shader() const;
|
||||||
INLINE int get_shader_priority() const;
|
INLINE int get_shader_priority() const;
|
||||||
|
|
||||||
CPT(RenderAttrib) set_shader(const Shader *s, int priority=0) const;
|
CPT(RenderAttrib) set_shader(const Shader *s, int priority=0) const;
|
||||||
CPT(RenderAttrib) set_shader_off(int priority=0) const;
|
CPT(RenderAttrib) set_shader_off(int priority=0) const;
|
||||||
|
CPT(RenderAttrib) set_shader_auto(int priority=0) const;
|
||||||
CPT(RenderAttrib) clear_shader() const;
|
CPT(RenderAttrib) clear_shader() const;
|
||||||
CPT(RenderAttrib) set_shader_input(const ShaderInput *inp) const;
|
CPT(RenderAttrib) set_shader_input(const ShaderInput *inp) const;
|
||||||
CPT(RenderAttrib) set_shader_input(InternalName *id, Texture *tex, int priority=0) const;
|
CPT(RenderAttrib) set_shader_input(InternalName *id, Texture *tex, int priority=0) const;
|
||||||
@ -79,8 +81,10 @@ protected:
|
|||||||
virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
|
virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
CPT(Shader) _shader;
|
CPT(Shader) _shader;
|
||||||
int _shader_priority;
|
int _shader_priority;
|
||||||
|
bool _auto_shader;
|
||||||
bool _has_shader;
|
bool _has_shader;
|
||||||
typedef pmap < CPT(InternalName), CPT(ShaderInput) > Inputs;
|
typedef pmap < CPT(InternalName), CPT(ShaderInput) > Inputs;
|
||||||
Inputs _inputs;
|
Inputs _inputs;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user