Updated stencil interface.
This commit is contained in:
parent
1afccc2d19
commit
64ac1f8510
|
|
@ -4012,13 +4012,6 @@ do_issue_stencil() {
|
|||
stencil_render_states = this -> _stencil_render_states;
|
||||
if (stencil && stencil_render_states) {
|
||||
|
||||
#ifndef NDEBUG
|
||||
// DEBUG ONLY
|
||||
if (stencil -> _pre) {
|
||||
dxgsg8_cat.error() << "Invalid StencilAttrib\n";
|
||||
}
|
||||
#endif
|
||||
|
||||
// DEBUG
|
||||
if (false) {
|
||||
dxgsg8_cat.debug() << "STENCIL STATE CHANGE\n";
|
||||
|
|
|
|||
|
|
@ -5142,13 +5142,6 @@ do_issue_stencil() {
|
|||
stencil_render_states = this -> _stencil_render_states;
|
||||
if (stencil && stencil_render_states) {
|
||||
|
||||
#ifndef NDEBUG
|
||||
// DEBUG ONLY
|
||||
if (stencil -> _pre) {
|
||||
dxgsg9_cat.error() << "Invalid StencilAttrib\n";
|
||||
}
|
||||
#endif
|
||||
|
||||
// DEBUG
|
||||
if (false) {
|
||||
dxgsg9_cat.debug() << "STENCIL STATE CHANGE\n";
|
||||
|
|
|
|||
|
|
@ -7369,13 +7369,6 @@ do_issue_stencil() {
|
|||
stencil_render_states = this -> _stencil_render_states;
|
||||
if (stencil && stencil_render_states) {
|
||||
|
||||
#ifndef NDEBUG
|
||||
// DEBUG ONLY
|
||||
if (stencil -> _pre) {
|
||||
GLCAT.error() << "Invalid StencilAttrib\n";
|
||||
}
|
||||
#endif
|
||||
|
||||
// DEBUG
|
||||
if (false) {
|
||||
GLCAT.debug() << "STENCIL STATE CHANGE\n";
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ initialize_defvals() {
|
|||
_defvals._rescale_normal = DCAST(RescaleNormalAttrib,RescaleNormalAttrib::make_default());
|
||||
_defvals._shade_model = DCAST(ShadeModelAttrib,ShadeModelAttrib::make(ShadeModelAttrib::M_smooth));
|
||||
_defvals._shader = DCAST(ShaderAttrib,ShaderAttrib::make_off());
|
||||
_defvals._stencil = DCAST(StencilAttrib,StencilAttrib::make());
|
||||
_defvals._stencil = DCAST(StencilAttrib,StencilAttrib::make_off());
|
||||
_defvals._tex_gen = DCAST(TexGenAttrib,TexGenAttrib::make());
|
||||
_defvals._tex_matrix = DCAST(TexMatrixAttrib,TexMatrixAttrib::make());
|
||||
_defvals._texture = DCAST(TextureAttrib,TextureAttrib::make_all_off());
|
||||
|
|
|
|||
|
|
@ -16,52 +16,6 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: StencilAttrib::Constructor
|
||||
// Access: Private
|
||||
// Description: Use StencilAttrib::make() to construct a new
|
||||
// StencilAttrib object.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE StencilAttrib::
|
||||
StencilAttrib() {
|
||||
|
||||
_stencil_render_states [SRS_front_enable] = 0;
|
||||
_stencil_render_states [SRS_back_enable] = 0;
|
||||
|
||||
_stencil_render_states [SRS_front_comparison_function] = SCF_always;
|
||||
_stencil_render_states [SRS_front_stencil_fail_operation] = SO_keep;
|
||||
_stencil_render_states [SRS_front_stencil_pass_z_fail_operation] = SO_keep;
|
||||
_stencil_render_states [SRS_front_stencil_pass_z_pass_operation] = SO_keep;
|
||||
|
||||
_stencil_render_states [SRS_reference] = 0;
|
||||
_stencil_render_states [SRS_read_mask] = ~0;
|
||||
_stencil_render_states [SRS_write_mask] = ~0;
|
||||
|
||||
_stencil_render_states [SRS_back_comparison_function] = SCF_always;
|
||||
_stencil_render_states [SRS_back_stencil_fail_operation] = SO_keep;
|
||||
_stencil_render_states [SRS_back_stencil_pass_z_fail_operation] = SO_keep;
|
||||
_stencil_render_states [SRS_back_stencil_pass_z_pass_operation] = SO_keep;
|
||||
|
||||
_pre = false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: StencilAttrib::set_render_state
|
||||
// Access: Published
|
||||
// Description: Sets the render state.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void StencilAttrib::
|
||||
set_render_state(unsigned int render_state_identifier, unsigned int render_state) {
|
||||
if (_pre) {
|
||||
_stencil_render_states [render_state_identifier] = render_state;
|
||||
}
|
||||
else {
|
||||
// ERROR: set_render_state can only be called with a pre_make StencilAttrib
|
||||
printf ("ERROR: set_render_state can only be called with a StencilAttrib.make_begin\n");
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: StencilAttrib::get_render_state
|
||||
// Access: Published
|
||||
|
|
|
|||
|
|
@ -49,53 +49,122 @@ stencil_render_state_name_array [StencilAttrib::SRS_total] =
|
|||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: StencilAttrib::make_begin
|
||||
// Function: StencilAttrib::Constructor
|
||||
// Access: Private
|
||||
// Description: Use StencilAttrib::make() to construct a new
|
||||
// StencilAttrib object.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
StencilAttrib::
|
||||
StencilAttrib() {
|
||||
|
||||
_stencil_render_states [SRS_front_enable] = 0;
|
||||
_stencil_render_states [SRS_back_enable] = 0;
|
||||
|
||||
_stencil_render_states [SRS_front_comparison_function] = SCF_always;
|
||||
_stencil_render_states [SRS_front_stencil_fail_operation] = SO_keep;
|
||||
_stencil_render_states [SRS_front_stencil_pass_z_fail_operation] = SO_keep;
|
||||
_stencil_render_states [SRS_front_stencil_pass_z_pass_operation] = SO_keep;
|
||||
|
||||
_stencil_render_states [SRS_reference] = 0;
|
||||
_stencil_render_states [SRS_read_mask] = ~0;
|
||||
_stencil_render_states [SRS_write_mask] = ~0;
|
||||
|
||||
_stencil_render_states [SRS_back_comparison_function] = SCF_always;
|
||||
_stencil_render_states [SRS_back_stencil_fail_operation] = SO_keep;
|
||||
_stencil_render_states [SRS_back_stencil_pass_z_fail_operation] = SO_keep;
|
||||
_stencil_render_states [SRS_back_stencil_pass_z_pass_operation] = SO_keep;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: StencilAttrib::make_off
|
||||
// Access: Published, Static
|
||||
// Description: Constructs a new default and writable StencilAttrib.
|
||||
// set_render_state can be called.
|
||||
// Description: Constructs a front face StencilAttrib.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) StencilAttrib::
|
||||
make_begin() {
|
||||
make_off()
|
||||
{
|
||||
StencilAttrib *attrib = new StencilAttrib;
|
||||
attrib -> _pre = true;
|
||||
|
||||
CPT(RenderAttrib) pt_attrib = attrib;
|
||||
|
||||
return pt_attrib;
|
||||
return return_new(attrib);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: StencilAttrib::make
|
||||
// Access: Published, Static
|
||||
// Description: Constructs a new default read-only StencilAttrib.
|
||||
// set_render_state can not be called on the created
|
||||
// object.
|
||||
// Description: Constructs a front face StencilAttrib.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) StencilAttrib::
|
||||
make() {
|
||||
make(
|
||||
unsigned int front_enable,
|
||||
unsigned int front_comparison_function,
|
||||
unsigned int stencil_fail_operation,
|
||||
unsigned int stencil_pass_z_fail_operation,
|
||||
unsigned int front_stencil_pass_z_pass_operation,
|
||||
unsigned int reference,
|
||||
unsigned int read_mask,
|
||||
unsigned int write_mask)
|
||||
{
|
||||
StencilAttrib *attrib = new StencilAttrib;
|
||||
|
||||
attrib->_stencil_render_states [SRS_front_enable] = front_enable;
|
||||
attrib->_stencil_render_states [SRS_back_enable] = 0;
|
||||
|
||||
attrib->_stencil_render_states [SRS_front_comparison_function] = front_comparison_function;
|
||||
attrib->_stencil_render_states [SRS_front_stencil_fail_operation] = stencil_fail_operation;
|
||||
attrib->_stencil_render_states [SRS_front_stencil_pass_z_fail_operation] = stencil_pass_z_fail_operation;
|
||||
attrib->_stencil_render_states [SRS_front_stencil_pass_z_pass_operation] = front_stencil_pass_z_pass_operation;
|
||||
|
||||
attrib->_stencil_render_states [SRS_reference] = reference;
|
||||
attrib->_stencil_render_states [SRS_read_mask] = read_mask;
|
||||
attrib->_stencil_render_states [SRS_write_mask] = write_mask;
|
||||
|
||||
attrib->_stencil_render_states [SRS_back_comparison_function] = SCF_always;
|
||||
attrib->_stencil_render_states [SRS_back_stencil_fail_operation] = SO_keep;
|
||||
attrib->_stencil_render_states [SRS_back_stencil_pass_z_fail_operation] = SO_keep;
|
||||
attrib->_stencil_render_states [SRS_back_stencil_pass_z_pass_operation] = SO_keep;
|
||||
|
||||
return return_new(attrib);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: StencilAttrib::make_end
|
||||
// Access: Published
|
||||
// Description: Constructs a final read-only StencilAttrib object
|
||||
// from an existing StencilAttrib.
|
||||
// Function: StencilAttrib::make_2_sided
|
||||
// Access: Published, Static
|
||||
// Description: Constructs a two-sided StencilAttrib.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) StencilAttrib::
|
||||
make_end() {
|
||||
|
||||
make_2_sided(
|
||||
unsigned int front_enable,
|
||||
unsigned int back_enable,
|
||||
unsigned int front_comparison_function,
|
||||
unsigned int stencil_fail_operation,
|
||||
unsigned int stencil_pass_z_fail_operation,
|
||||
unsigned int front_stencil_pass_z_pass_operation,
|
||||
unsigned int reference,
|
||||
unsigned int read_mask,
|
||||
unsigned int write_mask,
|
||||
unsigned int back_comparison_function,
|
||||
unsigned int back_stencil_fail_operation,
|
||||
unsigned int back_stencil_pass_z_fail_operation,
|
||||
unsigned int back_stencil_pass_z_pass_operation)
|
||||
{
|
||||
StencilAttrib *attrib = new StencilAttrib;
|
||||
StencilAttrib *original_attrib;
|
||||
|
||||
original_attrib = this;
|
||||
attrib->_stencil_render_states [SRS_front_enable] = front_enable;
|
||||
attrib->_stencil_render_states [SRS_back_enable] = back_enable;
|
||||
|
||||
int index;
|
||||
for (index = 0; index < SRS_total; index++) {
|
||||
attrib -> _stencil_render_states [index] =
|
||||
original_attrib -> _stencil_render_states [index];
|
||||
}
|
||||
attrib->_stencil_render_states [SRS_front_comparison_function] = front_comparison_function;
|
||||
attrib->_stencil_render_states [SRS_front_stencil_fail_operation] = stencil_fail_operation;
|
||||
attrib->_stencil_render_states [SRS_front_stencil_pass_z_fail_operation] = stencil_pass_z_fail_operation;
|
||||
attrib->_stencil_render_states [SRS_front_stencil_pass_z_pass_operation] = front_stencil_pass_z_pass_operation;
|
||||
|
||||
attrib->_stencil_render_states [SRS_reference] = reference;
|
||||
attrib->_stencil_render_states [SRS_read_mask] = read_mask;
|
||||
attrib->_stencil_render_states [SRS_write_mask] = write_mask;
|
||||
|
||||
attrib->_stencil_render_states [SRS_back_comparison_function] = back_comparison_function;
|
||||
attrib->_stencil_render_states [SRS_back_stencil_fail_operation] = back_stencil_fail_operation;
|
||||
attrib->_stencil_render_states [SRS_back_stencil_pass_z_fail_operation] = back_stencil_pass_z_fail_operation;
|
||||
attrib->_stencil_render_states [SRS_back_stencil_pass_z_pass_operation] = back_stencil_pass_z_pass_operation;
|
||||
|
||||
return return_new(attrib);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class FactoryParams;
|
|||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDA StencilAttrib : public RenderAttrib {
|
||||
private:
|
||||
INLINE StencilAttrib();
|
||||
StencilAttrib();
|
||||
|
||||
PUBLISHED:
|
||||
|
||||
|
|
@ -84,10 +84,38 @@ PUBLISHED:
|
|||
SO_decrement_saturate,
|
||||
};
|
||||
|
||||
static CPT(RenderAttrib) make_begin();
|
||||
static CPT(RenderAttrib) make();
|
||||
CPT(RenderAttrib) make_end();
|
||||
INLINE void set_render_state (unsigned int render_state_identifier, unsigned int render_state);
|
||||
enum StencilMask
|
||||
{
|
||||
SM_default = ~0,
|
||||
};
|
||||
|
||||
static CPT(RenderAttrib) make_off();
|
||||
|
||||
static CPT(RenderAttrib) make(
|
||||
unsigned int front_enable,
|
||||
unsigned int front_comparison_function,
|
||||
unsigned int stencil_fail_operation,
|
||||
unsigned int stencil_pass_z_fail_operation,
|
||||
unsigned int front_stencil_pass_z_pass_operation,
|
||||
unsigned int reference,
|
||||
unsigned int read_mask,
|
||||
unsigned int write_mask);
|
||||
|
||||
static CPT(RenderAttrib) make_2_sided(
|
||||
unsigned int front_enable,
|
||||
unsigned int back_enable,
|
||||
unsigned int front_comparison_function,
|
||||
unsigned int stencil_fail_operation,
|
||||
unsigned int stencil_pass_z_fail_operation,
|
||||
unsigned int front_stencil_pass_z_pass_operation,
|
||||
unsigned int reference,
|
||||
unsigned int read_mask,
|
||||
unsigned int write_mask,
|
||||
unsigned int back_comparison_function,
|
||||
unsigned int back_stencil_fail_operation,
|
||||
unsigned int back_stencil_pass_z_fail_operation,
|
||||
unsigned int back_stencil_pass_z_pass_operation);
|
||||
|
||||
INLINE unsigned int get_render_state (unsigned int render_state_identifier) const;
|
||||
|
||||
public:
|
||||
|
|
@ -102,8 +130,6 @@ protected:
|
|||
|
||||
private:
|
||||
unsigned int _stencil_render_states [SRS_total];
|
||||
public:
|
||||
bool _pre;
|
||||
|
||||
public:
|
||||
static void register_with_read_factory();
|
||||
|
|
|
|||
Loading…
Reference in New Issue