00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef RENDERATTRIB_H
00020 #define RENDERATTRIB_H
00021
00022 #include "pandabase.h"
00023
00024 #include "typedWritableReferenceCount.h"
00025 #include "indirectCompareTo.h"
00026 #include "pointerTo.h"
00027 #include "pset.h"
00028
00029 class GraphicsStateGuardianBase;
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 class EXPCL_PANDA RenderAttrib : public TypedWritableReferenceCount {
00059 protected:
00060 RenderAttrib();
00061 private:
00062 RenderAttrib(const RenderAttrib ©);
00063 void operator = (const RenderAttrib ©);
00064
00065 public:
00066 virtual ~RenderAttrib();
00067
00068 INLINE CPT(RenderAttrib) compose(const RenderAttrib *other) const;
00069 INLINE CPT(RenderAttrib) invert_compose(const RenderAttrib *other) const;
00070 INLINE CPT(RenderAttrib) make_default() const;
00071 INLINE int compare_to(const RenderAttrib &other) const;
00072 virtual void issue(GraphicsStateGuardianBase *gsg) const;
00073
00074 PUBLISHED:
00075 virtual void output(ostream &out) const;
00076 virtual void write(ostream &out, int indent_level) const;
00077
00078 enum PandaCompareFunc {
00079 M_none=0,
00080 M_never,
00081 M_less,
00082 M_equal,
00083 M_less_equal,
00084 M_greater,
00085 M_not_equal,
00086 M_greater_equal,
00087 M_always
00088 };
00089
00090 protected:
00091 static CPT(RenderAttrib) return_new(RenderAttrib *attrib);
00092 virtual int compare_to_impl(const RenderAttrib *other) const;
00093 virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
00094 virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
00095 virtual RenderAttrib *make_default_impl() const=0;
00096 void output_comparefunc(ostream &out,PandaCompareFunc fn) const;
00097
00098 private:
00099 typedef pset<const RenderAttrib *, IndirectCompareTo<RenderAttrib> > Attribs;
00100 static Attribs *_attribs;
00101
00102 Attribs::iterator _saved_entry;
00103
00104 public:
00105 virtual void write_datagram(BamWriter *manager, Datagram &dg);
00106 static TypedWritable *change_this(TypedWritable *old_ptr, BamReader *manager);
00107 virtual void finalize();
00108
00109 protected:
00110 static TypedWritable *new_from_bam(RenderAttrib *attrib, BamReader *manager);
00111 void fillin(DatagramIterator &scan, BamReader *manager);
00112
00113 public:
00114 static TypeHandle get_class_type() {
00115 return _type_handle;
00116 }
00117 static void init_type() {
00118 TypedWritableReferenceCount::init_type();
00119 register_type(_type_handle, "RenderAttrib",
00120 TypedWritableReferenceCount::get_class_type());
00121 }
00122 virtual TypeHandle get_type() const {
00123 return get_class_type();
00124 }
00125 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00126
00127 private:
00128 static TypeHandle _type_handle;
00129 };
00130
00131 INLINE ostream &operator << (ostream &out, const RenderAttrib &attrib) {
00132 attrib.output(out);
00133 return out;
00134 }
00135
00136 #include "renderAttrib.I"
00137
00138 #endif
00139