00001 // Filename: alphaTestAttrib.h 00002 // Created by: drose (04Mar02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 #ifndef ALPHATESTATTRIB_H 00020 #define ALPHATESTATTRIB_H 00021 00022 #include "pandabase.h" 00023 #include "renderAttrib.h" 00024 00025 class FactoryParams; 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Class : AlphaTestAttrib 00029 // Description : Enables or disables writing of pixel to framebuffer 00030 // based on its alpha value relative to a reference alpha value 00031 //////////////////////////////////////////////////////////////////// 00032 class EXPCL_PANDA AlphaTestAttrib : public RenderAttrib { 00033 private: 00034 INLINE AlphaTestAttrib(PandaCompareFunc mode = M_always, 00035 float reference_alpha = 1.0f); 00036 00037 PUBLISHED: 00038 static CPT(RenderAttrib) make(PandaCompareFunc mode, 00039 float reference_alpha); 00040 INLINE float get_reference_alpha() const; 00041 INLINE PandaCompareFunc get_mode() const; 00042 00043 public: 00044 virtual void issue(GraphicsStateGuardianBase *gsg) const; 00045 virtual void output(ostream &out) const; 00046 00047 protected: 00048 virtual int compare_to_impl(const RenderAttrib *other) const; 00049 virtual RenderAttrib *make_default_impl() const; 00050 00051 private: 00052 PandaCompareFunc _mode; 00053 float _reference_alpha; // should be in range [0.0-1.0] 00054 00055 public: 00056 static void register_with_read_factory(); 00057 virtual void write_datagram(BamWriter *manager, Datagram &dg); 00058 00059 protected: 00060 static TypedWritable *make_from_bam(const FactoryParams ¶ms); 00061 void fillin(DatagramIterator &scan, BamReader *manager); 00062 00063 public: 00064 static TypeHandle get_class_type() { 00065 return _type_handle; 00066 } 00067 static void init_type() { 00068 RenderAttrib::init_type(); 00069 register_type(_type_handle, "AlphaTestAttrib", 00070 RenderAttrib::get_class_type()); 00071 } 00072 virtual TypeHandle get_type() const { 00073 return get_class_type(); 00074 } 00075 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00076 00077 private: 00078 static TypeHandle _type_handle; 00079 }; 00080 00081 #include "alphaTestAttrib.I" 00082 00083 #endif 00084