15 #ifndef GRAPHICSOUTPUT_H
16 #define GRAPHICSOUTPUT_H
18 #include "pandabase.h"
20 #include "graphicsPipe.h"
21 #include "displayRegion.h"
22 #include "stereoDisplayRegion.h"
23 #include "graphicsStateGuardian.h"
24 #include "drawableRegion.h"
25 #include "renderBuffer.h"
26 #include "graphicsOutputBase.h"
28 #include "typedWritableReferenceCount.h"
29 #include "pandaNode.h"
30 #include "pStatCollector.h"
32 #include "lightMutex.h"
36 #include "weakPointerTo.h"
38 #include "cycleData.h"
39 #include "cycleDataLockedReader.h"
40 #include "cycleDataReader.h"
41 #include "cycleDataWriter.h"
42 #include "pipelineCycler.h"
43 #include "updateSeq.h"
77 bool default_stereo_flags);
84 enum RenderTextureMode {
99 RTM_triggered_copy_texture,
103 RTM_triggered_copy_ram,
123 INLINE
const string &get_name()
const;
125 INLINE
int count_textures()
const;
126 INLINE
bool has_texture()
const;
127 virtual INLINE
Texture *get_texture(
int i=0)
const;
128 INLINE RenderTexturePlane get_texture_plane(
int i=0)
const;
129 INLINE RenderTextureMode get_rtm_mode(
int i=0)
const;
130 void clear_render_textures();
131 void add_render_texture(
Texture *tex, RenderTextureMode mode,
132 RenderTexturePlane bitplane=RTP_COUNT);
133 void setup_render_texture(
Texture *tex,
bool allow_bind,
bool to_ram);
136 INLINE
int get_x_size()
const;
137 INLINE
int get_y_size()
const;
139 INLINE
int get_fb_x_size()
const;
140 INLINE
int get_fb_y_size()
const;
142 INLINE
int get_sbs_left_x_size()
const;
143 INLINE
int get_sbs_left_y_size()
const;
145 INLINE
int get_sbs_right_x_size()
const;
146 INLINE
int get_sbs_right_y_size()
const;
147 INLINE
bool has_size()
const;
148 INLINE
bool is_valid()
const;
149 INLINE
bool is_nonzero_size()
const;
151 void set_active(
bool active);
152 virtual bool is_active()
const;
154 void set_one_shot(
bool one_shot);
155 bool get_one_shot()
const;
157 void set_inverted(
bool inverted);
158 INLINE
bool get_inverted()
const;
160 INLINE
void set_swap_eyes(
bool swap_eyes);
161 INLINE
bool get_swap_eyes()
const;
163 INLINE
void set_red_blue_stereo(
bool red_blue_stereo,
164 unsigned int left_eye_color_mask,
165 unsigned int right_eye_color_mask);
166 INLINE
bool get_red_blue_stereo()
const;
167 INLINE
unsigned int get_left_eye_color_mask()
const;
168 INLINE
unsigned int get_right_eye_color_mask()
const;
170 void set_side_by_side_stereo(
bool side_by_side_stereo);
171 void set_side_by_side_stereo(
bool side_by_side_stereo,
174 INLINE
bool get_side_by_side_stereo()
const;
175 INLINE
const LVecBase4 &get_sbs_left_dimensions()
const;
176 INLINE
const LVecBase4 &get_sbs_right_dimensions()
const;
179 INLINE
bool is_stereo()
const;
181 INLINE
void clear_delete_flag();
182 bool get_delete_flag()
const;
184 virtual void set_sort(
int sort);
185 INLINE
int get_sort()
const;
187 INLINE
void set_child_sort(
int child_sort);
188 INLINE
void clear_child_sort();
189 INLINE
int get_child_sort()
const;
191 INLINE
void trigger_copy();
194 INLINE
DisplayRegion *make_display_region(PN_stdfloat l, PN_stdfloat r, PN_stdfloat b, PN_stdfloat t);
197 INLINE
DisplayRegion *make_mono_display_region(PN_stdfloat l, PN_stdfloat r, PN_stdfloat b, PN_stdfloat t);
200 INLINE
StereoDisplayRegion *make_stereo_display_region(PN_stdfloat l, PN_stdfloat r, PN_stdfloat b, PN_stdfloat t);
203 void remove_all_display_regions();
206 void set_overlay_display_region(
DisplayRegion *display_region);
208 int get_num_display_regions()
const;
210 MAKE_SEQ(get_display_regions, get_num_display_regions, get_display_region);
212 int get_num_active_display_regions()
const;
214 MAKE_SEQ(get_active_display_regions, get_num_active_display_regions, get_active_display_region);
217 const string &name,
int x_size,
int y_size,
224 INLINE
static Filename make_screenshot_filename(
225 const string &prefix =
"screenshot");
226 INLINE
Filename save_screenshot_default(
227 const string &prefix =
"screenshot");
228 INLINE
bool save_screenshot(
229 const Filename &filename,
const string &image_comment =
"");
230 INLINE
bool get_screenshot(
PNMImage &image);
231 INLINE PT(
Texture) get_screenshot();
236 virtual void unshare_depth_buffer();
238 virtual bool get_supports_render_texture()
const;
244 virtual bool flip_ready()
const;
250 virtual void request_open();
251 virtual void request_close();
253 virtual void set_close_now();
254 virtual void reset_window(
bool swapchain);
255 virtual void clear_pipe();
257 void set_size_and_recalc(
int x,
int y);
262 void clear(
Thread *current_thread);
263 virtual bool begin_frame(FrameMode mode,
Thread *current_thread);
264 virtual void end_frame(FrameMode mode,
Thread *current_thread);
267 virtual void select_target_tex_page(
int page);
270 virtual void begin_flip();
271 virtual void ready_flip();
272 virtual void end_flip();
277 virtual void process_events();
283 virtual void pixel_factor_changed();
284 void prepare_for_deletion();
285 void promote_to_copy_texture();
286 bool copy_to_textures();
288 INLINE
void begin_frame_spam(FrameMode mode);
289 INLINE
void end_frame_spam(FrameMode mode);
290 INLINE
void clear_cube_map_selection();
291 INLINE
void trigger_flip();
299 bool do_remove_display_region(
DisplayRegion *display_region);
301 INLINE
void win_display_regions_changed();
303 INLINE
void determine_display_regions()
const;
304 void do_determine_display_regions(CData *cdata);
306 static unsigned int parse_color_mask(
const string &word);
317 int _target_tex_page;
318 int _target_tex_view;
323 class RenderTexture {
326 RenderTexturePlane _plane;
327 RenderTextureMode _rtm_mode;
334 bool _got_child_sort;
335 unsigned int _internal_sort_index;
340 bool _red_blue_stereo;
341 unsigned int _left_eye_color_mask;
342 unsigned int _right_eye_color_mask;
343 bool _side_by_side_stereo;
365 class EXPCL_PANDA_DISPLAY CData :
public CycleData {
368 CData(
const CData ©);
372 return GraphicsOutput::get_class_type();
380 bool _active_display_regions_stale;
392 bool _is_nonzero_size;
405 static void init_type() {
406 GraphicsOutputBase::init_type();
407 register_type(_type_handle,
"GraphicsOutput",
408 GraphicsOutputBase::get_class_type());
411 return get_class_type();
413 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
423 EXPCL_PANDA_DISPLAY ostream &operator << (ostream &out, GraphicsOutput::FrameMode mode);
425 #include "graphicsOutput.I"
Encapsulates the data from a DisplayRegion, pre-fetched for one stage of the pipeline.
This is a base class for GraphicsWindow (actually, GraphicsOutput) and DisplayRegion, both of which are conceptually rectangular regions into which drawing commands may be issued.
The name of this class derives from the fact that we originally implemented it as a layer on top of t...
A single page of data maintained by a PipelineCycler.
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
This is the base class for all two-component vectors and points.
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
A lightweight class that represents a single element that may be timed and/or counted via stats...
A container for the various kinds of properties we might ask to have on a graphics window before we o...
The name of a file, such as a texture file or an Egg file.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
An object to create GraphicsOutputs that share a particular 3-D API.
This template class calls PipelineCycler::read() in the constructor and PipelineCycler::release_read(...
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...
This is a special DisplayRegion wrapper that actually includes a pair of DisplayRegions internally: t...
This is the base class for all three-component vectors and points.
A thread; that is, a lightweight process.
Encapsulates all the communication with a particular instance of a given rendering backend...
A rectangular subregion within a window for rendering into.
An abstract base class for GraphicsOutput, for all the usual reasons.
This class is the main interface to controlling the render process.
TypeHandle is the identifier used to differentiate C++ class types.
This is a sequence number that increments monotonically.
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
This is a standard, non-reentrant mutex, similar to the Mutex class.
static DrawMask get_all_camera_mask()
Returns a DrawMask that is appropriate for rendering to all cameras.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
A node that holds Geom objects, renderable pieces of geometry.