Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/pgraph/depthTestAttrib.cxx

Go to the documentation of this file.
00001 // Filename: depthTestAttrib.cxx
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 #include "depthTestAttrib.h"
00020 #include "graphicsStateGuardianBase.h"
00021 #include "dcast.h"
00022 #include "bamReader.h"
00023 #include "bamWriter.h"
00024 #include "datagram.h"
00025 #include "datagramIterator.h"
00026 
00027 TypeHandle DepthTestAttrib::_type_handle;
00028 
00029 ////////////////////////////////////////////////////////////////////
00030 //     Function: DepthTestAttrib::make
00031 //       Access: Published, Static
00032 //  Description: Constructs a new DepthTestAttrib object.
00033 ////////////////////////////////////////////////////////////////////
00034 CPT(RenderAttrib) DepthTestAttrib::
00035 make(DepthTestAttrib::PandaCompareFunc mode) {
00036   DepthTestAttrib *attrib = new DepthTestAttrib(mode);
00037   return return_new(attrib);
00038 }
00039 
00040 ////////////////////////////////////////////////////////////////////
00041 //     Function: DepthTestAttrib::issue
00042 //       Access: Public, Virtual
00043 //  Description: Calls the appropriate method on the indicated GSG
00044 //               to issue the graphics commands appropriate to the
00045 //               given attribute.  This is normally called
00046 //               (indirectly) only from
00047 //               GraphicsStateGuardian::set_state() or modify_state().
00048 ////////////////////////////////////////////////////////////////////
00049 void DepthTestAttrib::
00050 issue(GraphicsStateGuardianBase *gsg) const {
00051   gsg->issue_depth_test(this);
00052 }
00053 
00054 ////////////////////////////////////////////////////////////////////
00055 //     Function: DepthTestAttrib::output
00056 //       Access: Public, Virtual
00057 //  Description: 
00058 ////////////////////////////////////////////////////////////////////
00059 void DepthTestAttrib::
00060 output(ostream &out) const {
00061   out << get_type() << ":";
00062   output_comparefunc(out,_mode);
00063 }
00064 
00065 ////////////////////////////////////////////////////////////////////
00066 //     Function: DepthTestAttrib::compare_to_impl
00067 //       Access: Protected, Virtual
00068 //  Description: Intended to be overridden by derived DepthTestAttrib
00069 //               types to return a unique number indicating whether
00070 //               this DepthTestAttrib is equivalent to the other one.
00071 //
00072 //               This should return 0 if the two DepthTestAttrib objects
00073 //               are equivalent, a number less than zero if this one
00074 //               should be sorted before the other one, and a number
00075 //               greater than zero otherwise.
00076 //
00077 //               This will only be called with two DepthTestAttrib
00078 //               objects whose get_type() functions return the same.
00079 ////////////////////////////////////////////////////////////////////
00080 int DepthTestAttrib::
00081 compare_to_impl(const RenderAttrib *other) const {
00082   const DepthTestAttrib *ta;
00083   DCAST_INTO_R(ta, other, 0);
00084   return (int)_mode - (int)ta->_mode;
00085 }
00086 
00087 ////////////////////////////////////////////////////////////////////
00088 //     Function: DepthTestAttrib::make_default_impl
00089 //       Access: Protected, Virtual
00090 //  Description: Intended to be overridden by derived DepthTestAttrib
00091 //               types to specify what the default property for a
00092 //               DepthTestAttrib of this type should be.
00093 //
00094 //               This should return a newly-allocated DepthTestAttrib of
00095 //               the same type that corresponds to whatever the
00096 //               standard default for this kind of DepthTestAttrib is.
00097 ////////////////////////////////////////////////////////////////////
00098 RenderAttrib *DepthTestAttrib::
00099 make_default_impl() const {
00100   return new DepthTestAttrib;
00101 }
00102 
00103 ////////////////////////////////////////////////////////////////////
00104 //     Function: DepthTestAttrib::register_with_read_factory
00105 //       Access: Public, Static
00106 //  Description: Tells the BamReader how to create objects of type
00107 //               DepthTestAttrib.
00108 ////////////////////////////////////////////////////////////////////
00109 void DepthTestAttrib::
00110 register_with_read_factory() {
00111   BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
00112 }
00113 
00114 ////////////////////////////////////////////////////////////////////
00115 //     Function: DepthTestAttrib::write_datagram
00116 //       Access: Public, Virtual
00117 //  Description: Writes the contents of this object to the datagram
00118 //               for shipping out to a Bam file.
00119 ////////////////////////////////////////////////////////////////////
00120 void DepthTestAttrib::
00121 write_datagram(BamWriter *manager, Datagram &dg) {
00122   RenderAttrib::write_datagram(manager, dg);
00123 
00124   dg.add_int8(_mode);
00125 }
00126 
00127 ////////////////////////////////////////////////////////////////////
00128 //     Function: DepthTestAttrib::make_from_bam
00129 //       Access: Protected, Static
00130 //  Description: This function is called by the BamReader's factory
00131 //               when a new object of type DepthTestAttrib is encountered
00132 //               in the Bam file.  It should create the DepthTestAttrib
00133 //               and extract its information from the file.
00134 ////////////////////////////////////////////////////////////////////
00135 TypedWritable *DepthTestAttrib::
00136 make_from_bam(const FactoryParams &params) {
00137   DepthTestAttrib *attrib = new DepthTestAttrib;
00138   DatagramIterator scan;
00139   BamReader *manager;
00140 
00141   parse_params(params, scan, manager);
00142   attrib->fillin(scan, manager);
00143 
00144   return attrib;
00145 }
00146 
00147 ////////////////////////////////////////////////////////////////////
00148 //     Function: DepthTestAttrib::fillin
00149 //       Access: Protected
00150 //  Description: This internal function is called by make_from_bam to
00151 //               read in all of the relevant data from the BamFile for
00152 //               the new DepthTestAttrib.
00153 ////////////////////////////////////////////////////////////////////
00154 void DepthTestAttrib::
00155 fillin(DatagramIterator &scan, BamReader *manager) {
00156   RenderAttrib::fillin(scan, manager);
00157 
00158   _mode = (PandaCompareFunc)scan.get_int8();
00159 }

Generated on Fri May 2 00:41:32 2003 for Panda by doxygen1.3