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