51 INLINE
const std::string &GraphicsOutput::
65 return cdata->_textures.size();
74 return (cdata->_textures.size() > 0);
89 if ((i < 0) || (i >= ((
int)cdata->_textures.size()))) {
92 return cdata->_textures[i]._texture;
102 if ((i < 0) || (i >= ((
int)cdata->_textures.size()))) {
103 return (RenderTexturePlane)0;
105 return cdata->_textures[i]._plane;
115 if ((i < 0) || (i >= ((
int)cdata->_textures.size()))) {
118 return cdata->_textures[i]._rtm_mode;
130 INLINE
const LVecBase2i &GraphicsOutput::
146 return _size.get_x();
160 return _size.get_y();
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));
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));
214 PN_stdfloat left_w = _sbs_left_dimensions[1] - _sbs_left_dimensions[0];
215 return std::max(
int(_size.get_x() * left_w), 1);
225 PN_stdfloat left_h = _sbs_left_dimensions[3] - _sbs_left_dimensions[2];
226 return std::max(
int(_size.get_y() * left_h), 1);
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));
249 PN_stdfloat right_w = _sbs_right_dimensions[1] - _sbs_right_dimensions[0];
250 return std::max(
int(_size.get_x() * right_w), 1);
260 PN_stdfloat right_h = _sbs_right_dimensions[3] - _sbs_right_dimensions[2];
261 return std::max(
int(_size.get_y() * right_h), 1);
281 return _is_valid && _is_nonzero_size;
290 return _is_nonzero_size;
298 INLINE
bool GraphicsOutput::
299 get_inverted()
const {
312 _swap_eyes = swap_eyes;
318 INLINE
bool GraphicsOutput::
319 get_swap_eyes()
const {
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;
346 _left_eye_color_mask = 0x0f;
347 _right_eye_color_mask = 0x0f;
357 return _red_blue_stereo;
367 return _left_eye_color_mask;
377 return _right_eye_color_mask;
386 return _side_by_side_stereo;
396 return _sbs_left_dimensions;
406 return _sbs_right_dimensions;
414 return _fb_properties;
424 return _red_blue_stereo || _side_by_side_stereo || _fb_properties.is_stereo();
433 _delete_flag =
false;
441 INLINE
int GraphicsOutput::
463 _child_sort = child_sort;
464 _got_child_sort =
true;
473 _got_child_sort =
false;
480 INLINE
int GraphicsOutput::
481 get_child_sort()
const {
482 if (_got_child_sort) {
497 if (future ==
nullptr) {
499 _trigger_copy = future;
592 return _overlay_display_region;
616 return _overlay_display_region->save_screenshot_default(prefix);
627 return _overlay_display_region->save_screenshot(filename, image_comment);
636 return _overlay_display_region->get_screenshot(image);
645 return _overlay_display_region->get_screenshot();
655 if (_sort != other._sort) {
656 return _sort < other._sort;
658 return _internal_sort_index < other._internal_sort_index;
666 INLINE
void GraphicsOutput::
667 determine_display_regions()
const {
670 CDLockedReader cdata(_cycler);
671 if (cdata->_active_display_regions_stale) {
682 INLINE
void GraphicsOutput::
683 win_display_regions_changed() {
684 CDWriter cdata(_cycler,
true);
685 cdata->_active_display_regions_stale =
true;
694 return _cull_window_pcollector;
703 return _draw_window_pcollector;
712 return _clear_window_pcollector;
718 INLINE
void GraphicsOutput::
719 begin_frame_spam(FrameMode mode) {
720 if (display_cat.is_spam()) {
722 <<
"begin_frame(" << mode <<
"): " << get_type() <<
" " 723 << get_name() <<
" " << (
void *)
this <<
"\n";
730 INLINE
void GraphicsOutput::
731 end_frame_spam(FrameMode mode) {
732 if (display_cat.is_spam()) {
734 <<
"end_frame(" << mode <<
"): " << get_type() <<
" " 735 <<
get_name() <<
" " << (
void *)
this <<
"\n";
743 INLINE
void GraphicsOutput::
744 clear_cube_map_selection() {
745 _target_tex_page = -1;
746 _prev_page_dr =
nullptr;
753 INLINE
void GraphicsOutput::
755 if (!_fb_properties.is_single_buffered()) {
AsyncFuture * trigger_copy()
When the GraphicsOutput is in triggered copy mode, this function triggers the copy (at the end of the...
bool operator<(const GraphicsOutput &other) const
The sorting operator is used to order the GraphicsOutput object in order by their sort number,...
int get_sbs_right_y_size() const
If side-by-side stereo is enabled, this returns the pixel height of the right eye,...
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...
StereoDisplayRegion * make_stereo_display_region()
Creates a new DisplayRegion that covers the entire window.
This class represents a thread-safe handle to a promised future result of an asynchronous operation,...
virtual Texture * get_texture(int i=0) const
Returns the nth texture into which the GraphicsOutput renders.
The name of this class derives from the fact that we originally implemented it as a layer on top of t...
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...
get_sort
Returns the sorting order of this particular GraphicsOutput.
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
int get_y_size() const
Returns the visible height of the window or buffer, if it is known.
int get_fb_y_size() const
Returns the internal height of the window or buffer.
PStatCollector & get_clear_window_pcollector()
Returns a PStatCollector for timing the clear operation for just this GraphicsOutput.
static Filename make_screenshot_filename(const std::string &prefix="screenshot")
Synthesizes a suitable default filename for passing to save_screenshot().
DisplayRegion * make_display_region()
Creates a new DisplayRegion that covers the entire window.
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
bool is_valid() const
Returns true if the output is fully created and ready for rendering, false otherwise.
PStatCollector & get_draw_window_pcollector()
Returns a PStatCollector for timing the draw operation for just this GraphicsOutput.
A lightweight class that represents a single element that may be timed and/or counted via stats.
set_swap_eyes
Changes the "swap eyes" flag.
DisplayRegion * make_mono_display_region()
Creates a new DisplayRegion that covers the entire window.
The name of a file, such as a texture file or an Egg file.
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 ...
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...
set_child_sort
Specifies the sort value of future offscreen buffers created by make_texture_sort().
PT(Texture) GraphicsOutput
Captures the most-recently rendered image from the framebuffer and returns it as Texture,...
An object to create GraphicsOutputs that share a particular 3-D API.
bool save_screenshot(const Filename &filename, const std::string &image_comment="")
Saves a screenshot of the region to the indicated filename.
int count_textures() const
If the GraphicsOutput is set to render into a texture, returns the number of textures that are being ...
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.
bool get_screenshot(PNMImage &image)
Captures the most-recently rendered image from the framebuffer into the indicated PNMImage.
This is a base class for the various different classes that represent the result of a frame of render...
This is a special DisplayRegion wrapper that actually includes a pair of DisplayRegions internally: t...
int get_x_size() const
Returns the visible width of the window or buffer, if it is known.
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 ...
bool is_stereo() const
Returns Returns true if this window can render stereo DisplayRegions, either through red-blue stereo ...
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 ...
int get_fb_x_size() const
Returns the internal width of the window or buffer.
get_name
Returns the name that was passed to the GraphicsOutput constructor.
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.
RenderTextureMode get_rtm_mode(int i=0) const
Returns the RenderTextureMode associated with the nth render-texture.
Encapsulates all the communication with a particular instance of a given rendering backend.
void clear_child_sort()
Resets the sort value of future offscreen buffers created by make_texture_sort() to the default value...
A rectangular subregion within a window for rendering into.
bool get_red_blue_stereo() const
Returns whether red-blue stereo mode is in effect for this particular window.
This class is the main interface to controlling the render process.
PStatCollector & get_cull_window_pcollector()
Returns a PStatCollector for timing the cull operation for just this GraphicsOutput.
bool has_texture() const
Returns true if the GraphicsOutput is rendering into any textures at all.
bool has_size() const
Returns true if the size of the window/frame buffer is known, false otherwise.
get_pixel_factor
Returns the amount by which the height and width of the region will be scaled internally,...
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...
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
DisplayRegion * get_overlay_display_region() const
Returns the special "overlay" DisplayRegion that is created for each window or buffer.
void clear_delete_flag()
Resets the delete flag, so the GraphicsOutput will not be automatically deleted before the beginning ...
RenderTexturePlane get_texture_plane(int i=0) const
Returns the RenderTexturePlane associated with the nth render-texture.
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.
const FrameBufferProperties & get_fb_properties() const
Returns the framebuffer properties of the window.
bool get_side_by_side_stereo() const
Returns whether side-by-side stereo mode is in effect for this particular window.
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...