00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef DISPLAYREGION_H
00016 #define DISPLAYREGION_H
00017
00018 #include "pandabase.h"
00019
00020 #include "displayRegionBase.h"
00021 #include "drawableRegion.h"
00022 #include "referenceCount.h"
00023 #include "nodePath.h"
00024 #include "cullResult.h"
00025 #include "sceneSetup.h"
00026 #include "pointerTo.h"
00027 #include "cycleData.h"
00028 #include "cycleDataLockedReader.h"
00029 #include "cycleDataReader.h"
00030 #include "cycleDataWriter.h"
00031 #include "cycleDataStageWriter.h"
00032 #include "pipelineCycler.h"
00033 #include "config_display.h"
00034 #include "lens.h"
00035 #include "deletedChain.h"
00036 #include "plist.h"
00037 #include "pStatCollector.h"
00038 #include "cullTraverser.h"
00039 #include "callbackObject.h"
00040 #include "luse.h"
00041
00042 class GraphicsOutput;
00043 class GraphicsPipe;
00044 class CullHandler;
00045 class Camera;
00046 class PNMImage;
00047 class CullTraverser;
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 class EXPCL_PANDA_DISPLAY DisplayRegion : public DisplayRegionBase, public DrawableRegion {
00061 protected:
00062 DisplayRegion(GraphicsOutput *window, const LVecBase4 &dimensions);
00063
00064 private:
00065 DisplayRegion(const DisplayRegion ©);
00066 void operator = (const DisplayRegion ©);
00067
00068 public:
00069 virtual ~DisplayRegion();
00070 void cleanup();
00071
00072 INLINE bool operator < (const DisplayRegion &other) const;
00073
00074 PUBLISHED:
00075 INLINE void get_dimensions(PN_stdfloat &l, PN_stdfloat &r, PN_stdfloat &b, PN_stdfloat &t) const;
00076 INLINE LVecBase4 get_dimensions() const;
00077 INLINE PN_stdfloat get_left() const;
00078 INLINE PN_stdfloat get_right() const;
00079 INLINE PN_stdfloat get_bottom() const;
00080 INLINE PN_stdfloat get_top() const;
00081 INLINE void set_dimensions(PN_stdfloat l, PN_stdfloat r, PN_stdfloat b, PN_stdfloat t);
00082 virtual void set_dimensions(const LVecBase4 &dimensions);
00083
00084 INLINE GraphicsOutput *get_window() const;
00085 GraphicsPipe *get_pipe() const;
00086 virtual bool is_stereo() const;
00087
00088 virtual void set_camera(const NodePath &camera);
00089 INLINE NodePath get_camera(Thread *current_thread = Thread::get_current_thread()) const;
00090
00091 virtual void set_active(bool active);
00092 INLINE bool is_active() const;
00093
00094 virtual void set_sort(int sort);
00095 INLINE int get_sort() const;
00096
00097 virtual void set_stereo_channel(Lens::StereoChannel stereo_channel);
00098 INLINE Lens::StereoChannel get_stereo_channel() const;
00099 virtual void set_tex_view_offset(int tex_view_offset);
00100 INLINE int get_tex_view_offset() const;
00101
00102 virtual void set_incomplete_render(bool incomplete_render);
00103 INLINE bool get_incomplete_render() const;
00104
00105 virtual void set_texture_reload_priority(int texture_reload_priority);
00106 INLINE int get_texture_reload_priority() const;
00107
00108 void set_lens_index(int index);
00109 INLINE int get_lens_index() const;
00110
00111 virtual void set_cull_traverser(CullTraverser *trav);
00112 CullTraverser *get_cull_traverser();
00113
00114 virtual void set_cube_map_index(int cube_map_index);
00115 INLINE int get_cube_map_index() const;
00116
00117 INLINE void set_cull_callback(CallbackObject *object);
00118 INLINE void clear_cull_callback();
00119 INLINE CallbackObject *get_cull_callback() const;
00120
00121 INLINE void set_draw_callback(CallbackObject *object);
00122 INLINE void clear_draw_callback();
00123 INLINE CallbackObject *get_draw_callback() const;
00124
00125 INLINE int get_pixel_width() const;
00126 INLINE int get_pixel_height() const;
00127
00128 virtual void output(ostream &out) const;
00129
00130 static Filename make_screenshot_filename(
00131 const string &prefix = "screenshot");
00132 Filename save_screenshot_default(const string &prefix = "screenshot");
00133 bool save_screenshot(
00134 const Filename &filename, const string &image_comment = "");
00135 bool get_screenshot(PNMImage &image);
00136 PT(Texture) get_screenshot();
00137
00138 virtual PT(PandaNode) make_cull_result_graph();
00139
00140 public:
00141 void compute_pixels();
00142 void compute_pixels_all_stages();
00143 void compute_pixels(int x_size, int y_size);
00144 void compute_pixels_all_stages(int x_size, int y_size);
00145 INLINE void get_pixels(int &pl, int &pr, int &pb, int &pt) const;
00146 INLINE void get_region_pixels(int &xo, int &yo, int &w, int &h) const;
00147 INLINE void get_region_pixels_i(int &xo, int &yo, int &w, int &h) const;
00148
00149 virtual bool supports_pixel_zoom() const;
00150
00151 INLINE void set_cull_result(CullResult *cull_result, SceneSetup *scene_setup,
00152 Thread *current_thread);
00153 INLINE CullResult *get_cull_result(Thread *current_thread) const;
00154 INLINE SceneSetup *get_scene_setup(Thread *current_thread) const;
00155
00156 INLINE PStatCollector &get_cull_region_pcollector();
00157 INLINE PStatCollector &get_draw_region_pcollector();
00158
00159 private:
00160 class CData;
00161
00162 void win_display_regions_changed();
00163 void do_compute_pixels(int x_size, int y_size, CData *cdata);
00164 void set_active_index(int index);
00165
00166 protected:
00167 virtual void do_cull(CullHandler *cull_handler, SceneSetup *scene_setup,
00168 GraphicsStateGuardian *gsg, Thread *current_thread);
00169
00170 protected:
00171
00172
00173 GraphicsOutput *_window;
00174
00175 bool _incomplete_render;
00176 int _texture_reload_priority;
00177
00178
00179 PT(CullTraverser) _trav;
00180
00181 private:
00182
00183
00184
00185
00186 class EXPCL_PANDA_DISPLAY CData : public CycleData {
00187 public:
00188 CData();
00189 CData(const CData ©);
00190
00191 virtual CycleData *make_copy() const;
00192 virtual TypeHandle get_parent_type() const {
00193 return DisplayRegion::get_class_type();
00194 }
00195
00196 LVecBase4 _dimensions;
00197
00198 int _pl;
00199 int _pr;
00200 int _pb;
00201 int _pt;
00202 int _pbi;
00203 int _pti;
00204 int _lens_index;
00205
00206 NodePath _camera;
00207 Camera *_camera_node;
00208
00209 bool _active;
00210 int _sort;
00211 Lens::StereoChannel _stereo_channel;
00212 int _tex_view_offset;
00213 int _cube_map_index;
00214
00215 PT(CallbackObject) _cull_callback;
00216 PT(CallbackObject) _draw_callback;
00217 };
00218
00219 PipelineCycler<CData> _cycler;
00220 typedef CycleDataLockedReader<CData> CDLockedReader;
00221 typedef CycleDataReader<CData> CDReader;
00222 typedef CycleDataWriter<CData> CDWriter;
00223 typedef CycleDataStageWriter<CData> CDStageWriter;
00224
00225
00226
00227
00228
00229
00230
00231 class EXPCL_PANDA_DISPLAY CDataCull : public CycleData {
00232 public:
00233 CDataCull();
00234 CDataCull(const CDataCull ©);
00235
00236 virtual CycleData *make_copy() const;
00237 virtual TypeHandle get_parent_type() const {
00238 return DisplayRegion::get_class_type();
00239 }
00240
00241 PT(CullResult) _cull_result;
00242 PT(SceneSetup) _scene_setup;
00243 };
00244 PipelineCycler<CDataCull> _cycler_cull;
00245 typedef CycleDataReader<CDataCull> CDCullReader;
00246 typedef CycleDataWriter<CDataCull> CDCullWriter;
00247
00248 PStatCollector _cull_region_pcollector;
00249 PStatCollector _draw_region_pcollector;
00250
00251 public:
00252 static TypeHandle get_class_type() {
00253 return _type_handle;
00254 }
00255 static void init_type() {
00256 DisplayRegionBase::init_type();
00257 register_type(_type_handle, "DisplayRegion",
00258 DisplayRegionBase::get_class_type());
00259 }
00260 virtual TypeHandle get_type() const {
00261 return get_class_type();
00262 }
00263 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00264
00265 private:
00266 static TypeHandle _type_handle;
00267
00268 friend class GraphicsEngine;
00269 friend class GraphicsOutput;
00270 friend class DisplayRegionCullCallbackData;
00271 friend class DisplayRegionPipelineReader;
00272 };
00273
00274
00275
00276
00277
00278
00279 class EXPCL_PANDA_DISPLAY DisplayRegionPipelineReader {
00280 public:
00281 INLINE DisplayRegionPipelineReader(DisplayRegion *object, Thread *current_thread);
00282 private:
00283 INLINE DisplayRegionPipelineReader(const DisplayRegionPipelineReader ©);
00284 INLINE void operator = (const DisplayRegionPipelineReader ©);
00285
00286 public:
00287 INLINE ~DisplayRegionPipelineReader();
00288 ALLOC_DELETED_CHAIN(DisplayRegionPipelineReader);
00289
00290 INLINE DisplayRegion *get_object() const;
00291 INLINE Thread *get_current_thread() const;
00292
00293 INLINE bool is_any_clear_active() const;
00294
00295 INLINE void get_dimensions(PN_stdfloat &l, PN_stdfloat &r, PN_stdfloat &b, PN_stdfloat &t) const;
00296 INLINE const LVecBase4 &get_dimensions() const;
00297 INLINE PN_stdfloat get_left() const;
00298 INLINE PN_stdfloat get_right() const;
00299 INLINE PN_stdfloat get_bottom() const;
00300 INLINE PN_stdfloat get_top() const;
00301
00302 INLINE GraphicsOutput *get_window() const;
00303 GraphicsPipe *get_pipe() const;
00304
00305 INLINE NodePath get_camera() const;
00306 INLINE bool is_active() const;
00307 INLINE int get_sort() const;
00308 INLINE Lens::StereoChannel get_stereo_channel() const;
00309 INLINE int get_tex_view_offset();
00310 INLINE bool get_clear_depth_between_eyes() const;
00311 INLINE int get_cube_map_index() const;
00312 INLINE CallbackObject *get_draw_callback() const;
00313
00314 INLINE void get_pixels(int &pl, int &pr, int &pb, int &pt) const;
00315 INLINE void get_region_pixels(int &xo, int &yo, int &w, int &h) const;
00316 INLINE void get_region_pixels_i(int &xo, int &yo, int &w, int &h) const;
00317
00318 INLINE int get_pixel_width() const;
00319 INLINE int get_pixel_height() const;
00320
00321 INLINE int get_lens_index() const;
00322
00323 private:
00324 DisplayRegion *_object;
00325 Thread *_current_thread;
00326 const DisplayRegion::CData *_cdata;
00327
00328 public:
00329 static TypeHandle get_class_type() {
00330 return _type_handle;
00331 }
00332 static void init_type() {
00333 register_type(_type_handle, "DisplayRegionPipelineReader");
00334 }
00335
00336 private:
00337 static TypeHandle _type_handle;
00338 };
00339
00340 #include "displayRegion.I"
00341
00342 #endif