Panda3D
 All Classes Functions Variables Enumerations
scissorAttrib.h
00001 // Filename: scissorAttrib.h
00002 // Created by:  drose (29Jul08)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef SCISSORATTRIB_H
00016 #define SCISSORATTRIB_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "renderAttrib.h"
00021 #include "luse.h"
00022 
00023 class FactoryParams;
00024 
00025 ////////////////////////////////////////////////////////////////////
00026 //       Class : ScissorAttrib
00027 // Description : This restricts rendering to within a rectangular
00028 //               region of the scene, without otherwise affecting the
00029 //               viewport or lens properties.  Geometry that falls
00030 //               outside the scissor region is not rendered.  It is
00031 //               akin to the OpenGL glScissor() function.
00032 //
00033 //               The ScissorAttrib always specifies its region
00034 //               relative to its enclosing DisplayRegion, in screen
00035 //               space, and performs no culling.
00036 //
00037 //               See ScissorEffect if you wish to define a
00038 //               region relative to 2-D or 3-D coordinates in the
00039 //               scene graph, with culling.
00040 ////////////////////////////////////////////////////////////////////
00041 class EXPCL_PANDA_PGRAPH ScissorAttrib : public RenderAttrib {
00042 private:
00043   ScissorAttrib(const LVecBase4 &frame);
00044 
00045 PUBLISHED:
00046   static CPT(RenderAttrib) make_off();
00047   INLINE static CPT(RenderAttrib) make(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top);
00048   static CPT(RenderAttrib) make(const LVecBase4 &frame);
00049   static CPT(RenderAttrib) make_default();
00050 
00051   INLINE const LVecBase4 &get_frame() const;
00052 
00053 public:
00054   virtual void output(ostream &out) const;
00055 
00056 protected:
00057   virtual int compare_to_impl(const RenderAttrib *other) const;
00058   virtual size_t get_hash_impl() const;
00059   virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
00060 
00061 private:
00062   LVecBase4 _frame;
00063   static CPT(RenderAttrib) _off;
00064 
00065 PUBLISHED:
00066   static int get_class_slot() {
00067     return _attrib_slot;
00068   }
00069   virtual int get_slot() const {
00070     return get_class_slot();
00071   }
00072 
00073 public:
00074   static void register_with_read_factory();
00075   virtual void write_datagram(BamWriter *manager, Datagram &dg);
00076 
00077 protected:
00078   static TypedWritable *make_from_bam(const FactoryParams &params);
00079   void fillin(DatagramIterator &scan, BamReader *manager);
00080   
00081 public:
00082   static TypeHandle get_class_type() {
00083     return _type_handle;
00084   }
00085   static void init_type() {
00086     RenderAttrib::init_type();
00087     register_type(_type_handle, "ScissorAttrib",
00088                   RenderAttrib::get_class_type());
00089     _attrib_slot = register_slot(_type_handle, 100, make_default);
00090   }
00091   virtual TypeHandle get_type() const {
00092     return get_class_type();
00093   }
00094   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00095 
00096 private:
00097   static TypeHandle _type_handle;
00098   static int _attrib_slot;
00099 };
00100 
00101 #include "scissorAttrib.I"
00102 
00103 #endif
00104 
 All Classes Functions Variables Enumerations