Panda3D
Loading...
Searching...
No Matches
drawableRegion.cxx
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 drawableRegion.cxx
10 * @author drose
11 * @date 2002-07-11
12 */
13
14#include "drawableRegion.h"
15#include "config_display.h"
16
17
18/**
19 *
20 */
21DrawableRegion::
22~DrawableRegion() {
23}
24
25/**
26 * Sets the clear-active flag for any bitplane.
27 */
29set_clear_active(int n, bool clear_active) {
30 nassertv(n >= 0 && n < RTP_COUNT);
31 if (clear_active) {
32 _clear_mask |= 1 << n;
33 } else {
34 _clear_mask &= ~(1 << n);
35 }
36 update_pixel_factor();
37}
38
39/**
40 * Gets the clear-active flag for any bitplane.
41 */
43get_clear_active(int n) const {
44 nassertr(n >= 0 && n < RTP_COUNT, false);
45 return (_clear_mask & (1 << n)) != 0;
46}
47
48/**
49 * Sets the clear value for any bitplane.
50 */
52set_clear_value(int n, const LColor &clear_value) {
53 nassertv((n >= 0) && (n < RTP_COUNT));
54 _clear_value[n] = clear_value;
55}
56
57/**
58 * Returns the clear value for any bitplane.
59 */
60const LColor &DrawableRegion::
61get_clear_value(int n) const {
62 static LColor blank(0.5,0.5,0.5,0.0);
63 nassertr((n >= 0) && (n < RTP_COUNT), blank);
64 return _clear_value[n];
65}
66
67/**
68 * Disables both the color and depth clear. See set_clear_color_active and
69 * set_clear_depth_active.
70 */
73 _clear_mask = 0;
74 update_pixel_factor();
75}
76
77/**
78 * Returns true if any of the clear types (so far there are just color or
79 * depth) have been set active, or false if none of them are active and there
80 * is no need to clear.
81 */
83is_any_clear_active() const {
84 return (_clear_mask != 0);
85}
86
87/**
88 * Sets the amount by which the pixels of the region are scaled internally
89 * when filling the image interally. Setting this number larger makes the
90 * pixels blockier, but may make the rendering faster, particularly for
91 * software renderers. Setting this number to 2.0 reduces the number of
92 * pixels that have to be filled by the renderer by a factor of 2.0. It
93 * doesn't make sense to set this lower than 1.0.
94 *
95 * It is possible to set this on either individual DisplayRegions or on
96 * overall GraphicsWindows, but you will get better performance for setting it
97 * on the window rather than its individual DisplayRegions. Also, you may not
98 * set it on a DisplayRegion that doesn't have both clear_color() and
99 * clear_depth() enabled.
100 *
101 * This property is only supported on renderers for which it is particularly
102 * useful--currently, this is the tinydisplay software renderer. Other kinds
103 * of renderers allow you to set this property, but ignore it.
104 */
106set_pixel_zoom(PN_stdfloat pixel_zoom) {
107 _pixel_zoom = pixel_zoom;
108 update_pixel_factor();
109}
110
111/**
112 * Returns true if a call to set_pixel_zoom() will be respected, false if it
113 * will be ignored. If this returns false, then get_pixel_factor() will
114 * always return 1.0, regardless of what value you specify for
115 * set_pixel_zoom().
116 *
117 * This may return false if the underlying renderer doesn't support pixel
118 * zooming, or if you have called this on a DisplayRegion that doesn't have
119 * both set_clear_color() and set_clear_depth() enabled.
120 */
122supports_pixel_zoom() const {
123 return false;
124}
125
126/**
127 * Returns the RenderBuffer::Type that corresponds to a RenderTexturePlane.
128 */
130get_renderbuffer_type(int rtp) {
131 switch(rtp) {
132 case RTP_stencil: return RenderBuffer::T_stencil;
133 case RTP_depth: return RenderBuffer::T_depth;
134 case RTP_depth_stencil: return RenderBuffer::T_depth | RenderBuffer::T_stencil;
135 case RTP_color: return RenderBuffer::T_color;
136 case RTP_aux_rgba_0: return RenderBuffer::T_aux_rgba_0;
137 case RTP_aux_rgba_1: return RenderBuffer::T_aux_rgba_1;
138 case RTP_aux_rgba_2: return RenderBuffer::T_aux_rgba_2;
139 case RTP_aux_rgba_3: return RenderBuffer::T_aux_rgba_3;
140 case RTP_aux_hrgba_0: return RenderBuffer::T_aux_hrgba_0;
141 case RTP_aux_hrgba_1: return RenderBuffer::T_aux_hrgba_1;
142 case RTP_aux_hrgba_2: return RenderBuffer::T_aux_hrgba_2;
143 case RTP_aux_hrgba_3: return RenderBuffer::T_aux_hrgba_3;
144 case RTP_aux_float_0: return RenderBuffer::T_aux_float_0;
145 case RTP_aux_float_1: return RenderBuffer::T_aux_float_1;
146 case RTP_aux_float_2: return RenderBuffer::T_aux_float_2;
147 case RTP_aux_float_3: return RenderBuffer::T_aux_float_3;
148 default:
149 display_cat.error() << "DrawableRegion::get_renderbuffer_type unexpected case!\n";
150 return 0;
151 };
152}
153
154/**
155 * Called internally when the pixel factor changes.
156 */
157void DrawableRegion::
158pixel_factor_changed() {
159}
set_pixel_zoom
Sets the amount by which the pixels of the region are scaled internally when filling the image intera...
virtual void set_clear_value(int n, const LColor &clear_value)
Sets the clear value for any bitplane.
virtual bool supports_pixel_zoom() const
Returns true if a call to set_pixel_zoom() will be respected, false if it will be ignored.
static int get_renderbuffer_type(int plane)
Returns the RenderBuffer::Type that corresponds to a RenderTexturePlane.
virtual const LColor & get_clear_value(int n) const
Returns the clear value for any bitplane.
virtual bool get_clear_active(int n) const
Gets the clear-active flag for any bitplane.
virtual void set_clear_active(int n, bool clear_aux_active)
Sets the clear-active flag for any bitplane.
virtual bool is_any_clear_active() const
Returns true if any of the clear types (so far there are just color or depth) have been set active,...
virtual void disable_clears()
Disables both the color and depth clear.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.