14#ifndef GRAPHICSOUTPUT_H
15#define GRAPHICSOUTPUT_H
65 GraphicsOutput(GraphicsEngine *engine,
67 const std::string &name,
72 bool default_stereo_flags);
73 GraphicsOutput(
const GraphicsOutput ©) =
delete;
74 GraphicsOutput &operator = (
const GraphicsOutput ©) =
delete;
77 enum RenderTextureMode {
92 RTM_triggered_copy_texture,
96 RTM_triggered_copy_ram,
111 virtual ~GraphicsOutput();
114 INLINE GraphicsPipe *
get_pipe()
const;
116 INLINE
const std::string &
get_name()
const;
129 RenderTexturePlane bitplane=RTP_COUNT);
132 INLINE
const LVecBase2i &
get_size()
const;
170 unsigned int left_eye_color_mask,
171 unsigned int right_eye_color_mask);
178 const LVecBase4 &sbs_left_dimensions,
179 const LVecBase4 &sbs_right_dimensions);
202 INLINE DisplayRegion *
make_display_region(PN_stdfloat l, PN_stdfloat r, PN_stdfloat b, PN_stdfloat t);
227 const std::string &name,
int x_size,
int y_size,
229 GraphicsOutput *
make_cube_map(
const std::string &name,
int size,
235 const std::string &prefix =
"screenshot");
237 const std::string &prefix =
"screenshot");
239 const Filename &filename,
const std::string &image_comment =
"");
259 INLINE
bool operator < (
const GraphicsOutput &other)
const;
295 virtual void pixel_factor_changed();
296 void prepare_for_deletion();
297 void promote_to_copy_texture();
298 bool copy_to_textures();
300 INLINE
void begin_frame_spam(FrameMode mode);
301 INLINE
void end_frame_spam(FrameMode mode);
302 INLINE
void clear_cube_map_selection();
303 INLINE
void trigger_flip();
310 DisplayRegion *add_display_region(DisplayRegion *display_region);
311 bool do_remove_display_region(DisplayRegion *display_region);
313 INLINE
void win_display_regions_changed();
315 INLINE
void determine_display_regions()
const;
316 void do_determine_display_regions(CData *cdata);
318 static unsigned int parse_color_mask(
const std::string &word);
322 GraphicsEngine *_engine;
323 PT(GraphicsPipe) _pipe;
324 PT(GraphicsOutput) _host;
329 int _target_tex_page;
330 int _target_tex_view;
331 DisplayRegion *_prev_page_dr;
335 class RenderTexture {
338 RenderTexturePlane _plane;
339 RenderTextureMode _rtm_mode;
341 typedef pvector<RenderTexture> RenderTextures;
346 bool _got_child_sort;
347 unsigned int _internal_sort_index;
352 bool _red_blue_stereo;
353 unsigned int _left_eye_color_mask;
354 unsigned int _right_eye_color_mask;
355 bool _side_by_side_stereo;
356 LVecBase4 _sbs_left_dimensions;
357 LVecBase4 _sbs_right_dimensions;
364 pvector<WPT(
Texture)> _hold_textures;
371 TotalDisplayRegions _total_display_regions;
372 typedef pvector<DisplayRegion *> ActiveDisplayRegions;
377 class EXPCL_PANDA_DISPLAY CData :
public CycleData {
380 CData(
const CData ©);
384 return GraphicsOutput::get_class_type();
387 RenderTextures _textures;
388 UpdateSeq _textures_seq;
391 ActiveDisplayRegions _active_display_regions;
392 bool _active_display_regions_stale;
394 PipelineCycler<CData> _cycler;
395 typedef CycleDataLockedReader<CData> CDLockedReader;
396 typedef CycleDataReader<CData> CDReader;
397 typedef CycleDataWriter<CData> CDWriter;
398 typedef CycleDataStageWriter<CData> CDStageWriter;
405 bool _is_nonzero_size;
407 static PStatCollector _make_current_pcollector;
408 static PStatCollector _copy_texture_pcollector;
409 static PStatCollector _cull_pcollector;
410 static PStatCollector _draw_pcollector;
411 PStatCollector _cull_window_pcollector;
412 PStatCollector _draw_window_pcollector;
413 PStatCollector _clear_window_pcollector;
416 static TypeHandle get_class_type() {
419 static void init_type() {
420 GraphicsOutputBase::init_type();
422 GraphicsOutputBase::get_class_type());
424 virtual TypeHandle get_type()
const {
425 return get_class_type();
427 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
430 static TypeHandle _type_handle;
432 friend class GraphicsPipe;
433 friend class GraphicsEngine;
434 friend class DisplayRegion;
437EXPCL_PANDA_DISPLAY std::ostream &operator << (std::ostream &out, GraphicsOutput::FrameMode mode);
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class represents a thread-safe handle to a promised future result of an asynchronous operation,...
A single page of data maintained by a PipelineCycler.
Encapsulates the data from a DisplayRegion, pre-fetched for one stage of the pipeline.
A rectangular subregion within a window for rendering into.
The name of a file, such as a texture file or an Egg file.
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
A node that holds Geom objects, renderable pieces of geometry.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
This class is the main interface to controlling the render process.
An abstract base class for GraphicsOutput, for all the usual reasons.
virtual void ready_flip()
This function will be called within the draw thread after end_frame() has been called on all windows,...
virtual void process_events()
Do whatever processing in the window thread is appropriate for this output object each frame.
set_swap_eyes
Changes the "swap eyes" flag.
bool has_texture() const
Returns true if the GraphicsOutput is rendering into any textures at all.
void clear_render_textures()
If the GraphicsOutput is currently rendering to a texture, then all textures are dissociated from the...
int get_fb_x_size() const
Returns the internal width of the window or buffer.
get_inverted
Returns the current setting of the inverted flag.
set_inverted
Changes the current setting of the inverted flag.
get_num_active_display_regions
Returns the number of active DisplayRegions that have been created within the window.
get_pipe
Returns the GraphicsPipe that this window is associated with.
virtual void begin_flip()
This function will be called within the draw thread after end_frame() has been called on all windows,...
bool has_size() const
Returns true if the size of the window/frame buffer is known, false otherwise.
void add_render_texture(Texture *tex, RenderTextureMode mode, RenderTexturePlane bitplane=RTP_COUNT)
Creates a new Texture object, suitable for rendering the contents of this buffer into,...
set_active
Sets the active flag associated with the GraphicsOutput.
void set_side_by_side_stereo(bool side_by_side_stereo)
Enables side-by-side stereo mode on this particular window.
void clear_child_sort()
Resets the sort value of future offscreen buffers created by make_texture_sort() to the default value...
get_active_display_region
Returns the nth active DisplayRegion of those that have been created within the window.
is_active
Returns true if the window is ready to be rendered into, false otherwise.
get_gsg
Returns the GSG that is associated with this window.
get_sbs_left_size
If side-by-side stereo is enabled, this returns the pixel size of the left eye, based on scaling get_...
virtual void clear_pipe()
Sets the window's _pipe pointer to NULL; this is generally called only as a precursor to deleting the...
int count_textures() const
If the GraphicsOutput is set to render into a texture, returns the number of textures that are being ...
void remove_all_display_regions()
Removes all display regions from the window, except the default one that is created with the window.
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...
PStatCollector & get_draw_window_pcollector()
Returns a PStatCollector for timing the draw operation for just this GraphicsOutput.
PStatCollector & get_cull_window_pcollector()
Returns a PStatCollector for timing the cull operation for just this GraphicsOutput.
virtual void end_frame(FrameMode mode, Thread *current_thread)
This function will be called within the draw thread after rendering is completed for a given frame.
virtual bool share_depth_buffer(GraphicsOutput *graphics_output)
Will attempt to use the depth buffer of the input graphics_output.
get_fb_size
Returns the internal size of the window or buffer.
set_one_shot
Changes the current setting of the one-shot flag.
virtual void end_flip()
This function will be called within the draw thread after begin_flip() has been called on all windows...
bool get_delete_flag() const
Returns the current setting of the delete flag.
void change_scenes(DisplayRegionPipelineReader *new_dr)
Called by the GraphicsEngine when the window is about to change to another DisplayRegion.
void setup_render_texture(Texture *tex, bool allow_bind, bool to_ram)
This is a deprecated interface that made sense back when GraphicsOutputs could only render into one t...
const FrameBufferProperties & get_fb_properties() const
Returns the framebuffer properties of the window.
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 ...
StereoDisplayRegion * make_stereo_display_region()
Creates a new DisplayRegion that covers the entire window.
DisplayRegion * make_mono_display_region()
Creates a new DisplayRegion that covers the entire window.
virtual void unshare_depth_buffer()
Discontinue sharing the depth buffer.
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...
get_supports_render_texture
Returns true if this particular GraphicsOutput can render directly into a texture,...
NodePath get_texture_card()
Returns a PandaNode containing a square polygon.
bool get_screenshot(PNMImage &image)
Captures the most-recently rendered image from the framebuffer into the indicated PNMImage.
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 ...
RenderTexturePlane get_texture_plane(int i=0) const
Returns the RenderTexturePlane associated with the nth render-texture.
virtual bool begin_frame(FrameMode mode, Thread *current_thread)
This function will be called within the draw thread before beginning rendering for a given frame.
DisplayRegion * get_overlay_display_region() const
Returns the special "overlay" DisplayRegion that is created for each window or buffer.
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.
get_num_display_regions
Returns the number of DisplayRegions that have been created within the window, active or otherwise.
get_child_sort
Returns the sort value of future offscreen buffers created by make_texture_sort().
void clear_delete_flag()
Resets the delete flag, so the GraphicsOutput will not be automatically deleted before the beginning ...
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.
get_one_shot
Returns the current setting of the one-shot flag.
int get_fb_y_size() const
Returns the internal height of the window or buffer.
DisplayRegion * make_display_region()
Creates a new DisplayRegion that covers the entire window.
virtual void reset_window(bool swapchain)
Resets the window framebuffer from its derived children.
virtual GraphicsOutput * get_host()
This is normally called only from within make_texture_buffer().
void set_size_and_recalc(int x, int y)
Changes the x_size and y_size, then recalculates structures that depend on size.
get_size
Returns the visible size of the window or buffer, if it is known.
get_sbs_right_size
If side-by-side stereo is enabled, this returns the pixel size of the right eye, based on scaling get...
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 ...
get_swap_eyes
Returns the current setting of the "swap eyes" flag.
bool remove_display_region(DisplayRegion *display_region)
Removes the indicated DisplayRegion from the window, and destructs it if there are no other reference...
get_engine
Returns the graphics engine that created this output.
bool is_valid() const
Returns true if the output is fully created and ready for rendering, false otherwise.
virtual void request_close()
This is called by the GraphicsEngine to request that the window (or whatever) close itself or,...
get_display_region
Returns the nth DisplayRegion of those that have been created within the window.
int get_y_size() const
Returns the visible height of the window or buffer, if it is known.
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...
get_sort
Returns the sorting order of this particular GraphicsOutput.
get_name
Returns the name that was passed to the GraphicsOutput constructor.
set_child_sort
Specifies the sort value of future offscreen buffers created by make_texture_sort().
PStatCollector & get_clear_window_pcollector()
Returns a PStatCollector for timing the clear operation for just this GraphicsOutput.
void set_overlay_display_region(DisplayRegion *display_region)
Replaces the special "overlay" DisplayRegion that is created for each window or buffer.
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.
RenderTextureMode get_rtm_mode(int i=0) const
Returns the RenderTextureMode associated with the nth render-texture.
virtual void select_target_tex_page(int page)
Called internally when the window is in render-to-a-texture mode and we are in the process of renderi...
GraphicsOutput * make_cube_map(const std::string &name, int size, NodePath &camera_rig, DrawMask camera_mask=PandaNode::get_all_camera_mask(), bool to_ram=false, FrameBufferProperties *fbp=nullptr)
This is similar to make_texture_buffer() in that it allocates a separate buffer suitable for renderin...
bool is_stereo() const
Returns Returns true if this window can render stereo DisplayRegions, either through red-blue stereo ...
bool get_red_blue_stereo() const
Returns whether red-blue stereo mode is in effect for this particular window.
virtual void request_open()
This is called by the GraphicsEngine to request that the window (or whatever) open itself or,...
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...
int get_x_size() const
Returns the visible width of the window or buffer, if it is known.
virtual bool flip_ready() const
Returns true if a frame has been rendered and needs to be flipped, false otherwise.
AsyncFuture * trigger_copy()
When the GraphicsOutput is in triggered copy mode, this function triggers the copy (at the end of the...
GraphicsOutput * make_texture_buffer(const std::string &name, int x_size, int y_size, Texture *tex=nullptr, bool to_ram=false, FrameBufferProperties *fbp=nullptr)
Creates and returns an offscreen buffer for rendering into, the result of which will be a texture sui...
virtual void clear(Thread *current_thread)
Clears the entire framebuffer before rendering, according to the settings of get_color_clear_active()...
bool save_screenshot(const Filename &filename, const std::string &image_comment="")
Saves a screenshot of the region to the indicated filename.
int get_sbs_right_y_size() const
If side-by-side stereo is enabled, this returns the pixel height of the right eye,...
virtual Texture * get_texture(int i=0) const
Returns the nth texture into which the GraphicsOutput renders.
set_sort
Adjusts the sorting order of this particular GraphicsOutput, relative to other GraphicsOutputs.
virtual void set_close_now()
This is called by the GraphicsEngine to insist that the output be closed immediately.
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...
Encapsulates all the communication with a particular instance of a given rendering backend.
This is a standard, non-reentrant mutex, similar to the Mutex class.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
The name of this class derives from the fact that we originally implemented it as a layer on top of t...
A lightweight class that represents a single element that may be timed and/or counted via stats.
get_all_camera_mask
Returns a DrawMask that is appropriate for rendering to all cameras.
This is a special DisplayRegion wrapper that actually includes a pair of DisplayRegions internally: t...
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
A thread; that is, a lightweight process.
TypeHandle is the identifier used to differentiate C++ class types.
A container for the various kinds of properties we might ask to have on a graphics window before we o...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.