Panda3D

graphicsOutput.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 graphicsOutput.I
10 * @author drose
11 * @date 2004-02-06
12 */
13
14 /**
15 * Returns the GSG that is associated with this window. There is a one-to-one
16 * association between windows and GSG's.
17 *
18 * This may return NULL if the graphics context has not yet been created for
19 * the window, e.g. before the first frame has rendered; or after the window
20 * has been closed.
21 */
22 INLINE GraphicsStateGuardian *GraphicsOutput::
23 get_gsg() const {
24 return _gsg;
25 }
26
27 /**
28 * Returns the GraphicsPipe that this window is associated with. It is
29 * possible that the GraphicsPipe might have been deleted while an outstanding
30 * PT(GraphicsOutput) prevented all of its children windows from also being
31 * deleted; in this unlikely case, get_pipe() may return NULL.
32 */
33 INLINE GraphicsPipe *GraphicsOutput::
34 get_pipe() const {
35 return _pipe;
36 }
37
38 /**
39 * Returns the graphics engine that created this output. Since there is
40 * normally only one GraphicsEngine object in an application, this is usually
41 * the same as the global GraphicsEngine.
42 */
43 INLINE GraphicsEngine *GraphicsOutput::
44 get_engine() const {
45 return _engine;
46 }
47
48 /**
49 * Returns the name that was passed to the GraphicsOutput constructor.
50 */
51 INLINE const std::string &GraphicsOutput::
52 get_name() const {
53 return _name;
54 }
55
56 /**
57 * If the GraphicsOutput is set to render into a texture, returns the number
58 * of textures that are being rendered into. Normally, the textures would be
59 * associated with different buffers - a color texture, a depth texture, and a
60 * stencil texture.
61 */
62 INLINE int GraphicsOutput::
63 count_textures() const {
64 CDReader cdata(_cycler);
65 return cdata->_textures.size();
66 }
67
68 /**
69 * Returns true if the GraphicsOutput is rendering into any textures at all.
70 */
71 INLINE bool GraphicsOutput::
72 has_texture() const {
73 CDReader cdata(_cycler);
74 return (cdata->_textures.size() > 0);
75 }
76
77 /**
78 * Returns the nth texture into which the GraphicsOutput renders. Returns
79 * NULL if there is no such texture.
80 *
81 * If the texture is non-NULL, it may be applied to geometry to be rendered
82 * for any other windows or outputs that share the same GSG as this
83 * GraphicsOutput. The effect is undefined for windows that share a different
84 * GSG; usually in these cases the texture will be invalid.
85 */
86 INLINE Texture *GraphicsOutput::
87 get_texture(int i) const {
88 CDReader cdata(_cycler);
89 if ((i < 0) || (i >= ((int)cdata->_textures.size()))) {
90 return nullptr;
91 }
92 return cdata->_textures[i]._texture;
93 }
94
95 /**
96 * Returns the RenderTexturePlane associated with the nth render-texture.
97 * Returns 0 if there is no such texture.
98 */
99 INLINE GraphicsOutput::RenderTexturePlane GraphicsOutput::
100 get_texture_plane(int i) const {
101 CDReader cdata(_cycler);
102 if ((i < 0) || (i >= ((int)cdata->_textures.size()))) {
103 return (RenderTexturePlane)0;
104 }
105 return cdata->_textures[i]._plane;
106 }
107
108 /**
109 * Returns the RenderTextureMode associated with the nth render-texture.
110 * Returns RTM_none if there is no such texture.
111 */
112 INLINE GraphicsOutput::RenderTextureMode GraphicsOutput::
113 get_rtm_mode(int i) const {
114 CDReader cdata(_cycler);
115 if ((i < 0) || (i >= ((int)cdata->_textures.size()))) {
116 return RTM_none;
117 }
118 return cdata->_textures[i]._rtm_mode;
119 }
120
121 /**
122 * Returns the visible size of the window or buffer, if it is known. In
123 * certain cases (e.g. fullscreen windows), the size may not be known until
124 * after the object has been fully created. Check has_size() first.
125 *
126 * Certain objects (like windows) may change size spontaneously; this method
127 * is not thread-safe. To get the size of a window in a thread-safe manner,
128 * query get_properties().
129 */
130 INLINE const LVecBase2i &GraphicsOutput::
131 get_size() const {
132 return _size;
133 }
134
135 /**
136 * Returns the visible width of the window or buffer, if it is known. In
137 * certain cases (e.g. fullscreen windows), the size may not be known until
138 * after the object has been fully created. Check has_size() first.
139 *
140 * Certain objects (like windows) may change size spontaneously; this method
141 * is not thread-safe. To get the size of a window in a thread-safe manner,
142 * query get_properties().
143 */
144 INLINE int GraphicsOutput::
145 get_x_size() const {
146 return _size.get_x();
147 }
148
149 /**
150 * Returns the visible height of the window or buffer, if it is known. In
151 * certain cases (e.g. fullscreen windows), the size may not be known until
152 * after the object has been fully created. Check has_size() first.
153 *
154 * Certain objects (like windows) may change size spontaneously; this method
155 * is not thread-safe. To get the size of a window in a thread-safe manner,
156 * query get_properties().
157 */
158 INLINE int GraphicsOutput::
159 get_y_size() const {
160 return _size.get_y();
161 }
162
163 /**
164 * Returns the internal size of the window or buffer. This is almost always
165 * the same as get_size(), except when a pixel_zoom is in effect--see
166 * set_pixel_zoom().
167 */
168 INLINE LVecBase2i GraphicsOutput::
169 get_fb_size() const {
170 return LVecBase2i(std::max(int(_size.get_x() * get_pixel_factor()), 1),
171 std::max(int(_size.get_y() * get_pixel_factor()), 1));
172 }
173
174 /**
175 * Returns the internal width of the window or buffer. This is almost always
176 * the same as get_x_size(), except when a pixel_zoom is in effect--see
177 * set_pixel_zoom().
178 */
179 INLINE int GraphicsOutput::
180 get_fb_x_size() const {
181 return std::max(int(_size.get_x() * get_pixel_factor()), 1);
182 }
183
184 /**
185 * Returns the internal height of the window or buffer. This is almost always
186 * the same as get_y_size(), except when a pixel_zoom is in effect--see
187 * set_pixel_zoom().
188 */
189 INLINE int GraphicsOutput::
190 get_fb_y_size() const {
191 return std::max(int(_size.get_y() * get_pixel_factor()), 1);
192 }
193
194 /**
195 * If side-by-side stereo is enabled, this returns the pixel size of the left
196 * eye, based on scaling get_size() by get_sbs_left_dimensions(). If side-by-
197 * side stereo is not enabled, this returns the same as get_size().
198 */
199 INLINE LVecBase2i GraphicsOutput::
200 get_sbs_left_size() const {
201 PN_stdfloat left_w = _sbs_left_dimensions[1] - _sbs_left_dimensions[0];
202 PN_stdfloat left_h = _sbs_left_dimensions[3] - _sbs_left_dimensions[2];
203 return LVecBase2i(std::max(int(_size.get_x() * left_w), 1),
204 std::max(int(_size.get_y() * left_h), 1));
205 }
206
207 /**
208 * If side-by-side stereo is enabled, this returns the pixel width of the left
209 * eye, based on scaling get_x_size() by get_sbs_left_dimensions(). If side-
210 * by-side stereo is not enabled, this returns the same as get_x_size().
211 */
212 INLINE int GraphicsOutput::
213 get_sbs_left_x_size() const {
214 PN_stdfloat left_w = _sbs_left_dimensions[1] - _sbs_left_dimensions[0];
215 return std::max(int(_size.get_x() * left_w), 1);
216 }
217
218 /**
219 * If side-by-side stereo is enabled, this returns the pixel height of the
220 * left eye, based on scaling get_y_size() by get_sbs_left_dimensions(). If
221 * side-by-side stereo is not enabled, this returns the same as get_y_size().
222 */
223 INLINE int GraphicsOutput::
224 get_sbs_left_y_size() const {
225 PN_stdfloat left_h = _sbs_left_dimensions[3] - _sbs_left_dimensions[2];
226 return std::max(int(_size.get_y() * left_h), 1);
227 }
228
229 /**
230 * If side-by-side stereo is enabled, this returns the pixel size of the right
231 * eye, based on scaling get_size() by get_sbs_right_dimensions(). If side-
232 * by-side stereo is not enabled, this returns the same as get_size().
233 */
234 INLINE LVecBase2i GraphicsOutput::
235 get_sbs_right_size() const {
236 PN_stdfloat right_w = _sbs_right_dimensions[1] - _sbs_right_dimensions[0];
237 PN_stdfloat right_h = _sbs_right_dimensions[3] - _sbs_right_dimensions[2];
238 return LVecBase2i(std::max(int(_size.get_x() * right_w), 1),
239 std::max(int(_size.get_y() * right_h), 1));
240 }
241
242 /**
243 * If side-by-side stereo is enabled, this returns the pixel width of the
244 * right eye, based on scaling get_x_size() by get_sbs_right_dimensions(). If
245 * side-by-side stereo is not enabled, this returns the same as get_x_size().
246 */
247 INLINE int GraphicsOutput::
248 get_sbs_right_x_size() const {
249 PN_stdfloat right_w = _sbs_right_dimensions[1] - _sbs_right_dimensions[0];
250 return std::max(int(_size.get_x() * right_w), 1);
251 }
252
253 /**
254 * If side-by-side stereo is enabled, this returns the pixel height of the
255 * right eye, based on scaling get_y_size() by get_sbs_right_dimensions(). If
256 * side-by-side stereo is not enabled, this returns the same as get_y_size().
257 */
258 INLINE int GraphicsOutput::
259 get_sbs_right_y_size() const {
260 PN_stdfloat right_h = _sbs_right_dimensions[3] - _sbs_right_dimensions[2];
261 return std::max(int(_size.get_y() * right_h), 1);
262 }
263
264 /**
265 * Returns true if the size of the window/frame buffer is known, false
266 * otherwise. In certain cases the size may not be known until after the
267 * object has been fully created. Also, certain objects (like windows) may
268 * change size spontaneously.
269 */
270 INLINE bool GraphicsOutput::
271 has_size() const {
272 return _has_size;
273 }
274
275 /**
276 * Returns true if the output is fully created and ready for rendering, false
277 * otherwise.
278 */
279 INLINE bool GraphicsOutput::
280 is_valid() const {
281 return _is_valid && _is_nonzero_size;
282 }
283
284 /**
285 * Returns true if the output has a nonzero size in both X and Y, or false if
286 * it is zero (and therefore invalid).
287 */
288 INLINE bool GraphicsOutput::
289 is_nonzero_size() const {
290 return _is_nonzero_size;
291 }
292
293 /**
294 * Returns the current setting of the inverted flag. When this is true, the
295 * scene is rendered into the window upside-down, flipped like a mirror along
296 * the X axis. See set_inverted().
297 */
298 INLINE bool GraphicsOutput::
299 get_inverted() const {
300 return _inverted;
301 }
302
303 /**
304 * Changes the "swap eyes" flag. This flag is normally false. When it is
305 * true, the left and right channels of a stereo DisplayRegion are sent to the
306 * opposite channels in the rendering backend. This is meant to work around
307 * hardware that inadvertently swaps the output channels, or hardware for
308 * which it cannot be determined which channel is which until runtime.
309 */
310 INLINE void GraphicsOutput::
311 set_swap_eyes(bool swap_eyes) {
312 _swap_eyes = swap_eyes;
313 }
314
315 /**
316 * Returns the current setting of the "swap eyes" flag. See set_swap_eyes().
317 */
318 INLINE bool GraphicsOutput::
319 get_swap_eyes() const {
320 return _swap_eyes;
321 }
322
323 /**
324 * Enables red-blue stereo mode on this particular window. When red-blue
325 * stereo mode is in effect, DisplayRegions that have the "left" channel set
326 * will render in the red (or specified) channel only, while DisplayRegions
327 * that have the "right" channel set will render in the blue (or specified)
328 * channel only.
329 *
330 * The remaining two parameters specify the particular color channel(s) to
331 * associate with each eye. Use the bits defined in
332 * ColorWriteAttrib::Channels.
333 *
334 * This can be used to achieve a cheesy stereo mode in the absence of
335 * hardware-supported stereo.
336 */
337 INLINE void GraphicsOutput::
338 set_red_blue_stereo(bool red_blue_stereo,
339 unsigned int left_eye_color_mask,
340 unsigned int right_eye_color_mask) {
341 _red_blue_stereo = red_blue_stereo;
342 if (_red_blue_stereo) {
343 _left_eye_color_mask = left_eye_color_mask;
344 _right_eye_color_mask = right_eye_color_mask;
345 } else {
346 _left_eye_color_mask = 0x0f;
347 _right_eye_color_mask = 0x0f;
348 }
349 }
350
351 /**
352 * Returns whether red-blue stereo mode is in effect for this particular
353 * window. See set_red_blue_stereo().
354 */
355 INLINE bool GraphicsOutput::
356 get_red_blue_stereo() const {
357 return _red_blue_stereo;
358 }
359
360 /**
361 * Returns the color mask in effect when rendering a left-eye view in red_blue
362 * stereo mode. This is one or more bits defined in
363 * ColorWriteAttrib::Channels. See set_red_blue_stereo().
364 */
365 INLINE unsigned int GraphicsOutput::
366 get_left_eye_color_mask() const {
367 return _left_eye_color_mask;
368 }
369
370 /**
371 * Returns the color mask in effect when rendering a right-eye view in
372 * red_blue stereo mode. This is one or more bits defined in
373 * ColorWriteAttrib::Channels. See set_red_blue_stereo().
374 */
375 INLINE unsigned int GraphicsOutput::
376 get_right_eye_color_mask() const {
377 return _right_eye_color_mask;
378 }
379
380 /**
381 * Returns whether side-by-side stereo mode is in effect for this particular
382 * window. See set_side_by_side_stereo().
383 */
384 INLINE bool GraphicsOutput::
385 get_side_by_side_stereo() const {
386 return _side_by_side_stereo;
387 }
388
389 /**
390 * Returns the effective sub-region of the window for displaying the left
391 * channel, if side-by-side stereo mode is in effect for the window. See
392 * set_side_by_side_stereo().
393 */
394 INLINE const LVecBase4 &GraphicsOutput::
395 get_sbs_left_dimensions() const {
396 return _sbs_left_dimensions;
397 }
398
399 /**
400 * Returns the effective sub-region of the window for displaying the right
401 * channel, if side-by-side stereo mode is in effect for the window. See
402 * set_side_by_side_stereo().
403 */
404 INLINE const LVecBase4 &GraphicsOutput::
405 get_sbs_right_dimensions() const {
406 return _sbs_right_dimensions;
407 }
408
409 /**
410 * Returns the framebuffer properties of the window.
411 */
412 INLINE const FrameBufferProperties &GraphicsOutput::
413 get_fb_properties() const {
414 return _fb_properties;
415 }
416
417 /**
418 * Returns Returns true if this window can render stereo DisplayRegions,
419 * either through red-blue stereo (see set_red_blue_stereo()) or through true
420 * hardware stereo rendering.
421 */
422 INLINE bool GraphicsOutput::
423 is_stereo() const {
424 return _red_blue_stereo || _side_by_side_stereo || _fb_properties.is_stereo();
425 }
426
427 /**
428 * Resets the delete flag, so the GraphicsOutput will not be automatically
429 * deleted before the beginning of the next frame.
430 */
431 INLINE void GraphicsOutput::
432 clear_delete_flag() {
433 _delete_flag = false;
434 }
435
436 /**
437 * Returns the sorting order of this particular GraphicsOutput. The various
438 * GraphicsOutputs within a particular thread will be rendered in the
439 * indicated order.
440 */
441 INLINE int GraphicsOutput::
442 get_sort() const {
443 return _sort;
444 }
445
446 /**
447 * Specifies the sort value of future offscreen buffers created by
448 * make_texture_sort().
449 *
450 * The purpose of this method is to allow the user to limit the sort value
451 * chosen for a buffer created via make_texture_buffer(). Normally, this
452 * buffer will be assigned a value of get_sort() - 1, so that it will be
453 * rendered before this window is rendered; but sometimes this isn't
454 * sufficiently early, especially if other buffers also have a view into the
455 * same scene.
456 *
457 * If you specify a value here, then new buffers created via
458 * make_texture_buffer() will be given that sort value instead of get_sort() -
459 * 1.
460 */
461 INLINE void GraphicsOutput::
462 set_child_sort(int child_sort) {
463 _child_sort = child_sort;
464 _got_child_sort = true;
465 }
466
467 /**
468 * Resets the sort value of future offscreen buffers created by
469 * make_texture_sort() to the default value. See set_child_sort().
470 */
471 INLINE void GraphicsOutput::
472 clear_child_sort() {
473 _got_child_sort = false;
474 }
475
476 /**
477 * Returns the sort value of future offscreen buffers created by
478 * make_texture_sort(). See set_child_sort().
479 */
480 INLINE int GraphicsOutput::
481 get_child_sort() const {
482 if (_got_child_sort) {
483 return _child_sort;
484 } else {
485 return get_sort() - 1;
486 }
487 }
488
489 /**
490 * When the GraphicsOutput is in triggered copy mode, this function triggers
491 * the copy (at the end of the next frame).
492 * @returns a future that can be awaited.
493 */
494 INLINE AsyncFuture *GraphicsOutput::
495 trigger_copy() {
496 AsyncFuture *future = _trigger_copy;
497 if (future == nullptr) {
498 future = new AsyncFuture;
499 _trigger_copy = future;
500 }
501 return future;
502 }
503
504 /**
505 * Creates a new DisplayRegion that covers the entire window.
506 *
507 * If is_stereo() is true for this window, and default-stereo-camera is
508 * configured true, this actually makes a StereoDisplayRegion. Call
509 * make_mono_display_region() or make_stereo_display_region() if you want to
510 * insist on one or the other.
511 */
512 INLINE DisplayRegion *GraphicsOutput::
513 make_display_region() {
514 return make_display_region(0.0f, 1.0f, 0.0f, 1.0f);
515 }
516
517 /**
518 * Creates a new DisplayRegion that covers the indicated sub-rectangle within
519 * the window. The range on all parameters is 0..1.
520 *
521 * If is_stereo() is true for this window, and default-stereo-camera is
522 * configured true, this actually makes a StereoDisplayRegion. Call
523 * make_mono_display_region() or make_stereo_display_region() if you want to
524 * insist on one or the other.
525 */
526 DisplayRegion *GraphicsOutput::
527 make_display_region(PN_stdfloat l, PN_stdfloat r, PN_stdfloat b, PN_stdfloat t) {
528 return make_display_region(LVecBase4(l, r, b, t));
529 }
530
531 /**
532 * Creates a new DisplayRegion that covers the entire window.
533 *
534 * This generally returns a mono DisplayRegion, even if is_stereo() is true.
535 * However, if side-by-side stereo is enabled, this will return a
536 * StereoDisplayRegion whose two eyes are both set to SC_mono. (This is
537 * necessary because in side-by-side stereo mode, it is necessary to draw even
538 * mono DisplayRegions twice).
539 */
540 INLINE DisplayRegion *GraphicsOutput::
541 make_mono_display_region() {
542 return make_mono_display_region(0.0f, 1.0f, 0.0f, 1.0f);
543 }
544
545 /**
546 * Creates a new DisplayRegion that covers the entire window.
547 *
548 * This generally returns a mono DisplayRegion, even if is_stereo() is true.
549 * However, if side-by-side stereo is enabled, this will return a
550 * StereoDisplayRegion whose two eyes are both set to SC_mono. (This is
551 * necessary because in side-by-side stereo mode, it is necessary to draw even
552 * mono DisplayRegions twice).
553 */
554 INLINE DisplayRegion *GraphicsOutput::
555 make_mono_display_region(PN_stdfloat l, PN_stdfloat r, PN_stdfloat b, PN_stdfloat t) {
556 return make_mono_display_region(LVecBase4(l, r, b, t));
557 }
558
559 /**
560 * Creates a new DisplayRegion that covers the entire window.
561 *
562 * This always returns a stereo DisplayRegion, even if is_stereo() is false.
563 */
564 INLINE StereoDisplayRegion *GraphicsOutput::
565 make_stereo_display_region() {
566 return make_stereo_display_region(0.0f, 1.0f, 0.0f, 1.0f);
567 }
568
569 /**
570 * Creates a new DisplayRegion that covers the entire window.
571 *
572 * This always returns a stereo DisplayRegion, even if is_stereo() is false.
573 */
574 INLINE StereoDisplayRegion *GraphicsOutput::
575 make_stereo_display_region(PN_stdfloat l, PN_stdfloat r, PN_stdfloat b, PN_stdfloat t) {
576 return make_stereo_display_region(LVecBase4(l, r, b, t));
577 }
578
579 /**
580 * Returns the special "overlay" DisplayRegion that is created for each window
581 * or buffer. This DisplayRegion covers the entire window, but cannot be used
582 * for rendering. It is a placeholder only, to indicate the dimensions of the
583 * window, and is usually used internally for purposes such as clearing the
584 * window, or grabbing a screenshot of the window.
585 *
586 * There are very few applications that require access to this DisplayRegion.
587 * Normally, you should create your own DisplayRegion that covers the window,
588 * if you want to render to the window.
589 */
590 INLINE DisplayRegion *GraphicsOutput::
591 get_overlay_display_region() const {
592 return _overlay_display_region;
593 }
594
595 /**
596 * Saves a screenshot of the region to a default filename, and returns the
597 * filename, or empty string if the screenshot failed. The default filename
598 * is generated from the supplied prefix and from the Config variable
599 * screenshot-filename, which contains the following strings:
600 *
601 * %~p - the supplied prefix %~f - the frame count %~e - the value of
602 * screenshot-extension All other % strings in strftime().
603 */
604 INLINE Filename GraphicsOutput::
605 make_screenshot_filename(const std::string &prefix) {
606 return DisplayRegion::make_screenshot_filename(prefix);
607 }
608
609 /**
610 * Saves a screenshot of the region to a default filename, and returns the
611 * filename, or empty string if the screenshot failed. The filename is
612 * generated by make_screenshot_filename().
613 */
614 INLINE Filename GraphicsOutput::
615 save_screenshot_default(const std::string &prefix) {
616 return _overlay_display_region->save_screenshot_default(prefix);
617 }
618
619 /**
620 * Saves a screenshot of the region to the indicated filename. The image
621 * comment is an optional user readable string that will be saved with the
622 * header of the image (if the file format supports embedded data; for example
623 * jpg allows comments). Returns true on success, false on failure.
624 */
625 INLINE bool GraphicsOutput::
626 save_screenshot(const Filename &filename, const std::string &image_comment) {
627 return _overlay_display_region->save_screenshot(filename, image_comment);
628 }
629
630 /**
631 * Captures the most-recently rendered image from the framebuffer into the
632 * indicated PNMImage. Returns true on success, false on failure.
633 */
634 INLINE bool GraphicsOutput::
635 get_screenshot(PNMImage &image) {
636 return _overlay_display_region->get_screenshot(image);
637 }
638
639 /**
640 * Captures the most-recently rendered image from the framebuffer and returns
641 * it as Texture, or NULL on failure.
642 */
643 INLINE PT(Texture) GraphicsOutput::
644 get_screenshot() {
645 return _overlay_display_region->get_screenshot();
646 }
647
648 /**
649 * The sorting operator is used to order the GraphicsOutput object in order by
650 * their sort number, so that they will render in the correct order in the
651 * GraphicsEngine.
652 */
653 INLINE bool GraphicsOutput::
654 operator < (const GraphicsOutput &other) const {
655 if (_sort != other._sort) {
656 return _sort < other._sort;
657 }
658 return _internal_sort_index < other._internal_sort_index;
659 }
660
661
662 /**
663 * Recomputes the list of active DisplayRegions within the window, if they
664 * have changed recently.
665 */
666 INLINE void GraphicsOutput::
667 determine_display_regions() const {
668 // This function isn't strictly speaking const, but we pretend it is because
669 // it only updates a transparent cache value.
670 CDLockedReader cdata(_cycler);
671 if (cdata->_active_display_regions_stale) {
672 CDWriter cdataw(((GraphicsOutput *)this)->_cycler, cdata, false);
673 ((GraphicsOutput *)this)->do_determine_display_regions(cdataw);
674 }
675 }
676
677 /**
678 * Intended to be called when the active state on a nested display region
679 * changes, forcing the window to recompute its list of active display
680 * regions.
681 */
682 INLINE void GraphicsOutput::
683 win_display_regions_changed() {
684 CDWriter cdata(_cycler, true);
685 cdata->_active_display_regions_stale = true;
686 }
687
688 /**
689 * Returns a PStatCollector for timing the cull operation for just this
690 * GraphicsOutput.
691 */
692 INLINE PStatCollector &GraphicsOutput::
693 get_cull_window_pcollector() {
694 return _cull_window_pcollector;
695 }
696
697 /**
698 * Returns a PStatCollector for timing the draw operation for just this
699 * GraphicsOutput.
700 */
701 INLINE PStatCollector &GraphicsOutput::
702 get_draw_window_pcollector() {
703 return _draw_window_pcollector;
704 }
705
706 /**
707 * Returns a PStatCollector for timing the clear operation for just this
708 * GraphicsOutput.
709 */
710 INLINE PStatCollector &GraphicsOutput::
711 get_clear_window_pcollector() {
712 return _clear_window_pcollector;
713 }
714
715 /**
716 * Display the spam message associated with begin_frame
717 */
718 INLINE void GraphicsOutput::
719 begin_frame_spam(FrameMode mode) {
720 if (display_cat.is_spam()) {
721 display_cat.spam()
722 << "begin_frame(" << mode << "): " << get_type() << " "
723 << get_name() << " " << (void *)this << "\n";
724 }
725 }
726
727 /**
728 * Display the spam message associated with end_frame
729 */
730 INLINE void GraphicsOutput::
731 end_frame_spam(FrameMode mode) {
732 if (display_cat.is_spam()) {
733 display_cat.spam()
734 << "end_frame(" << mode << "): " << get_type() << " "
735 << get_name() << " " << (void *)this << "\n";
736 }
737 }
738
739 /**
740 * Clear the variables that select a cube-map face (or other multipage texture
741 * face).
742 */
743 INLINE void GraphicsOutput::
744 clear_cube_map_selection() {
745 _target_tex_page = -1;
746 _prev_page_dr = nullptr;
747 }
748
749 /**
750 * To be called at the end of the frame, after the window has successfully
751 * been drawn and is ready to be flipped (if appropriate).
752 */
753 INLINE void GraphicsOutput::
754 trigger_flip() {
755 if (!_fb_properties.is_single_buffered()) {
756 _flip_ready = true;
757 }
758 }
AsyncFuture
This class represents a thread-safe handle to a promised future result of an asynchronous operation,...
Definition: asyncFuture.h:61
CycleDataReader
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
Definition: cycleDataReader.h:35
DisplayRegion
A rectangular subregion within a window for rendering into.
Definition: displayRegion.h:57
DisplayRegion::make_screenshot_filename
static Filename make_screenshot_filename(const std::string &prefix="screenshot")
Synthesizes a suitable default filename for passing to save_screenshot().
Definition: displayRegion.cxx:360
DrawableRegion::get_pixel_factor
get_pixel_factor
Returns the amount by which the height and width of the region will be scaled internally,...
Definition: drawableRegion.h:97
Filename
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:39
FrameBufferProperties
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
Definition: frameBufferProperties.h:26
GraphicsEngine
This class is the main interface to controlling the render process.
Definition: graphicsEngine.h:53
GraphicsOutput
This is a base class for the various different classes that represent the result of a frame of render...
Definition: graphicsOutput.h:63
GraphicsOutput::set_swap_eyes
set_swap_eyes
Changes the "swap eyes" flag.
Definition: graphicsOutput.h:167
GraphicsOutput::has_texture
bool has_texture() const
Returns true if the GraphicsOutput is rendering into any textures at all.
Definition: graphicsOutput.I:72
GraphicsOutput::get_fb_x_size
int get_fb_x_size() const
Returns the internal width of the window or buffer.
Definition: graphicsOutput.I:180
GraphicsOutput::get_inverted
get_inverted
Returns the current setting of the inverted flag.
Definition: graphicsOutput.h:163
GraphicsOutput::get_pipe
get_pipe
Returns the GraphicsPipe that this window is associated with.
Definition: graphicsOutput.h:118
GraphicsOutput::has_size
bool has_size() const
Returns true if the size of the window/frame buffer is known, false otherwise.
Definition: graphicsOutput.I:271
GraphicsOutput::operator<
bool operator<(const GraphicsOutput &other) const
The sorting operator is used to order the GraphicsOutput object in order by their sort number,...
Definition: graphicsOutput.I:654
GraphicsOutput::clear_child_sort
void clear_child_sort()
Resets the sort value of future offscreen buffers created by make_texture_sort() to the default value...
Definition: graphicsOutput.I:472
GraphicsOutput::get_gsg
get_gsg
Returns the GSG that is associated with this window.
Definition: graphicsOutput.h:117
GraphicsOutput::get_sbs_left_size
get_sbs_left_size
If side-by-side stereo is enabled, this returns the pixel size of the left eye, based on scaling get_...
Definition: graphicsOutput.h:150
GraphicsOutput::count_textures
int count_textures() const
If the GraphicsOutput is set to render into a texture, returns the number of textures that are being ...
Definition: graphicsOutput.I:63
GraphicsOutput::get_sbs_left_x_size
int get_sbs_left_x_size() const
If side-by-side stereo is enabled, this returns the pixel width of the left eye, based on scaling get...
Definition: graphicsOutput.I:213
GraphicsOutput::get_draw_window_pcollector
PStatCollector & get_draw_window_pcollector()
Returns a PStatCollector for timing the draw operation for just this GraphicsOutput.
Definition: graphicsOutput.I:702
GraphicsOutput::get_cull_window_pcollector
PStatCollector & get_cull_window_pcollector()
Returns a PStatCollector for timing the cull operation for just this GraphicsOutput.
Definition: graphicsOutput.I:693
GraphicsOutput::get_fb_size
get_fb_size
Returns the internal size of the window or buffer.
Definition: graphicsOutput.h:149
GraphicsOutput::get_fb_properties
const FrameBufferProperties & get_fb_properties() const
Returns the framebuffer properties of the window.
Definition: graphicsOutput.I:413
GraphicsOutput::is_nonzero_size
bool is_nonzero_size() const
Returns true if the output has a nonzero size in both X and Y, or false if it is zero (and therefore ...
Definition: graphicsOutput.I:289
GraphicsOutput::make_stereo_display_region
StereoDisplayRegion * make_stereo_display_region()
Creates a new DisplayRegion that covers the entire window.
Definition: graphicsOutput.I:565
GraphicsOutput::make_mono_display_region
DisplayRegion * make_mono_display_region()
Creates a new DisplayRegion that covers the entire window.
Definition: graphicsOutput.I:541
GraphicsOutput::get_side_by_side_stereo
bool get_side_by_side_stereo() const
Returns whether side-by-side stereo mode is in effect for this particular window.
Definition: graphicsOutput.I:385
GraphicsOutput::get_sbs_right_x_size
int get_sbs_right_x_size() const
If side-by-side stereo is enabled, this returns the pixel width of the right eye, based on scaling ge...
Definition: graphicsOutput.I:248
GraphicsOutput::get_screenshot
bool get_screenshot(PNMImage &image)
Captures the most-recently rendered image from the framebuffer into the indicated PNMImage.
Definition: graphicsOutput.I:635
GraphicsOutput::save_screenshot_default
Filename save_screenshot_default(const std::string &prefix="screenshot")
Saves a screenshot of the region to a default filename, and returns the filename, or empty string if ...
Definition: graphicsOutput.I:615
GraphicsOutput::get_texture_plane
RenderTexturePlane get_texture_plane(int i=0) const
Returns the RenderTexturePlane associated with the nth render-texture.
Definition: graphicsOutput.I:100
GraphicsOutput::get_overlay_display_region
DisplayRegion * get_overlay_display_region() const
Returns the special "overlay" DisplayRegion that is created for each window or buffer.
Definition: graphicsOutput.I:591
GraphicsOutput::set_red_blue_stereo
void set_red_blue_stereo(bool red_blue_stereo, unsigned int left_eye_color_mask, unsigned int right_eye_color_mask)
Enables red-blue stereo mode on this particular window.
Definition: graphicsOutput.I:338
GraphicsOutput::get_child_sort
get_child_sort
Returns the sort value of future offscreen buffers created by make_texture_sort().
Definition: graphicsOutput.h:197
GraphicsOutput::clear_delete_flag
void clear_delete_flag()
Resets the delete flag, so the GraphicsOutput will not be automatically deleted before the beginning ...
Definition: graphicsOutput.I:432
GraphicsOutput::get_right_eye_color_mask
unsigned int get_right_eye_color_mask() const
Returns the color mask in effect when rendering a right-eye view in red_blue stereo mode.
Definition: graphicsOutput.I:376
GraphicsOutput::get_fb_y_size
int get_fb_y_size() const
Returns the internal height of the window or buffer.
Definition: graphicsOutput.I:190
GraphicsOutput::make_display_region
DisplayRegion * make_display_region()
Creates a new DisplayRegion that covers the entire window.
Definition: graphicsOutput.I:513
GraphicsOutput::get_size
get_size
Returns the visible size of the window or buffer, if it is known.
Definition: graphicsOutput.h:148
GraphicsOutput::get_sbs_right_size
get_sbs_right_size
If side-by-side stereo is enabled, this returns the pixel size of the right eye, based on scaling get...
Definition: graphicsOutput.h:151
GraphicsOutput::make_screenshot_filename
static Filename make_screenshot_filename(const std::string &prefix="screenshot")
Saves a screenshot of the region to a default filename, and returns the filename, or empty string if ...
Definition: graphicsOutput.I:605
GraphicsOutput::get_swap_eyes
get_swap_eyes
Returns the current setting of the "swap eyes" flag.
Definition: graphicsOutput.h:167
GraphicsOutput::get_engine
get_engine
Returns the graphics engine that created this output.
Definition: graphicsOutput.h:119
GraphicsOutput::is_valid
bool is_valid() const
Returns true if the output is fully created and ready for rendering, false otherwise.
Definition: graphicsOutput.I:280
GraphicsOutput::get_y_size
int get_y_size() const
Returns the visible height of the window or buffer, if it is known.
Definition: graphicsOutput.I:159
GraphicsOutput::get_sbs_left_dimensions
const LVecBase4 & get_sbs_left_dimensions() const
Returns the effective sub-region of the window for displaying the left channel, if side-by-side stere...
Definition: graphicsOutput.I:395
GraphicsOutput::get_sort
get_sort
Returns the sorting order of this particular GraphicsOutput.
Definition: graphicsOutput.h:192
GraphicsOutput::get_name
get_name
Returns the name that was passed to the GraphicsOutput constructor.
Definition: graphicsOutput.h:120
GraphicsOutput::set_child_sort
set_child_sort
Specifies the sort value of future offscreen buffers created by make_texture_sort().
Definition: graphicsOutput.h:197
GraphicsOutput::get_clear_window_pcollector
PStatCollector & get_clear_window_pcollector()
Returns a PStatCollector for timing the clear operation for just this GraphicsOutput.
Definition: graphicsOutput.I:711
GraphicsOutput::get_left_eye_color_mask
unsigned int get_left_eye_color_mask() const
Returns the color mask in effect when rendering a left-eye view in red_blue stereo mode.
Definition: graphicsOutput.I:366
GraphicsOutput::get_rtm_mode
RenderTextureMode get_rtm_mode(int i=0) const
Returns the RenderTextureMode associated with the nth render-texture.
Definition: graphicsOutput.I:113
GraphicsOutput::is_stereo
bool is_stereo() const
Returns Returns true if this window can render stereo DisplayRegions, either through red-blue stereo ...
Definition: graphicsOutput.I:423
GraphicsOutput::get_red_blue_stereo
bool get_red_blue_stereo() const
Returns whether red-blue stereo mode is in effect for this particular window.
Definition: graphicsOutput.I:356
GraphicsOutput::get_sbs_left_y_size
int get_sbs_left_y_size() const
If side-by-side stereo is enabled, this returns the pixel height of the left eye, based on scaling ge...
Definition: graphicsOutput.I:224
GraphicsOutput::get_x_size
int get_x_size() const
Returns the visible width of the window or buffer, if it is known.
Definition: graphicsOutput.I:145
GraphicsOutput::trigger_copy
AsyncFuture * trigger_copy()
When the GraphicsOutput is in triggered copy mode, this function triggers the copy (at the end of the...
Definition: graphicsOutput.I:495
GraphicsOutput::save_screenshot
bool save_screenshot(const Filename &filename, const std::string &image_comment="")
Saves a screenshot of the region to the indicated filename.
Definition: graphicsOutput.I:626
GraphicsOutput::get_sbs_right_y_size
int get_sbs_right_y_size() const
If side-by-side stereo is enabled, this returns the pixel height of the right eye,...
Definition: graphicsOutput.I:259
GraphicsOutput::get_texture
virtual Texture * get_texture(int i=0) const
Returns the nth texture into which the GraphicsOutput renders.
Definition: graphicsOutput.I:87
GraphicsOutput::get_sbs_right_dimensions
const LVecBase4 & get_sbs_right_dimensions() const
Returns the effective sub-region of the window for displaying the right channel, if side-by-side ster...
Definition: graphicsOutput.I:405
GraphicsPipe
An object to create GraphicsOutputs that share a particular 3-D API.
Definition: graphicsPipe.h:52
GraphicsStateGuardian
Encapsulates all the communication with a particular instance of a given rendering backend.
Definition: graphicsStateGuardian.h:65
PNMImage
The name of this class derives from the fact that we originally implemented it as a layer on top of t...
Definition: pnmImage.h:58
PStatCollector
A lightweight class that represents a single element that may be timed and/or counted via stats.
Definition: pStatCollector.h:43
StereoDisplayRegion
This is a special DisplayRegion wrapper that actually includes a pair of DisplayRegions internally: t...
Definition: stereoDisplayRegion.h:32
Texture
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition: texture.h:71
PT
PT(Texture) GraphicsOutput
Captures the most-recently rendered image from the framebuffer and returns it as Texture,...
Definition: graphicsOutput.I:643