mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
more easily extendable DisplayRegion
This commit is contained in:
parent
c06eafece4
commit
2d78a0503b
@ -53,8 +53,8 @@ get_dimensions(PN_stdfloat &l, PN_stdfloat &r, PN_stdfloat &b, PN_stdfloat &t) c
|
|||||||
b = cdata->_dimensions[2];
|
b = cdata->_dimensions[2];
|
||||||
t = cdata->_dimensions[3];
|
t = cdata->_dimensions[3];
|
||||||
}
|
}
|
||||||
///////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////
|
||||||
// Function: DisplayRegion::get_dimensions
|
// Function: DisplayRegion::get_dimensions
|
||||||
// Access: Published
|
// Access: Published
|
||||||
// Description: Retrieves the coordinates of the DisplayRegion's
|
// Description: Retrieves the coordinates of the DisplayRegion's
|
||||||
@ -512,6 +512,17 @@ get_draw_region_pcollector() {
|
|||||||
return _draw_region_pcollector;
|
return _draw_region_pcollector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: DisplayRegion::pixel_size_changed
|
||||||
|
// Access: Private, Virtual
|
||||||
|
// Description: Called when the size in pixels of this region
|
||||||
|
// has changed. Also called the first time the
|
||||||
|
// pixel size is known.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void DisplayRegion::
|
||||||
|
pixel_size_changed(int x_size, int y_size) {
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: DisplayRegion::CDataCull::Constructor
|
// Function: DisplayRegion::CDataCull::Constructor
|
||||||
// Access: Public
|
// Access: Public
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include "displayRegion.h"
|
#include "displayRegion.h"
|
||||||
#include "stereoDisplayRegion.h"
|
#include "stereoDisplayRegion.h"
|
||||||
|
#include "graphicsEngine.h"
|
||||||
#include "graphicsOutput.h"
|
#include "graphicsOutput.h"
|
||||||
#include "config_display.h"
|
#include "config_display.h"
|
||||||
#include "texture.h"
|
#include "texture.h"
|
||||||
@ -43,6 +44,8 @@ DisplayRegion(GraphicsOutput *window, const LVecBase4 &dimensions) :
|
|||||||
_draw_buffer_type = window->get_draw_buffer_type();
|
_draw_buffer_type = window->get_draw_buffer_type();
|
||||||
set_dimensions(dimensions);
|
set_dimensions(dimensions);
|
||||||
compute_pixels_all_stages();
|
compute_pixels_all_stages();
|
||||||
|
|
||||||
|
_window->add_display_region(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -738,6 +741,9 @@ do_compute_pixels(int x_size, int y_size, CData *cdata) {
|
|||||||
<< "DisplayRegion::do_compute_pixels(" << x_size << ", " << y_size << ")\n";
|
<< "DisplayRegion::do_compute_pixels(" << x_size << ", " << y_size << ")\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int old_w = cdata->_pr - cdata->_pl;
|
||||||
|
int old_h = cdata->_pt - cdata->_pb;
|
||||||
|
|
||||||
cdata->_pl = int((cdata->_dimensions[0] * x_size) + 0.5);
|
cdata->_pl = int((cdata->_dimensions[0] * x_size) + 0.5);
|
||||||
cdata->_pr = int((cdata->_dimensions[1] * x_size) + 0.5);
|
cdata->_pr = int((cdata->_dimensions[1] * x_size) + 0.5);
|
||||||
|
|
||||||
@ -756,6 +762,12 @@ do_compute_pixels(int x_size, int y_size, CData *cdata) {
|
|||||||
cdata->_pbi = int(((1.0f - cdata->_dimensions[2]) * y_size) + 0.5);
|
cdata->_pbi = int(((1.0f - cdata->_dimensions[2]) * y_size) + 0.5);
|
||||||
cdata->_pti = int(((1.0f - cdata->_dimensions[3]) * y_size) + 0.5);
|
cdata->_pti = int(((1.0f - cdata->_dimensions[3]) * y_size) + 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int w = cdata->_pr - cdata->_pl;
|
||||||
|
int h = cdata->_pt - cdata->_pb;
|
||||||
|
if (old_w != w || old_h != h) {
|
||||||
|
pixel_size_changed(w, h);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -782,6 +794,19 @@ set_active_index(int index) {
|
|||||||
#endif // DO_PSTATS
|
#endif // DO_PSTATS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: DisplayRegion::do_cull
|
||||||
|
// Access: Protected, Virtual
|
||||||
|
// Description: Performs a cull traversal. The default
|
||||||
|
// implementation simply calls GraphicsEngine::do_cull.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void DisplayRegion::
|
||||||
|
do_cull(CullHandler *cull_handler, SceneSetup *scene_setup,
|
||||||
|
GraphicsStateGuardian *gsg, Thread *current_thread) {
|
||||||
|
|
||||||
|
GraphicsEngine::do_cull(cull_handler, scene_setup, gsg, current_thread);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: DisplayRegion::CData::Constructor
|
// Function: DisplayRegion::CData::Constructor
|
||||||
// Access: Public
|
// Access: Public
|
||||||
|
@ -162,6 +162,11 @@ private:
|
|||||||
void win_display_regions_changed();
|
void win_display_regions_changed();
|
||||||
void do_compute_pixels(int x_size, int y_size, CData *cdata);
|
void do_compute_pixels(int x_size, int y_size, CData *cdata);
|
||||||
void set_active_index(int index);
|
void set_active_index(int index);
|
||||||
|
INLINE virtual void pixel_size_changed(int x_size, int y_size);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void do_cull(CullHandler *cull_handler, SceneSetup *scene_setup,
|
||||||
|
GraphicsStateGuardian *gsg, Thread *current_thread);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// The associated window is a permanent property of the
|
// The associated window is a permanent property of the
|
||||||
@ -261,7 +266,9 @@ public:
|
|||||||
private:
|
private:
|
||||||
static TypeHandle _type_handle;
|
static TypeHandle _type_handle;
|
||||||
|
|
||||||
|
friend class GraphicsEngine;
|
||||||
friend class GraphicsOutput;
|
friend class GraphicsOutput;
|
||||||
|
friend class DisplayRegionCullCallbackData;
|
||||||
friend class DisplayRegionPipelineReader;
|
friend class DisplayRegionPipelineReader;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -60,7 +60,5 @@ upcall() {
|
|||||||
DisplayRegion *dr = _scene_setup->get_display_region();
|
DisplayRegion *dr = _scene_setup->get_display_region();
|
||||||
GraphicsStateGuardian *gsg = dr->get_window()->get_gsg();
|
GraphicsStateGuardian *gsg = dr->get_window()->get_gsg();
|
||||||
|
|
||||||
GraphicsEngine::do_cull(_cull_handler, _scene_setup,
|
dr->do_cull(_cull_handler, _scene_setup, gsg, current_thread);
|
||||||
gsg, current_thread);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1103,6 +1103,7 @@ texture_uploaded(Texture *tex) {
|
|||||||
LoadedTexture < = _loaded_textures.back();
|
LoadedTexture < = _loaded_textures.back();
|
||||||
lt._tex = tex;
|
lt._tex = tex;
|
||||||
lt._image_modified = tex->get_image_modified();
|
lt._image_modified = tex->get_image_modified();
|
||||||
|
// Usually only called by DisplayRegion::do_cull.
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -1334,7 +1335,7 @@ cull_and_draw_together(GraphicsOutput *win, DisplayRegion *dr,
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Perform the cull normally.
|
// Perform the cull normally.
|
||||||
do_cull(&cull_handler, scene_setup, gsg, current_thread);
|
dr->do_cull(&cull_handler, scene_setup, gsg, current_thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
gsg->end_scene();
|
gsg->end_scene();
|
||||||
@ -1452,7 +1453,7 @@ cull_to_bins(GraphicsOutput *win, DisplayRegion *dr, Thread *current_thread) {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Perform the cull normally.
|
// Perform the cull normally.
|
||||||
do_cull(&cull_handler, scene_setup, gsg, current_thread);
|
dr->do_cull(&cull_handler, scene_setup, gsg, current_thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
PStatTimer timer(_cull_sort_pcollector, current_thread);
|
PStatTimer timer(_cull_sort_pcollector, current_thread);
|
||||||
|
@ -671,7 +671,7 @@ make_mono_display_region(const LVecBase4 &dimensions) {
|
|||||||
return dr;
|
return dr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return add_display_region(new DisplayRegion(this, dimensions));
|
return new DisplayRegion(this, dimensions);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -720,9 +720,6 @@ make_stereo_display_region(const LVecBase4 &dimensions) {
|
|||||||
|
|
||||||
PT(StereoDisplayRegion) stereo = new StereoDisplayRegion(this, dimensions,
|
PT(StereoDisplayRegion) stereo = new StereoDisplayRegion(this, dimensions,
|
||||||
left, right);
|
left, right);
|
||||||
add_display_region(stereo);
|
|
||||||
add_display_region(left);
|
|
||||||
add_display_region(right);
|
|
||||||
|
|
||||||
return stereo;
|
return stereo;
|
||||||
}
|
}
|
||||||
@ -1592,7 +1589,7 @@ create_texture_card_vdata(int x, int y) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: GraphicsOutput::add_display_region
|
// Function: GraphicsOutput::add_display_region
|
||||||
// Access: Private
|
// Access: Private
|
||||||
// Description: Called by one of the make_display_region() methods to
|
// Description: Called by the DisplayRegion constructor to
|
||||||
// add the new DisplayRegion to the list.
|
// add the new DisplayRegion to the list.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
DisplayRegion *GraphicsOutput::
|
DisplayRegion *GraphicsOutput::
|
||||||
|
Loading…
x
Reference in New Issue
Block a user