Panda3D
displayRegion.I
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 displayRegion.I
10  * @author frang
11  * @date 1999-03-07
12  */
13 
14 /**
15  * Returns true if this DisplayRegion should be sorted before the other one,
16  * false otherwise.
17  */
18 INLINE bool DisplayRegion::
19 operator < (const DisplayRegion &other) const {
20  return get_sort() < other.get_sort();
21 }
22 
23 /**
24  * Returns the specific lens of the associated Camera that will be used for
25  * rendering this scene. Most Cameras hold only one lens, but for multiple
26  * lenses this method may be used to selected between them.
27  */
28 INLINE int DisplayRegion::
29 get_lens_index() const {
30  CDReader cdata(_cycler);
31  return cdata->_lens_index;
32 }
33 
34 /**
35  * Returns the number of regions, see set_num_regions.
36  */
37 INLINE int DisplayRegion::
38 get_num_regions() const {
39  CDReader cdata(_cycler);
40  return cdata->_regions.size();
41 }
42 
43 /**
44  * Sets the number of regions that this DisplayRegion indicates. Usually,
45  * this number is 1 (and it is always at least 1), and only the first is used
46  * for rendering. However, if more than one is provided, you may select which
47  * one to render into using a geometry shader (gl_ViewportIndex in GLSL).
48  */
49 INLINE void DisplayRegion::
51  nassertv(i >= 1);
52  CDWriter cdata(_cycler);
53  cdata->_regions.resize(i);
54 }
55 
56 /**
57  * Retrieves the coordinates of the DisplayRegion's rectangle within its
58  * GraphicsOutput. These numbers will be in the range [0..1].
59  */
60 INLINE void DisplayRegion::
61 get_dimensions(PN_stdfloat &l, PN_stdfloat &r, PN_stdfloat &b, PN_stdfloat &t) const {
62  get_dimensions(0, l, r, b, t);
63 }
64 
65 /**
66  * Retrieves the coordinates of the DisplayRegion's rectangle within its
67  * GraphicsOutput. These numbers will be in the range [0..1].
68  */
69 INLINE void DisplayRegion::
70 get_dimensions(int i, PN_stdfloat &l, PN_stdfloat &r, PN_stdfloat &b, PN_stdfloat &t) const {
71  CDReader cdata(_cycler);
72  const Region &region = cdata->_regions[i];
73  l = region._dimensions[0];
74  r = region._dimensions[1];
75  b = region._dimensions[2];
76  t = region._dimensions[3];
77 }
78 
79 /**
80  * Retrieves the coordinates of the DisplayRegion's rectangle within its
81  * GraphicsOutput. These numbers will be in the range [0..1].
82  */
83 INLINE LVecBase4 DisplayRegion::
84 get_dimensions(int i) const {
85  CDReader cdata(_cycler);
86  return cdata->_regions[i]._dimensions;
87 }
88 
89 /**
90  * Retrieves the x coordinate of the left edge of the rectangle within its
91  * GraphicsOutput. This number will be in the range [0..1].
92  */
93 INLINE PN_stdfloat DisplayRegion::
94 get_left(int i) const {
95  CDReader cdata(_cycler);
96  return cdata->_regions[i]._dimensions[0];
97 }
98 
99 /**
100  * Retrieves the x coordinate of the right edge of the rectangle within its
101  * GraphicsOutput. This number will be in the range [0..1].
102  */
103 INLINE PN_stdfloat DisplayRegion::
104 get_right(int i) const {
105  CDReader cdata(_cycler);
106  return cdata->_regions[i]._dimensions[1];
107 }
108 
109 /**
110  * Retrieves the y coordinate of the bottom edge of the rectangle within its
111  * GraphicsOutput. This number will be in the range [0..1].
112  */
113 INLINE PN_stdfloat DisplayRegion::
114 get_bottom(int i) const {
115  CDReader cdata(_cycler);
116  return cdata->_regions[i]._dimensions[2];
117 }
118 
119 /**
120  * Retrieves the y coordinate of the top edge of the rectangle within its
121  * GraphicsOutput. This number will be in the range [0..1].
122  */
123 INLINE PN_stdfloat DisplayRegion::
124 get_top(int i) const {
125  CDReader cdata(_cycler);
126  return cdata->_regions[i]._dimensions[3];
127 }
128 
129 /**
130  * Changes the portion of the framebuffer this DisplayRegion corresponds to.
131  * The parameters range from 0 to 1, where 0,0 is the lower left corner and
132  * 1,1 is the upper right; (0, 1, 0, 1) represents the whole screen.
133  */
134 INLINE void DisplayRegion::
135 set_dimensions(PN_stdfloat l, PN_stdfloat r, PN_stdfloat b, PN_stdfloat t) {
136  set_dimensions(0, LVecBase4(l, r, b, t));
137 }
138 
139 /**
140  * Changes the portion of the framebuffer this DisplayRegion corresponds to.
141  * The parameters range from 0 to 1, where 0,0 is the lower left corner and
142  * 1,1 is the upper right; (0, 1, 0, 1) represents the whole screen.
143  */
144 INLINE void DisplayRegion::
145 set_dimensions(int i, PN_stdfloat l, PN_stdfloat r, PN_stdfloat b, PN_stdfloat t) {
146  set_dimensions(i, LVecBase4(l, r, b, t));
147 }
148 
149 /**
150  * Changes the portion of the framebuffer this DisplayRegion corresponds to.
151  * The parameters range from 0 to 1, where 0,0 is the lower left corner and
152  * 1,1 is the upper right; (0, 1, 0, 1) represents the whole screen.
153  */
154 INLINE void DisplayRegion::
155 set_dimensions(const LVecBase4 &dimensions) {
156  set_dimensions(0, dimensions);
157 }
158 
159 /**
160  * Returns the GraphicsOutput that this DisplayRegion is ultimately associated
161  * with, or NULL if no window is associated.
162  */
163 INLINE GraphicsOutput *DisplayRegion::
164 get_window() const {
165  return _window;
166 }
167 
168 /**
169  * Returns the camera associated with this DisplayRegion, or an empty NodePath
170  * if no camera is associated.
171  */
173 get_camera(Thread *current_thread) const {
174  CDReader cdata(_cycler, current_thread);
175  return cdata->_camera;
176 }
177 
178 /**
179  * Returns the active flag associated with the DisplayRegion.
180  */
181 INLINE bool DisplayRegion::
182 is_active() const {
183  CDReader cdata(_cycler);
184  return cdata->_active;
185 }
186 
187 /**
188  * Returns the sort value associated with the DisplayRegion.
189  */
190 INLINE int DisplayRegion::
191 get_sort() const {
192  CDReader cdata(_cycler);
193  return cdata->_sort;
194 }
195 
196 /**
197  * Returns whether the DisplayRegion is specified as the left or right channel
198  * of a stereo pair, or whether it is a normal, monocular image. See
199  * set_stereo_channel().
200  */
201 INLINE Lens::StereoChannel DisplayRegion::
202 get_stereo_channel() const {
203  CDReader cdata(_cycler);
204  return cdata->_stereo_channel;
205 }
206 
207 /**
208  * Returns the current texture view offset for this DisplayRegion. This is
209  * normally set to zero. If nonzero, it is used to select a particular view
210  * of any multiview textures that are rendered within this DisplayRegion.
211  *
212  * For a StereoDisplayRegion, this is normally 0 for the left eye, and 1 for
213  * the right eye, to support stereo textures.
214  */
215 INLINE int DisplayRegion::
216 get_tex_view_offset() const {
217  CDReader cdata(_cycler);
218  return cdata->_tex_view_offset;
219 }
220 
221 /**
222  * Returns the incomplete_render flag. See set_incomplete_render().
223  */
224 INLINE bool DisplayRegion::
225 get_incomplete_render() const {
226  return _incomplete_render;
227 }
228 
229 /**
230  * Returns the priority which is assigned to asynchronous texture reload
231  * requests. See set_texture_reload_priority().
232  */
233 INLINE int DisplayRegion::
234 get_texture_reload_priority() const {
235  return _texture_reload_priority;
236 }
237 
238 /**
239  * Deprecated; replaced by set_target_tex_page().
240  */
241 INLINE void DisplayRegion::
242 set_cube_map_index(int cube_map_index) {
243  set_target_tex_page(cube_map_index);
244 }
245 
246 /**
247  * Returns the target page number associated with this particular
248  * DisplayRegion, or -1 if it is not associated with a page. See
249  * set_target_tex_page().
250  */
251 INLINE int DisplayRegion::
252 get_target_tex_page() const {
253  CDReader cdata(_cycler);
254  return cdata->_target_tex_page;
255 }
256 
257 /**
258  * Sets whether or not scissor testing is enabled for this region. The
259  * default is true, except for the overlay display region.
260  */
261 INLINE void DisplayRegion::
262 set_scissor_enabled(bool scissor_enabled) {
263  CDWriter cdata(_cycler);
264  cdata->_scissor_enabled = scissor_enabled;
265 }
266 
267 /**
268  * Returns whether or not scissor testing is enabled for this region. The
269  * default is true, except for the overlay display region.
270  */
271 INLINE bool DisplayRegion::
272 get_scissor_enabled() const {
273  CDReader cdata(_cycler);
274  return cdata->_scissor_enabled;
275 }
276 
277 /**
278  * Sets the CallbackObject that will be notified when the DisplayRegion is
279  * visited during the cull traversal. This callback will be made during the
280  * cull thread.
281  *
282  * The cull traversal is responsible for determining which nodes are visible
283  * and within the view frustum, and for accumulating state and transform, and
284  * generally building up the list of CullableObjects that are to be eventually
285  * passed to the draw traversal for rendering.
286  *
287  * At the time the cull traversal callback is made, the traversal for this
288  * DisplayRegion has not yet started.
289  *
290  * The callback is passed an instance of a DisplayRegionCullCallbackData,
291  * which contains pointers to the current scene information, as well as the
292  * current DisplayRegion and GSG. The callback *replaces* the normal cull
293  * behavior, so if your callback does nothing, the scene graph will not be
294  * traversed and therefore nothing will be drawn. If you wish the normal cull
295  * traversal to be performed for this DisplayRegion, you must call
296  * cbdata->upcall() from your callback.
297  */
298 INLINE void DisplayRegion::
300  CDWriter cdata(_cycler);
301  cdata->_cull_callback = object;
302 }
303 
304 /**
305  * Removes the callback set by an earlier call to set_cull_callback().
306  */
307 INLINE void DisplayRegion::
309  set_cull_callback(nullptr);
310 }
311 
312 /**
313  * Returns the CallbackObject set by set_cull_callback().
314  */
315 INLINE CallbackObject *DisplayRegion::
316 get_cull_callback() const {
317  CDReader cdata(_cycler);
318  return cdata->_cull_callback;
319 }
320 
321 /**
322  * Sets the CallbackObject that will be notified when the contents of
323  * DisplayRegion is drawn during the draw traversal. This callback will be
324  * made during the draw thread.
325  *
326  * The draw traversal is responsible for actually issuing the commands to the
327  * graphics engine to draw primitives. Its job is to walk through the list of
328  * CullableObjects build up by the cull traversal, as quickly as possible,
329  * issuing the appropriate commands to draw each one.
330  *
331  * At the time the draw traversal callback is made, the graphics state is in
332  * the initial state, and no projection matrix or modelview matrix is in
333  * effect. begin_scene() has not yet been called, and no objects have yet
334  * been drawn. However, the viewport has already been set to the appropriate
335  * part of the window, and the clear commands for this DisplayRegion (if any)
336  * have been issued.
337  *
338  * The callback is passed an instance of a DisplayRegionDrawCallbackData,
339  * which contains pointers to the current scene information, as well as the
340  * current DisplayRegion and GSG. The callback *replaces* the normal draw
341  * behavior, so if your callback does nothing, nothing in the DisplayRegion
342  * will be drawn. If you wish the draw traversal to continue to draw the
343  * contents of this DisplayRegion, you must call cbdata->upcall() from your
344  * callback.
345  */
346 INLINE void DisplayRegion::
348  CDWriter cdata(_cycler);
349  cdata->_draw_callback = object;
350 }
351 
352 /**
353  * Removes the callback set by an earlier call to set_draw_callback().
354  */
355 INLINE void DisplayRegion::
357  set_draw_callback(nullptr);
358 }
359 
360 /**
361  * Returns the CallbackObject set by set_draw_callback().
362  */
363 INLINE CallbackObject *DisplayRegion::
364 get_draw_callback() const {
365  CDReader cdata(_cycler);
366  return cdata->_draw_callback;
367 }
368 
369 /**
370  * Returns the width of the DisplayRegion in pixels.
371  */
372 INLINE int DisplayRegion::
373 get_pixel_width(int i) const {
374  CDReader cdata(_cycler);
375  return cdata->_regions[i]._pixels[1] - cdata->_regions[i]._pixels[0];
376 }
377 
378 /**
379  * Returns the height of the DisplayRegion in pixels.
380  */
381 INLINE int DisplayRegion::
382 get_pixel_height(int i) const {
383  CDReader cdata(_cycler);
384  return cdata->_regions[i]._pixels[3] - cdata->_regions[i]._pixels[2];
385 }
386 
387 /**
388  * Returns the size of the DisplayRegion in pixels.
389  */
390 INLINE LVecBase2i DisplayRegion::
391 get_pixel_size(int i) const {
392  CDReader cdata(_cycler);
393  return LVecBase2i(cdata->_regions[i]._pixels[1] - cdata->_regions[i]._pixels[0],
394  cdata->_regions[i]._pixels[3] - cdata->_regions[i]._pixels[2]);
395 }
396 
397 /**
398  * Retrieves the coordinates of the DisplayRegion within its window, in
399  * pixels.
400  */
401 INLINE void DisplayRegion::
402 get_pixels(int &pl, int &pr, int &pb, int &pt) const {
403  get_pixels(0, pl, pr, pb, pt);
404 }
405 
406 /**
407  * Retrieves the coordinates of the DisplayRegion within its window, in
408  * pixels.
409  */
410 INLINE void DisplayRegion::
411 get_pixels(int i, int &pl, int &pr, int &pb, int &pt) const {
412  CDReader cdata(_cycler);
413  const Region &region = cdata->_regions[i];
414  pl = region._pixels[0];
415  pr = region._pixels[1];
416  pb = region._pixels[2];
417  pt = region._pixels[3];
418 }
419 
420 /**
421  * Retrieves the coordinates of the DisplayRegion within its window, as the
422  * pixel location of its bottom-left corner, along with a pixel width and
423  * height.
424  */
425 INLINE void DisplayRegion::
426 get_region_pixels(int &xo, int &yo, int &w, int &h) const {
427  get_region_pixels(0, xo, yo, w, h);
428 }
429 
430 /**
431  * Retrieves the coordinates of the DisplayRegion within its window, as the
432  * pixel location of its bottom-left corner, along with a pixel width and
433  * height.
434  */
435 INLINE void DisplayRegion::
436 get_region_pixels(int i, int &xo, int &yo, int &w, int &h) const {
437  CDReader cdata(_cycler);
438  const Region &region = cdata->_regions[i];
439  xo = region._pixels[0];
440  yo = region._pixels[2];
441  w = region._pixels[1] - xo;
442  h = region._pixels[3] - yo;
443 }
444 
445 /**
446  * Similar to get_region_pixels(), but returns the upper left corner, and the
447  * pixel numbers are numbered from the top-left corner down, in the DirectX
448  * way of things.
449  */
450 INLINE void DisplayRegion::
451 get_region_pixels_i(int &xo, int &yo, int &w, int &h) const {
452  get_region_pixels_i(0, xo, yo, w, h);
453 }
454 
455 /**
456  * Similar to get_region_pixels(), but returns the upper left corner, and the
457  * pixel numbers are numbered from the top-left corner down, in the DirectX
458  * way of things.
459  */
460 INLINE void DisplayRegion::
461 get_region_pixels_i(int i, int &xo, int &yo, int &w, int &h) const {
462  CDReader cdata(_cycler);
463  const Region &region = cdata->_regions[i];
464  xo = region._pixels_i[0];
465  yo = region._pixels_i[3];
466  w = region._pixels_i[1] - xo;
467  h = region._pixels_i[2] - yo;
468 }
469 
470 /**
471  * Stores the result of performing a cull operation on this DisplayRegion.
472  * Normally, this will only be called by the GraphicsEngine; you should not
473  * call this directly.
474  *
475  * The stored result will automatically be applied back to all upstream
476  * pipeline stages.
477  */
478 INLINE void DisplayRegion::
479 set_cull_result(PT(CullResult) cull_result, PT(SceneSetup) scene_setup,
480  Thread *current_thread) {
481  CDCullWriter cdata(_cycler_cull, true, current_thread);
482  cdata->_cull_result = std::move(cull_result);
483  cdata->_scene_setup = std::move(scene_setup);
484 }
485 
486 /**
487  * Returns the CullResult value that was stored on this DisplayRegion,
488  * presumably by the last successful cull operation. This method is for the
489  * benefit of the GraphicsEngine; normally you shouldn't call this directly.
490  */
492 get_cull_result(Thread *current_thread) const {
493  CDCullReader cdata(_cycler_cull, current_thread);
494  return cdata->_cull_result;
495 }
496 
497 /**
498  * Returns the SceneSetup value that was stored on this DisplayRegion,
499  * presumably by the last successful cull operation. This method is for the
500  * benefit of the GraphicsEngine; normally you shouldn't call this directly.
501  */
503 get_scene_setup(Thread *current_thread) const {
504  CDCullReader cdata(_cycler_cull, current_thread);
505  return cdata->_scene_setup;
506 }
507 
508 /**
509  * Returns a PStatCollector for timing the cull operation for just this
510  * DisplayRegion.
511  */
514  return _cull_region_pcollector;
515 }
516 
517 /**
518  * Returns a PStatCollector for timing the draw operation for just this
519  * DisplayRegion.
520  */
523  return _draw_region_pcollector;
524 }
525 
526 /**
527  * Returns a unique name used for debugging.
528  */
529 INLINE const std::string &DisplayRegion::
530 get_debug_name() const {
531  return _debug_name;
532 }
533 
534 /**
535  *
536  */
537 INLINE DisplayRegion::Region::
538 Region() :
539  _dimensions(0, 1, 0, 1),
540  _pixels(0),
541  _pixels_i(0) {
542 }
543 
544 /**
545  *
546  */
547 INLINE DisplayRegion::CDataCull::
548 CDataCull() {
549 }
550 
551 /**
552  *
553  */
554 INLINE DisplayRegion::CDataCull::
555 CDataCull(const DisplayRegion::CDataCull &copy) :
556  _cull_result(copy._cull_result),
557  _scene_setup(copy._scene_setup)
558 {
559 }
560 
561 /**
562  *
563  */
564 INLINE DisplayRegionPipelineReader::
565 DisplayRegionPipelineReader(DisplayRegion *object, Thread *current_thread) :
566  _object(object),
567  _current_thread(current_thread),
568  _cdata(object->_cycler.read(current_thread))
569 {
570 #ifdef _DEBUG
571  nassertv(_object->test_ref_count_nonzero());
572 #ifdef DO_PIPELINING
573  nassertv(_cdata->test_ref_count_nonzero());
574 #endif // DO_PIPELINING
575 #endif // _DEBUG
576 }
577 
578 /**
579  *
580  */
581 INLINE DisplayRegionPipelineReader::
582 ~DisplayRegionPipelineReader() {
583 #ifdef _DEBUG
584  nassertv(_object->test_ref_count_nonzero());
585 #ifdef DO_PIPELINING
586  nassertv(_cdata->test_ref_count_nonzero());
587 #endif // DO_PIPELINING
588 #endif // _DEBUG
589  _object->_cycler.release_read(_cdata);
590 
591 #ifdef _DEBUG
592  _object = nullptr;
593  _cdata = nullptr;
594 #endif // _DEBUG
595 }
596 
597 /**
598  *
599  */
600 INLINE DisplayRegion *DisplayRegionPipelineReader::
601 get_object() const {
602  return _object;
603 }
604 
605 /**
606  *
607  */
608 INLINE Thread *DisplayRegionPipelineReader::
609 get_current_thread() const {
610  return _current_thread;
611 }
612 
613 /**
614  *
615  */
616 INLINE bool DisplayRegionPipelineReader::
617 is_any_clear_active() const {
618  return _object->is_any_clear_active();
619 }
620 
621 /**
622  * Returns the number of regions, see set_num_regions.
623  */
626  return _cdata->_regions.size();
627 }
628 
629 /**
630  * Retrieves the coordinates of the DisplayRegion's rectangle within its
631  * GraphicsOutput. These numbers will be in the range [0..1].
632  */
634 get_dimensions(PN_stdfloat &l, PN_stdfloat &r, PN_stdfloat &b, PN_stdfloat &t) const {
635  return get_dimensions(0, l, r, b, t);
636 }
637 
638 /**
639  * Retrieves the coordinates of the DisplayRegion's rectangle within its
640  * GraphicsOutput. These numbers will be in the range [0..1].
641  */
643 get_dimensions(int i, PN_stdfloat &l, PN_stdfloat &r, PN_stdfloat &b, PN_stdfloat &t) const {
644  const DisplayRegion::Region &region = _cdata->_regions[i];
645  l = region._dimensions[0];
646  r = region._dimensions[1];
647  b = region._dimensions[2];
648  t = region._dimensions[3];
649 }
650 
651 /**
652  * Retrieves the coordinates of the DisplayRegion's rectangle within its
653  * GraphicsOutput. These numbers will be in the range [0..1].
654  */
655 INLINE const LVecBase4 &DisplayRegionPipelineReader::
656 get_dimensions(int i) const {
657  return _cdata->_regions[i]._dimensions;
658 }
659 
660 /**
661  * Retrieves the x coordinate of the left edge of the rectangle within its
662  * GraphicsOutput. This number will be in the range [0..1].
663  */
664 INLINE PN_stdfloat DisplayRegionPipelineReader::
665 get_left(int i) const {
666  return _cdata->_regions[i]._dimensions[0];
667 }
668 
669 /**
670  * Retrieves the x coordinate of the right edge of the rectangle within its
671  * GraphicsOutput. This number will be in the range [0..1].
672  */
673 INLINE PN_stdfloat DisplayRegionPipelineReader::
674 get_right(int i) const {
675  return _cdata->_regions[i]._dimensions[1];
676 }
677 
678 /**
679  * Retrieves the y coordinate of the bottom edge of the rectangle within its
680  * GraphicsOutput. This number will be in the range [0..1].
681  */
682 INLINE PN_stdfloat DisplayRegionPipelineReader::
683 get_bottom(int i) const {
684  return _cdata->_regions[i]._dimensions[2];
685 }
686 
687 /**
688  * Retrieves the y coordinate of the top edge of the rectangle within its
689  * GraphicsOutput. This number will be in the range [0..1].
690  */
691 INLINE PN_stdfloat DisplayRegionPipelineReader::
692 get_top(int i) const {
693  return _cdata->_regions[i]._dimensions[3];
694 }
695 
696 /**
697  * Returns the GraphicsOutput that this DisplayRegion is ultimately associated
698  * with, or NULL if no window is associated.
699  */
701 get_window() const {
702  return _object->_window;
703 }
704 
705 /**
706  * Returns the camera associated with this DisplayRegion, or an empty NodePath
707  * if no camera is associated.
708  */
710 get_camera() const {
711  return _cdata->_camera;
712 }
713 
714 /**
715  * Returns the active flag associated with the DisplayRegion.
716  */
718 is_active() const {
719  return _cdata->_active;
720 }
721 
722 /**
723  * Returns the sort value associated with the DisplayRegion.
724  */
726 get_sort() const {
727  return _cdata->_sort;
728 }
729 
730 /**
731  * Returns whether the DisplayRegion is specified as the left or right channel
732  * of a stereo pair, or whether it is a normal, monocular image. See
733  * set_stereo_channel().
734  */
735 INLINE Lens::StereoChannel DisplayRegionPipelineReader::
737  return _cdata->_stereo_channel;
738 }
739 
740 /**
741  * Returns the current texture view offset for this DisplayRegion. This is
742  * normally set to zero. If nonzero, it is used to select a particular view
743  * of any multiview textures that are rendered within this DisplayRegion.
744  *
745  * For a StereoDisplayRegion, this is normally 0 for the left eye, and 1 for
746  * the right eye, to support stereo textures.
747  */
750  return _cdata->_tex_view_offset;
751 }
752 
753 /**
754  * Returns the target page number associated with this particular
755  * DisplayRegion, or -1 if it is not associated with a page. See
756  * set_target_tex_page().
757  */
760  return _cdata->_target_tex_page;
761 }
762 
763 /**
764  * Returns whether or not scissor testing is enabled for this region. The
765  * default is true, except for the overlay display region.
766  */
769  return _cdata->_scissor_enabled;
770 }
771 
772 /**
773  * Returns the CallbackObject set by set_draw_callback().
774  */
777  return _cdata->_draw_callback;
778 }
779 
780 /**
781  * Retrieves the coordinates of the DisplayRegion within its window, in
782  * pixels.
783  */
785 get_pixels(int &pl, int &pr, int &pb, int &pt) const {
786  get_pixels(0, pl, pr, pb, pt);
787 }
788 
789 /**
790  * Retrieves the coordinates of the DisplayRegion within its window, in
791  * pixels.
792  */
794 get_pixels(int i, int &pl, int &pr, int &pb, int &pt) const {
795  const DisplayRegion::Region &region = _cdata->_regions[i];
796  pl = region._pixels[0];
797  pr = region._pixels[1];
798  pb = region._pixels[2];
799  pt = region._pixels[3];
800 }
801 
802 /**
803  * Retrieves the coordinates of the DisplayRegion within its window, as the
804  * pixel location of its bottom-left corner, along with a pixel width and
805  * height.
806  */
808 get_region_pixels(int &xo, int &yo, int &w, int &h) const {
809  get_region_pixels(0, xo, yo, w, h);
810 }
811 
812 /**
813  * Retrieves the coordinates of the DisplayRegion within its window, as the
814  * pixel location of its bottom-left corner, along with a pixel width and
815  * height.
816  */
818 get_region_pixels(int i, int &xo, int &yo, int &w, int &h) const {
819  const DisplayRegion::Region &region = _cdata->_regions[i];
820  xo = region._pixels[0];
821  yo = region._pixels[2];
822  w = region._pixels[1] - xo;
823  h = region._pixels[3] - yo;
824 }
825 
826 /**
827  * Similar to get_region_pixels(), but returns the upper left corner, and the
828  * pixel numbers are numbered from the top-left corner down, in the DirectX
829  * way of things.
830  */
832 get_region_pixels_i(int &xo, int &yo, int &w, int &h) const {
833  get_region_pixels_i(0, xo, yo, w, h);
834 }
835 
836 /**
837  * Similar to get_region_pixels(), but returns the upper left corner, and the
838  * pixel numbers are numbered from the top-left corner down, in the DirectX
839  * way of things.
840  */
842 get_region_pixels_i(int i, int &xo, int &yo, int &w, int &h) const {
843  const DisplayRegion::Region &region = _cdata->_regions[i];
844  xo = region._pixels_i[0];
845  yo = region._pixels_i[3];
846  w = region._pixels_i[1] - xo;
847  h = region._pixels_i[2] - yo;
848 }
849 
850 /**
851  * Returns the width of the DisplayRegion in pixels.
852  */
854 get_pixel_width(int i) const {
855  return _cdata->_regions[i]._pixels[1] - _cdata->_regions[i]._pixels[0];
856 }
857 
858 /**
859  * Gets the index into a lens_node lens array. 0 default
860  */
862 get_lens_index() const {
863  return _cdata->_lens_index;
864 }
865 
866 /**
867  * Returns the height of the DisplayRegion in pixels.
868  */
870 get_pixel_height(int i) const {
871  return _cdata->_regions[i]._pixels[3] - _cdata->_regions[i]._pixels[2];
872 }
873 
874 INLINE std::ostream &
875 operator << (std::ostream &out, const DisplayRegion &dr) {
876  dr.output(out);
877  return out;
878 }
int get_num_regions() const
Returns the number of regions, see set_num_regions.
Definition: displayRegion.I:38
set_draw_callback
Sets the CallbackObject that will be notified when the contents of DisplayRegion is drawn during the ...
Lens::StereoChannel get_stereo_channel() const
Returns whether the DisplayRegion is specified as the left or right channel of a stereo pair,...
void set_num_regions(int i)
Sets the number of regions that this DisplayRegion indicates.
Definition: displayRegion.I:50
void set_cull_result(PT(CullResult) cull_result, PT(SceneSetup) scene_setup, Thread *current_thread)
Stores the result of performing a cull operation on this DisplayRegion.
PN_stdfloat get_right(int i=0) const
Retrieves the x coordinate of the right edge of the rectangle within its GraphicsOutput.
PN_stdfloat get_left(int i=0) const
Retrieves the x coordinate of the left edge of the rectangle within its GraphicsOutput.
bool test_ref_count_nonzero() const
Does some easy checks to make sure that the reference count isn't zero, or completely bogus.
void get_region_pixels_i(int &xo, int &yo, int &w, int &h) const
Similar to get_region_pixels(), but returns the upper left corner, and the pixel numbers are numbered...
GraphicsOutput * get_window() const
Returns the GraphicsOutput that this DisplayRegion is ultimately associated with, or NULL if no windo...
void get_region_pixels(int &xo, int &yo, int &w, int &h) const
Retrieves the coordinates of the DisplayRegion within its window, as the pixel location of its bottom...
bool operator<(const DisplayRegion &other) const
Returns true if this DisplayRegion should be sorted before the other one, false otherwise.
Definition: displayRegion.I:19
void clear_cull_callback()
Removes the callback set by an earlier call to set_cull_callback().
PN_stdfloat get_bottom(int i=0) const
Retrieves the y coordinate of the bottom edge of the rectangle within its GraphicsOutput.
get_pixel_size
Returns the size of the DisplayRegion in pixels.
PN_stdfloat get_top(int i=0) const
Retrieves the y coordinate of the top edge of the rectangle within its GraphicsOutput.
SceneSetup * get_scene_setup(Thread *current_thread) const
Returns the SceneSetup value that was stored on this DisplayRegion, presumably by the last successful...
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
PStatCollector & get_cull_region_pcollector()
Returns a PStatCollector for timing the cull operation for just this DisplayRegion.
NodePath get_camera() const
Returns the camera associated with this DisplayRegion, or an empty NodePath if no camera is associate...
set_cull_callback
Sets the CallbackObject that will be notified when the DisplayRegion is visited during the cull trave...
int get_sort() const
Returns the sort value associated with the DisplayRegion.
A lightweight class that represents a single element that may be timed and/or counted via stats.
CullResult * get_cull_result(Thread *current_thread) const
Returns the CullResult value that was stored on this DisplayRegion, presumably by the last successful...
void get_region_pixels(int &xo, int &yo, int &w, int &h) const
Retrieves the coordinates of the DisplayRegion within its window, as the pixel location of its bottom...
int get_pixel_width(int i=0) const
Returns the width of the DisplayRegion in pixels.
int get_pixel_height(int i=0) const
Returns the height of the DisplayRegion in pixels.
get_camera
Returns the camera associated with this DisplayRegion, or an empty NodePath if no camera is associate...
Definition: displayRegion.h:94
void get_dimensions(PN_stdfloat &l, PN_stdfloat &r, PN_stdfloat &b, PN_stdfloat &t) const
Retrieves the coordinates of the DisplayRegion's rectangle within its GraphicsOutput.
PStatCollector & get_draw_region_pcollector()
Returns a PStatCollector for timing the draw operation for just this DisplayRegion.
int get_target_tex_page() const
Returns the target page number associated with this particular DisplayRegion, or -1 if it is not asso...
void get_region_pixels_i(int &xo, int &yo, int &w, int &h) const
Similar to get_region_pixels(), but returns the upper left corner, and the pixel numbers are numbered...
void clear_draw_callback()
Removes the callback set by an earlier call to set_draw_callback().
int get_tex_view_offset()
Returns the current texture view offset for this DisplayRegion.
int get_pixel_width(int i=0) const
Returns the width of the DisplayRegion in pixels.
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
This is a base class for the various different classes that represent the result of a frame of render...
int get_num_regions() const
Returns the number of regions, see set_num_regions.
set_target_tex_page
This is a special parameter that is only used when rendering the faces of a cube map or multipage and...
bool get_scissor_enabled() const
Returns whether or not scissor testing is enabled for this region.
This is a generic object that can be assigned to a callback at various points in the rendering proces...
void set_cube_map_index(int cube_map_index)
Deprecated; replaced by set_target_tex_page().
This stores the result of a BinCullHandler traversal: an ordered collection of CullBins,...
Definition: cullResult.h:44
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,...
PN_stdfloat get_left(int i=0) const
Retrieves the x coordinate of the left edge of the rectangle within its GraphicsOutput.
Definition: displayRegion.I:94
A thread; that is, a lightweight process.
Definition: thread.h:46
CallbackObject * get_draw_callback() const
Returns the CallbackObject set by set_draw_callback().
get_dimensions
Retrieves the coordinates of the DisplayRegion's rectangle within its GraphicsOutput.
Definition: displayRegion.h:83
PN_stdfloat get_bottom(int i=0) const
Retrieves the y coordinate of the bottom edge of the rectangle within its GraphicsOutput.
PN_stdfloat get_top(int i=0) const
Retrieves the y coordinate of the top edge of the rectangle within its GraphicsOutput.
const std::string & get_debug_name() const
Returns a unique name used for debugging.
A rectangular subregion within a window for rendering into.
Definition: displayRegion.h:57
int get_pixel_height(int i=0) const
Returns the height of the DisplayRegion in pixels.
set_scissor_enabled
Sets whether or not scissor testing is enabled for this region.
void get_pixels(int &pl, int &pr, int &pb, int &pt) const
Retrieves the coordinates of the DisplayRegion within its window, in pixels.
PN_stdfloat get_right(int i=0) const
Retrieves the x coordinate of the right edge of the rectangle within its GraphicsOutput.
get_sort
Returns the sort value associated with the DisplayRegion.
set_dimensions
Changes the portion of the framebuffer this DisplayRegion corresponds to.
Definition: displayRegion.h:83
This object holds the camera position, etc., and other general setup information for rendering a part...
Definition: sceneSetup.h:32
int get_lens_index() const
Gets the index into a lens_node lens array.
void release_read(const CycleData *pointer) const
Releases a pointer previously obtained via a call to read().
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:161
void get_pixels(int &pl, int &pr, int &pb, int &pt) const
Retrieves the coordinates of the DisplayRegion within its window, in pixels.
bool is_active() const
Returns the active flag associated with the DisplayRegion.