Panda3D
logicOpAttrib.h
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file logicOpAttrib.I
10  * @author rdb
11  * @date 2016-03-24
12  */
13 
14 #ifndef LOGICOPATTRIB_H
15 #define LOGICOPATTRIB_H
16 
17 #include "pandabase.h"
18 #include "luse.h"
19 #include "renderAttrib.h"
20 
21 class FactoryParams;
22 
23 /**
24  * If enabled, specifies that a custom logical operation be performed instead
25  * of any color blending. Setting it to a value other than M_none will cause
26  * color blending to be disabled and the given logic operation to be performed.
27  *
28  * @since 1.10.0
29  */
30 class EXPCL_PANDA_PGRAPH LogicOpAttrib : public RenderAttrib {
31 PUBLISHED:
32  enum Operation {
33  O_none, // LogicOp disabled, regular blending occurs.
34  O_clear, // Clears framebuffer value.
35  O_and,
36  O_and_reverse,
37  O_copy, // Writes the incoming color to the framebuffer.
38  O_and_inverted,
39  O_noop, // Leaves the framebuffer value unaltered.
40  O_xor,
41  O_or,
42  O_nor,
43  O_equivalent,
44  O_invert,
45  O_or_reverse,
46  O_copy_inverted,
47  O_or_inverted,
48  O_nand,
49  O_set, // Sets all the bits in the framebuffer to 1.
50  };
51 
52 private:
53  INLINE LogicOpAttrib(Operation op);
54 
55 PUBLISHED:
56  static CPT(RenderAttrib) make_off();
57  static CPT(RenderAttrib) make(Operation op);
58  static CPT(RenderAttrib) make_default();
59 
60  INLINE Operation get_operation() const;
61  MAKE_PROPERTY(operation, get_operation);
62 
63 public:
64  virtual void output(std::ostream &out) const;
65 
66 protected:
67  virtual int compare_to_impl(const RenderAttrib *other) const;
68  virtual size_t get_hash_impl() const;
69 
70 private:
71  Operation _op;
72 
73 PUBLISHED:
74  static int get_class_slot() {
75  return _attrib_slot;
76  }
77  virtual int get_slot() const {
78  return get_class_slot();
79  }
80  MAKE_PROPERTY(class_slot, get_class_slot);
81 
82 public:
83  static void register_with_read_factory();
84  virtual void write_datagram(BamWriter *manager, Datagram &dg);
85 
86 protected:
87  static TypedWritable *make_from_bam(const FactoryParams &params);
88  void fillin(DatagramIterator &scan, BamReader *manager);
89 
90 public:
91  static TypeHandle get_class_type() {
92  return _type_handle;
93  }
94  static void init_type() {
95  RenderAttrib::init_type();
96  register_type(_type_handle, "LogicOpAttrib",
97  RenderAttrib::get_class_type());
98  _attrib_slot = register_slot(_type_handle, 100, new LogicOpAttrib(O_none));
99  }
100  virtual TypeHandle get_type() const {
101  return get_class_type();
102  }
103  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
104 
105 private:
106  static TypeHandle _type_handle;
107  static int _attrib_slot;
108 };
109 
110 EXPCL_PANDA_PGRAPH std::ostream &operator << (std::ostream &out, LogicOpAttrib::Operation op);
111 
112 #include "logicOpAttrib.I"
113 
114 #endif
This is the base class for a number of render attributes (other than transform) that may be set on sc...
Definition: renderAttrib.h:51
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
static int register_slot(TypeHandle type_handle, int sort, RenderAttrib *default_attrib)
Adds the indicated TypeHandle to the registry, if it is not there already, and returns a unique slot ...
Definition: renderAttrib.I:101
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
If enabled, specifies that a custom logical operation be performed instead of any color blending.
Definition: logicOpAttrib.h:30
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:81
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38