Panda3D
scissorAttrib.h
1 // Filename: scissorAttrib.h
2 // Created by: drose (29Jul08)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef SCISSORATTRIB_H
16 #define SCISSORATTRIB_H
17 
18 #include "pandabase.h"
19 
20 #include "renderAttrib.h"
21 #include "luse.h"
22 
23 class FactoryParams;
24 
25 ////////////////////////////////////////////////////////////////////
26 // Class : ScissorAttrib
27 // Description : This restricts rendering to within a rectangular
28 // region of the scene, without otherwise affecting the
29 // viewport or lens properties. Geometry that falls
30 // outside the scissor region is not rendered. It is
31 // akin to the OpenGL glScissor() function.
32 //
33 // The ScissorAttrib always specifies its region
34 // relative to its enclosing DisplayRegion, in screen
35 // space, and performs no culling.
36 //
37 // See ScissorEffect if you wish to define a
38 // region relative to 2-D or 3-D coordinates in the
39 // scene graph, with culling.
40 ////////////////////////////////////////////////////////////////////
41 class EXPCL_PANDA_PGRAPH ScissorAttrib : public RenderAttrib {
42 private:
43  ScissorAttrib(const LVecBase4 &frame);
44 
45 PUBLISHED:
46  static CPT(RenderAttrib) make_off();
47  INLINE static CPT(RenderAttrib) make(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top);
48  static CPT(RenderAttrib) make(const LVecBase4 &frame);
49  static CPT(RenderAttrib) make_default();
50 
51  INLINE bool is_off() const;
52 
53  INLINE const LVecBase4 &get_frame() const;
54 
55 public:
56  virtual void output(ostream &out) const;
57 
58 protected:
59  virtual int compare_to_impl(const RenderAttrib *other) const;
60  virtual size_t get_hash_impl() const;
61  virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
62 
63 private:
64  LVecBase4 _frame;
65  bool _off;
66  static CPT(RenderAttrib) _off_attrib;
67 
68 PUBLISHED:
69  static int get_class_slot() {
70  return _attrib_slot;
71  }
72  virtual int get_slot() const {
73  return get_class_slot();
74  }
75 
76 public:
77  static void register_with_read_factory();
78  virtual void write_datagram(BamWriter *manager, Datagram &dg);
79 
80 protected:
81  static TypedWritable *make_from_bam(const FactoryParams &params);
82  void fillin(DatagramIterator &scan, BamReader *manager);
83 
84 public:
85  static TypeHandle get_class_type() {
86  return _type_handle;
87  }
88  static void init_type() {
89  RenderAttrib::init_type();
90  register_type(_type_handle, "ScissorAttrib",
91  RenderAttrib::get_class_type());
92  _attrib_slot = register_slot(_type_handle, 100, make_default);
93  }
94  virtual TypeHandle get_type() const {
95  return get_class_type();
96  }
97  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
98 
99 private:
100  static TypeHandle _type_handle;
101  static int _attrib_slot;
102 };
103 
104 #include "scissorAttrib.I"
105 
106 #endif
107 
static int register_slot(TypeHandle type_handle, int sort, RenderAttribRegistry::MakeDefaultFunc *make_default_func)
Adds the indicated TypeHandle to the registry, if it is not there already, and returns a unique slot ...
Definition: renderAttrib.I:163
This is the base class for a number of render attributes (other than transform) that may be set on sc...
Definition: renderAttrib.h:60
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
This restricts rendering to within a rectangular region of the scene, without otherwise affecting the...
Definition: scissorAttrib.h:41
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43