From 799f0fcf19fe31c6807bdbf455ec6519dbc4f6e9 Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 16 Feb 2006 01:34:18 +0000 Subject: [PATCH] slightly better viewport handling --- panda/src/display/displayRegion.cxx | 45 +++++++++++++++++++++++++++- panda/src/display/displayRegion.h | 4 +++ panda/src/display/graphicsOutput.cxx | 2 +- 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/panda/src/display/displayRegion.cxx b/panda/src/display/displayRegion.cxx index b61af96726..8770c3dc8a 100644 --- a/panda/src/display/displayRegion.cxx +++ b/panda/src/display/displayRegion.cxx @@ -36,7 +36,7 @@ DisplayRegion(GraphicsOutput *window) : _window(window) { _draw_buffer_type = window->get_draw_buffer_type(); - compute_pixels(); + compute_pixels_all_stages(); } //////////////////////////////////////////////////////////////////// @@ -50,6 +50,7 @@ DisplayRegion(GraphicsOutput *window, float l, float r, float b, float t) : { _draw_buffer_type = window->get_draw_buffer_type(); set_dimensions(l, r, b, t); + compute_pixels_all_stages(); } //////////////////////////////////////////////////////////////////// @@ -334,6 +335,28 @@ compute_pixels() { } } +//////////////////////////////////////////////////////////////////// +// Function: DisplayRegion::compute_pixels_all_stages +// Access: Published +// Description: Computes the pixel locations of the DisplayRegion +// within its window. The DisplayRegion will request +// the size from the window. +//////////////////////////////////////////////////////////////////// +void DisplayRegion:: +compute_pixels_all_stages() { + int pipeline_stage = Thread::get_current_pipeline_stage(); + nassertv(pipeline_stage == 0); + + if (_window != (GraphicsOutput *)NULL) { + OPEN_ITERATE_ALL_STAGES(_cycler) { + CDStageWriter cdata(_cycler, pipeline_stage); + do_compute_pixels(_window->get_x_size(), _window->get_y_size(), + cdata); + } + CLOSE_ITERATE_ALL_STAGES(_cycler); + } +} + //////////////////////////////////////////////////////////////////// // Function: DisplayRegion::compute_pixels // Access: Published @@ -349,6 +372,24 @@ compute_pixels(int x_size, int y_size) { do_compute_pixels(x_size, y_size, cdata); } +//////////////////////////////////////////////////////////////////// +// Function: DisplayRegion::compute_pixels_all_stages +// Access: Published +// Description: Performs a compute_pixels() operation for all stages +// of the pipeline. This is appropriate, for instance, +// when a window changes sizes, since this is a global +// operation; and you want the new window size to be +// immediately available even to the downstream stages. +//////////////////////////////////////////////////////////////////// +void DisplayRegion:: +compute_pixels_all_stages(int x_size, int y_size) { + OPEN_ITERATE_ALL_STAGES(_cycler) { + CDStageWriter cdata(_cycler, pipeline_stage); + do_compute_pixels(x_size, y_size, cdata); + } + CLOSE_ITERATE_ALL_STAGES(_cycler); +} + //////////////////////////////////////////////////////////////////// // Function: DisplayRegion::get_pixels // Access: Published @@ -640,6 +681,8 @@ do_compute_pixels(int x_size, int y_size, CData *cdata) { DisplayRegion::CData:: CData() : _l(0.), _r(1.), _b(0.), _t(1.), + _pl(0), _pr(0), _pb(0), _pt(0), + _pbi(0), _pti(0), _camera_node((Camera *)NULL), _active(true), _sort(0), diff --git a/panda/src/display/displayRegion.h b/panda/src/display/displayRegion.h index a96fe47512..2848858b9e 100644 --- a/panda/src/display/displayRegion.h +++ b/panda/src/display/displayRegion.h @@ -30,6 +30,7 @@ #include "cycleData.h" #include "cycleDataReader.h" #include "cycleDataWriter.h" +#include "cycleDataStageWriter.h" #include "pipelineCycler.h" #include "config_display.h" @@ -91,7 +92,9 @@ PUBLISHED: INLINE int get_cube_map_index() const; void compute_pixels(); + void compute_pixels_all_stages(); void compute_pixels(int x_size, int y_size); + void compute_pixels_all_stages(int x_size, int y_size); void get_pixels(int &pl, int &pr, int &pb, int &pt) const; void get_region_pixels(int &xo, int &yo, int &w, int &h) const; void get_region_pixels_i(int &xo, int &yo, int &w, int &h) const; @@ -158,6 +161,7 @@ private: PipelineCycler _cycler; typedef CycleDataReader CDReader; typedef CycleDataWriter CDWriter; + typedef CycleDataWriter CDStageWriter; // This is a special cycler created to hold the results from the // cull traversal, for (a) the draw traversal, and (b) the next diff --git a/panda/src/display/graphicsOutput.cxx b/panda/src/display/graphicsOutput.cxx index eb71f540a7..2a7307f81f 100644 --- a/panda/src/display/graphicsOutput.cxx +++ b/panda/src/display/graphicsOutput.cxx @@ -565,7 +565,7 @@ set_size_and_recalc(int x, int y) { for (dri = _total_display_regions.begin(); dri != _total_display_regions.end(); ++dri) { - (*dri)->compute_pixels(x,y); + (*dri)->compute_pixels_all_stages(x, y); } if (_texture_card != 0) {