00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "depthTestAttrib.h"
00016 #include "graphicsStateGuardianBase.h"
00017 #include "dcast.h"
00018 #include "bamReader.h"
00019 #include "bamWriter.h"
00020 #include "datagram.h"
00021 #include "datagramIterator.h"
00022
00023 TypeHandle DepthTestAttrib::_type_handle;
00024 int DepthTestAttrib::_attrib_slot;
00025
00026
00027
00028
00029
00030
00031 CPT(RenderAttrib) DepthTestAttrib::
00032 make(DepthTestAttrib::PandaCompareFunc mode) {
00033 DepthTestAttrib *attrib = new DepthTestAttrib(mode);
00034 return return_new(attrib);
00035 }
00036
00037
00038
00039
00040
00041
00042
00043
00044 CPT(RenderAttrib) DepthTestAttrib::
00045 make_default() {
00046 return return_new(new DepthTestAttrib);
00047 }
00048
00049
00050
00051
00052
00053
00054 void DepthTestAttrib::
00055 output(ostream &out) const {
00056 out << get_type() << ":";
00057 output_comparefunc(out,_mode);
00058 }
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 int DepthTestAttrib::
00076 compare_to_impl(const RenderAttrib *other) const {
00077 const DepthTestAttrib *ta;
00078 DCAST_INTO_R(ta, other, 0);
00079 return (int)_mode - (int)ta->_mode;
00080 }
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092 size_t DepthTestAttrib::
00093 get_hash_impl() const {
00094 size_t hash = 0;
00095 hash = int_hash::add_hash(hash, (int)_mode);
00096 return hash;
00097 }
00098
00099
00100
00101
00102
00103
00104
00105 void DepthTestAttrib::
00106 register_with_read_factory() {
00107 BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
00108 }
00109
00110
00111
00112
00113
00114
00115
00116 void DepthTestAttrib::
00117 write_datagram(BamWriter *manager, Datagram &dg) {
00118 RenderAttrib::write_datagram(manager, dg);
00119
00120 dg.add_int8(_mode);
00121 }
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131 TypedWritable *DepthTestAttrib::
00132 make_from_bam(const FactoryParams ¶ms) {
00133 DepthTestAttrib *attrib = new DepthTestAttrib;
00134 DatagramIterator scan;
00135 BamReader *manager;
00136
00137 parse_params(params, scan, manager);
00138 attrib->fillin(scan, manager);
00139
00140 return attrib;
00141 }
00142
00143
00144
00145
00146
00147
00148
00149
00150 void DepthTestAttrib::
00151 fillin(DatagramIterator &scan, BamReader *manager) {
00152 RenderAttrib::fillin(scan, manager);
00153
00154 _mode = (PandaCompareFunc)scan.get_int8();
00155 }