41 PStatCollector GraphicsOutput::_make_current_pcollector(
"Draw:Make current");
42 PStatCollector GraphicsOutput::_copy_texture_pcollector(
"Draw:Copy texture");
47 CubeFaceDef(
const char *name,
const LPoint3 &look_at,
const LVector3 &up) :
48 _name(name), _look_at(look_at), _up(up) { }
55 static CubeFaceDef cube_faces[6] = {
56 CubeFaceDef(
"positive_x", LPoint3(1, 0, 0), LVector3(0, -1, 0)),
57 CubeFaceDef(
"negative_x", LPoint3(-1, 0, 0), LVector3(0, -1, 0)),
58 CubeFaceDef(
"positive_y", LPoint3(0, 1, 0), LVector3(0, 0, 1)),
59 CubeFaceDef(
"negative_y", LPoint3(0, -1, 0), LVector3(0, 0, -1)),
60 CubeFaceDef(
"positive_z", LPoint3(0, 0, 1), LVector3(0, -1, 0)),
61 CubeFaceDef(
"negative_z", LPoint3(0, 0, -1), LVector3(0, -1, 0))
76 bool default_stereo_flags) :
77 _lock(
"GraphicsOutput"),
78 _cull_window_pcollector(_cull_pcollector, name),
79 _draw_window_pcollector(_draw_pcollector, name),
80 _clear_window_pcollector(_draw_window_pcollector,
"Clear"),
83 #ifdef DO_MEMORY_USAGE 90 _fb_properties = fb_prop;
92 _creation_flags = flags;
94 _is_nonzero_size =
false;
97 _is_nonzero_size = (_size[0] > 0 && _size[1] > 0);
99 if (_creation_flags & GraphicsPipe::BF_size_track_host) {
101 _is_nonzero_size =
true;
106 _target_tex_page = -1;
107 _prev_page_dr =
nullptr;
110 _got_child_sort =
false;
111 _internal_sort_index = 0;
112 _inverted = window_inverted;
113 _swap_eyes = swap_eyes;
114 _red_blue_stereo =
false;
115 _left_eye_color_mask = 0x0f;
116 _right_eye_color_mask = 0x0f;
117 _side_by_side_stereo =
false;
118 _sbs_left_dimensions.set(0.0f, 1.0f, 0.0f, 1.0f);
119 _sbs_right_dimensions.set(0.0f, 1.0f, 0.0f, 1.0f);
120 _delete_flag =
false;
122 if (_fb_properties.is_single_buffered()) {
123 _draw_buffer_type = RenderBuffer::T_front;
125 _draw_buffer_type = RenderBuffer::T_back;
128 if (default_stereo_flags) {
131 _red_blue_stereo = red_blue_stereo && !fb_prop.is_stereo();
132 if (_red_blue_stereo) {
133 _left_eye_color_mask = parse_color_mask(red_blue_stereo_colors.
get_word(0));
134 _right_eye_color_mask = parse_color_mask(red_blue_stereo_colors.
get_word(1));
136 _side_by_side_stereo = side_by_side_stereo && !fb_prop.is_stereo();
137 if (_side_by_side_stereo) {
138 _sbs_left_dimensions.set(sbs_left_dimensions[0], sbs_left_dimensions[1],
139 sbs_left_dimensions[2], sbs_left_dimensions[3]);
140 _sbs_right_dimensions.set(sbs_right_dimensions[0], sbs_right_dimensions[1],
141 sbs_right_dimensions[2], sbs_right_dimensions[3]);
148 _overlay_display_region = make_mono_display_region(0.0f, 1.0f, 0.0f, 1.0f);
149 _overlay_display_region->set_active(
false);
150 _overlay_display_region->set_scissor_enabled(
false);
154 CDWriter cdata(_cycler,
true);
155 cdata->_active =
true;
159 set_clear_color_active(
true);
160 set_clear_depth_active(
true);
161 set_clear_stencil_active(
true);
162 set_clear_color(background_color.
get_value());
174 nassertv(_pipe ==
nullptr);
179 TotalDisplayRegions::iterator dri;
180 for (dri = _total_display_regions.begin();
181 dri != _total_display_regions.end();
183 (*dri)->_window =
nullptr;
186 _total_display_regions.clear();
187 _overlay_display_region =
nullptr;
197 cdata->_textures.clear();
198 ++(cdata->_textures_seq);
199 throw_event(
"render-texture-targets-changed");
238 RenderTexturePlane plane) {
240 if (mode == RTM_none) {
246 if (tex ==
nullptr) {
261 if (plane == RTP_COUNT) {
263 case Texture::F_depth_stencil:
264 plane = RTP_depth_stencil;
267 case Texture::F_depth_component:
268 case Texture::F_depth_component16:
269 case Texture::F_depth_component24:
270 case Texture::F_depth_component32:
283 if (plane == RTP_depth) {
287 }
else if (plane == RTP_depth_stencil) {
289 if (_fb_properties.get_float_depth()) {
296 }
else if (plane == RTP_color ||
297 plane == RTP_aux_rgba_0 ||
298 plane == RTP_aux_rgba_1 ||
299 plane == RTP_aux_rgba_2 ||
300 plane == RTP_aux_rgba_3) {
304 }
else if (plane == RTP_aux_hrgba_0 ||
305 plane == RTP_aux_hrgba_1 ||
306 plane == RTP_aux_hrgba_2 ||
307 plane == RTP_aux_hrgba_3) {
311 }
else if (plane == RTP_aux_float_0 ||
312 plane == RTP_aux_float_1 ||
313 plane == RTP_aux_float_2 ||
314 plane == RTP_aux_float_3) {
320 display_cat.error() <<
321 "add_render_texture: invalid bitplane specified.\n";
330 if (_fb_properties.is_stereo() && plane == RTP_color) {
339 if (mode == RTM_bind_or_copy) {
340 mode = RTM_copy_texture;
341 }
else if (mode == RTM_bind_layered) {
344 display_cat.error() <<
345 "add_render_texture: RTM_bind_layered was requested but " 346 "render-to-texture is not supported or has been disabled!\n";
350 if (mode == RTM_bind_layered && _gsg !=
nullptr && !_gsg->get_supports_geometry_shaders()) {
353 display_cat.warning() <<
354 "add_render_texture: RTM_bind_layered was requested but " 355 "geometry shaders are not supported!\n";
358 if (mode == RTM_bind_or_copy || mode == RTM_bind_layered) {
364 RenderTexture result;
365 result._texture = tex;
366 result._plane = plane;
367 result._rtm_mode = mode;
368 cdata->_textures.push_back(result);
369 ++(cdata->_textures_seq);
371 throw_event(
"render-texture-targets-changed");
381 display_cat.warning() <<
382 "Using deprecated setup_render_texture interface.\n";
386 }
else if (allow_bind) {
399 CDLockedReader cdata(_cycler);
400 if (cdata->_active != active) {
402 cdataw->_active = active;
409 bool GraphicsOutput::
415 CDLockedReader cdata(_cycler);
416 if (!cdata->_active) {
420 if (cdata->_one_shot_frame != -1) {
441 if (cdata->_active_display_regions_stale) {
444 return !cdataw->_active_display_regions.empty();
446 return !cdata->_active_display_regions.empty();
467 CDWriter cdata(_cycler,
true);
471 cdata->_one_shot_frame = -1;
479 bool GraphicsOutput::
480 get_one_shot()
const {
481 CDReader cdata(_cycler);
498 if (_inverted != inverted) {
499 _inverted = inverted;
504 TotalDisplayRegions::iterator dri;
505 for (dri = _total_display_regions.begin();
506 dri != _total_display_regions.end();
527 LVecBase4 left, right;
528 left.set(sbs_left_dimensions[0], sbs_left_dimensions[1],
529 sbs_left_dimensions[2], sbs_left_dimensions[3]);
530 right.set(sbs_right_dimensions[0], sbs_right_dimensions[1],
531 sbs_right_dimensions[2], sbs_right_dimensions[3]);
548 const LVecBase4 &sbs_left_dimensions,
549 const LVecBase4 &sbs_right_dimensions) {
550 _side_by_side_stereo = side_by_side_stereo;
551 if (_side_by_side_stereo) {
552 _sbs_left_dimensions = sbs_left_dimensions;
553 _sbs_right_dimensions = sbs_right_dimensions;
555 _sbs_left_dimensions.set(0.0f, 1.0f, 0.0f, 1.0f);
556 _sbs_right_dimensions.set(0.0f, 1.0f, 0.0f, 1.0f);
569 for (
int i = 0; i < (int)_hold_textures.size(); i++) {
570 if (_hold_textures[i].is_valid_pointer()) {
585 if (_gsg !=
nullptr &&
586 _gsg->get_engine() !=
nullptr) {
587 _gsg->get_engine()->set_window_sort(
this, sort);
603 if (
is_stereo() && default_stereo_camera) {
622 if (_side_by_side_stereo) {
642 if (_side_by_side_stereo) {
645 PN_stdfloat left_l = _sbs_left_dimensions[0];
646 PN_stdfloat left_b = _sbs_left_dimensions[2];
647 PN_stdfloat left_w = _sbs_left_dimensions[1] - _sbs_left_dimensions[0];
648 PN_stdfloat left_h = _sbs_left_dimensions[3] - _sbs_left_dimensions[2];
649 LVecBase4 left_dimensions(dimensions[0] * left_w + left_l,
650 dimensions[1] * left_w + left_l,
651 dimensions[2] * left_h + left_b,
652 dimensions[3] * left_h + left_b);
655 PN_stdfloat right_l = _sbs_right_dimensions[0];
656 PN_stdfloat right_b = _sbs_right_dimensions[2];
657 PN_stdfloat right_w = _sbs_right_dimensions[1] - _sbs_right_dimensions[0];
658 PN_stdfloat right_h = _sbs_right_dimensions[3] - _sbs_right_dimensions[2];
659 LVecBase4 right_dimensions(dimensions[0] * right_w + right_l,
660 dimensions[1] * right_w + right_l,
661 dimensions[2] * right_h + right_b,
662 dimensions[3] * right_h + right_b);
681 right->set_clear_depth_active(
true);
684 right->set_clear_stencil_active(
true);
705 nassertr(display_region != _overlay_display_region,
false);
709 DCAST_INTO_R(sdr, display_region,
false);
714 return do_remove_display_region(display_region);
725 TotalDisplayRegions::iterator dri;
726 for (dri = _total_display_regions.begin();
727 dri != _total_display_regions.end();
730 if (display_region != _overlay_display_region) {
733 display_region->_window =
nullptr;
736 _total_display_regions.clear();
737 _total_display_regions.push_back(_overlay_display_region);
739 OPEN_ITERATE_ALL_STAGES(_cycler) {
741 cdata->_active_display_regions_stale =
true;
743 CLOSE_ITERATE_ALL_STAGES(_cycler);
761 nassertv(display_region->
get_window() ==
this);
762 _overlay_display_region = display_region;
770 get_num_display_regions()
const {
772 return _total_display_regions.size();
782 get_display_region(
int n)
const {
783 determine_display_regions();
787 if (n >= 0 && n < (
int)_total_display_regions.size()) {
788 result = _total_display_regions[n];
801 get_num_active_display_regions()
const {
802 determine_display_regions();
803 CDReader cdata(_cycler);
804 return cdata->_active_display_regions.size();
814 get_active_display_region(
int n)
const {
815 determine_display_regions();
817 CDReader cdata(_cycler);
818 if (n >= 0 && n < (
int)cdata->_active_display_regions.size()) {
819 return cdata->_active_display_regions[n];
849 make_texture_buffer(
const string &name,
int x_size,
int y_size,
853 props.set_rgb_color(1);
855 props.set_alpha_bits(1);
856 props.set_depth_bits(1);
858 if (fbp ==
nullptr) {
862 int flags = GraphicsPipe::BF_refuse_window;
863 if (textures_power_2 != ATS_none) {
864 flags |= GraphicsPipe::BF_size_power_2;
866 if (tex !=
nullptr &&
868 flags |= GraphicsPipe::BF_size_square;
877 if (buffer !=
nullptr) {
878 if (buffer->
get_gsg() ==
nullptr ||
879 buffer->
get_gsg()->get_prepared_objects() !=
get_gsg()->get_prepared_objects()) {
918 display_cat.warning()
919 <<
"Cannot make dynamic cube map; GSG does not support cube maps.\n";
922 if (max_dimension > 0) {
923 size = std::min(max_dimension, size);
940 buffer = make_texture_buffer(name, size, size, tex, to_ram, fbp);
950 for (
int i = 0; i < 6; i++) {
952 camera->set_lens(lens);
953 camera->set_camera_mask(camera_mask);
955 camera_np.
look_at(cube_faces[i]._look_at, cube_faces[i]._up);
981 if (_texture_card ==
nullptr) {
984 strip->set_shade_model(Geom::SM_uniform);
985 strip->add_next_vertices(4);
986 strip->close_primitive();
988 geom->add_primitive(strip);
989 _texture_card =
new GeomNode(
"texture card");
990 _texture_card->add_geom(geom);
994 path.
node()->add_child(_texture_card);
1000 RenderTextures::const_iterator ri;
1001 for (ri = cdata->_textures.begin(); ri != cdata->_textures.end(); ++ri) {
1002 Texture *texture = (*ri)._texture;
1003 if ((texture->
get_format() != Texture::F_depth_stencil)) {
1033 bool GraphicsOutput::
1034 get_supports_render_texture()
const {
1091 <<
"Resetting " << get_type() <<
"\n";
1113 _is_nonzero_size = (x > 0 && y > 0);
1118 TotalDisplayRegions::iterator dri;
1119 for (dri = _total_display_regions.begin();
1120 dri != _total_display_regions.end();
1122 (*dri)->compute_pixels_all_stages(fb_x_size, fb_y_size);
1125 if (_texture_card !=
nullptr && _texture_card->get_num_geoms() > 0) {
1126 _texture_card->modify_geom(0)->set_vertex_data(create_texture_card_vdata(x, y));
1140 if (display_cat.is_spam()) {
1142 <<
"clear(): " << get_type() <<
" " 1143 <<
get_name() <<
" " << (
void *)
this <<
"\n";
1146 nassertv(_gsg !=
nullptr);
1149 _gsg->prepare_display_region(&dr_reader);
1183 if (new_target_tex_page != -1 && new_target_tex_page != _target_tex_page) {
1185 if (new_target_tex_page == -1) {
1186 new_target_tex_page = 0;
1188 int old_target_tex_page = _target_tex_page;
1190 _target_tex_page = new_target_tex_page;
1191 _prev_page_dr = new_dr->get_object();
1194 RenderTextures::const_iterator ri;
1195 for (ri = cdata->_textures.begin(); ri != cdata->_textures.end(); ++ri) {
1196 RenderTextureMode rtm_mode = (*ri)._rtm_mode;
1197 RenderTexturePlane plane = (*ri)._plane;
1198 Texture *texture = (*ri)._texture;
1199 if (rtm_mode != RTM_none) {
1200 if (rtm_mode == RTM_bind_or_copy || rtm_mode == RTM_bind_layered) {
1206 }
else if (old_target_tex_page != -1) {
1210 nassertv(old_page_dr !=
nullptr);
1211 if (display_cat.is_debug()) {
1213 <<
"Copying texture for " <<
get_name() <<
" at scene change.\n";
1215 <<
"target_tex_page = " << old_target_tex_page <<
"\n";
1220 if (plane == RTP_color && _fb_properties.is_stereo()) {
1222 RenderBuffer left(_gsg, buffer._buffer_type & ~RenderBuffer::T_right);
1223 RenderBuffer right(_gsg, buffer._buffer_type & ~RenderBuffer::T_left);
1225 if (rtm_mode == RTM_copy_ram) {
1226 _gsg->framebuffer_copy_to_ram(texture, 0, old_target_tex_page,
1228 _gsg->framebuffer_copy_to_ram(texture, 1, old_target_tex_page,
1229 old_page_dr, right);
1231 _gsg->framebuffer_copy_to_texture(texture, 0, old_target_tex_page,
1233 _gsg->framebuffer_copy_to_texture(texture, 1, old_target_tex_page,
1234 old_page_dr, right);
1237 if (rtm_mode == RTM_copy_ram) {
1238 _gsg->framebuffer_copy_to_ram(texture, 0, old_target_tex_page,
1239 old_page_dr, buffer);
1241 _gsg->framebuffer_copy_to_texture(texture, 0, old_target_tex_page,
1242 old_page_dr, buffer);
1298 _flip_ready =
false;
1314 void GraphicsOutput::
1315 pixel_factor_changed() {
1325 void GraphicsOutput::
1326 prepare_for_deletion() {
1327 CDWriter cdata(_cycler,
true);
1328 cdata->_active =
false;
1332 RenderTextures::iterator ri;
1333 for (ri = cdata->_textures.begin(); ri != cdata->_textures.end(); ++ri) {
1334 if ((*ri)._rtm_mode == RTM_bind_or_copy || (*ri)._rtm_mode == RTM_bind_layered) {
1335 _hold_textures.push_back((*ri)._texture);
1338 cdata->_textures.clear();
1340 _delete_flag =
true;
1354 void GraphicsOutput::
1355 promote_to_copy_texture() {
1356 CDLockedReader cdata(_cycler);
1357 RenderTextures::const_iterator ri;
1359 bool any_bind =
false;
1360 for (ri = cdata->_textures.begin(); ri != cdata->_textures.end(); ++ri) {
1361 if ((*ri)._rtm_mode == RTM_bind_or_copy) {
1368 RenderTextures::iterator ri;
1369 for (ri = cdataw->_textures.begin(); ri != cdataw->_textures.end(); ++ri) {
1370 if ((*ri)._rtm_mode == RTM_bind_or_copy) {
1371 (*ri)._rtm_mode = RTM_copy_texture;
1384 bool GraphicsOutput::
1385 copy_to_textures() {
1388 CDReader cdata(_cycler);
1389 RenderTextures::const_iterator ri;
1390 for (ri = cdata->_textures.begin(); ri != cdata->_textures.end(); ++ri) {
1391 RenderTextureMode rtm_mode = (*ri)._rtm_mode;
1392 if ((rtm_mode == RTM_none) || (rtm_mode == RTM_bind_or_copy)) {
1396 Texture *texture = (*ri)._texture;
1399 if ((rtm_mode == RTM_copy_texture)||
1400 (rtm_mode == RTM_copy_ram)||
1401 ((rtm_mode == RTM_triggered_copy_texture)&&(_trigger_copy))||
1402 ((rtm_mode == RTM_triggered_copy_ram)&&(_trigger_copy))) {
1403 if (display_cat.is_debug()) {
1405 <<
"Copying texture for " <<
get_name() <<
" at frame end.\n";
1407 <<
"target_tex_page = " << _target_tex_page <<
"\n";
1409 RenderTexturePlane plane = (*ri)._plane;
1411 if (plane == RTP_color) {
1416 bool copied =
false;
1418 if (_prev_page_dr !=
nullptr) {
1422 if (plane == RTP_color && _fb_properties.is_stereo()) {
1424 RenderBuffer left(_gsg, buffer._buffer_type & ~RenderBuffer::T_right);
1425 RenderBuffer right(_gsg, buffer._buffer_type & ~RenderBuffer::T_left);
1427 if ((rtm_mode == RTM_copy_ram)||(rtm_mode == RTM_triggered_copy_ram)) {
1428 copied = _gsg->framebuffer_copy_to_ram(texture, 0, _target_tex_page,
1430 copied = _gsg->framebuffer_copy_to_ram(texture, 1, _target_tex_page,
1431 dr, right) && copied;
1433 copied = _gsg->framebuffer_copy_to_texture(texture, 0, _target_tex_page,
1435 copied = _gsg->framebuffer_copy_to_texture(texture, 1, _target_tex_page,
1436 dr, right) && copied;
1439 if ((rtm_mode == RTM_copy_ram)||(rtm_mode == RTM_triggered_copy_ram)) {
1440 copied = _gsg->framebuffer_copy_to_ram(texture, 0, _target_tex_page,
1443 copied = _gsg->framebuffer_copy_to_texture(texture, 0, _target_tex_page,
1452 if (_trigger_copy !=
nullptr) {
1453 _trigger_copy->set_result(
nullptr);
1454 _trigger_copy =
nullptr;
1464 create_texture_card_vdata(
int x,
int y) {
1465 PN_stdfloat xhi = 1.0;
1466 PN_stdfloat yhi = 1.0;
1471 xhi = (x * 1.0f) / xru;
1472 yhi = (y * 1.0f) / yru;
1478 (
"card", format, Geom::UH_static);
1484 vertex.
add_data3(LVertex::rfu(-1.0f, 0.0f, 1.0f));
1485 vertex.
add_data3(LVertex::rfu(-1.0f, 0.0f, -1.0f));
1486 vertex.
add_data3(LVertex::rfu( 1.0f, 0.0f, 1.0f));
1487 vertex.
add_data3(LVertex::rfu( 1.0f, 0.0f, -1.0f));
1509 CDWriter cdata(_cycler,
true);
1510 cdata->_active_display_regions_stale =
true;
1512 _total_display_regions.push_back(display_region);
1514 return display_region;
1521 bool GraphicsOutput::
1523 nassertr(display_region != _overlay_display_region,
false);
1526 TotalDisplayRegions::iterator dri =
1527 find(_total_display_regions.begin(), _total_display_regions.end(), drp);
1528 if (dri != _total_display_regions.end()) {
1531 display_region->_window =
nullptr;
1532 _total_display_regions.erase(dri);
1534 OPEN_ITERATE_ALL_STAGES(_cycler) {
1535 CDStageWriter cdata(_cycler, pipeline_stage);
1536 cdata->_active_display_regions_stale =
true;
1538 CLOSE_ITERATE_ALL_STAGES(_cycler);
1548 void GraphicsOutput::
1549 do_determine_display_regions(GraphicsOutput::CData *cdata) {
1550 cdata->_active_display_regions_stale =
false;
1552 cdata->_active_display_regions.clear();
1553 cdata->_active_display_regions.reserve(_total_display_regions.size());
1556 TotalDisplayRegions::const_iterator dri;
1557 for (dri = _total_display_regions.begin();
1558 dri != _total_display_regions.end();
1562 cdata->_active_display_regions.push_back(display_region);
1563 display_region->set_active_index(index);
1566 display_region->set_active_index(-1);
1570 std::stable_sort(cdata->_active_display_regions.begin(),
1571 cdata->_active_display_regions.end(),
1581 unsigned int GraphicsOutput::
1582 parse_color_mask(
const string &word) {
1583 unsigned int result = 0;
1584 vector_string components;
1587 vector_string::const_iterator ci;
1588 for (ci = components.begin(); ci != components.end(); ++ci) {
1590 if (w ==
"red" || w ==
"r") {
1593 }
else if (w ==
"green" || w ==
"g") {
1596 }
else if (w ==
"blue" || w ==
"b") {
1599 }
else if (w ==
"yellow" || w ==
"y") {
1602 }
else if (w ==
"magenta" || w ==
"m") {
1605 }
else if (w ==
"cyan" || w ==
"c") {
1608 }
else if (w ==
"alpha" || w ==
"a") {
1611 }
else if (w ==
"off") {
1614 display_cat.warning()
1615 <<
"Invalid color in red-blue-stereo-colors: " << (*ci) <<
"\n";
1625 GraphicsOutput::CData::
1631 _one_shot_frame = -1;
1632 _active_display_regions_stale =
false;
1638 GraphicsOutput::CData::
1639 CData(
const GraphicsOutput::CData ©) :
1640 _textures(copy._textures),
1641 _active(copy._active),
1642 _one_shot_frame(copy._one_shot_frame),
1643 _active_display_regions(copy._active_display_regions),
1644 _active_display_regions_stale(copy._active_display_regions_stale)
1653 return new CData(*
this);
1660 operator << (std::ostream &out, GraphicsOutput::FrameMode fm) {
1662 case GraphicsOutput::FM_render:
1663 return out <<
"render";
1664 case GraphicsOutput::FM_parasite:
1665 return out <<
"parasite";
1666 case GraphicsOutput::FM_refresh:
1667 return out <<
"refresh";
1670 return out <<
"(**invalid GraphicsOutput::FrameMode(" << (int)fm <<
")**)";
static ClockObject * get_global_clock()
Returns a pointer to the global ClockObject.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void request_close()
This is called by the GraphicsEngine to request that the window (or whatever) close itself or,...
static int get_renderbuffer_type(int plane)
Returns the RenderBuffer::Type that corresponds to a RenderTexturePlane.
void set_size_and_recalc(int x, int y)
Changes the x_size and y_size, then recalculates structures that depend on size.
void cleanup()
Cleans up some pointers associated with the DisplayRegion to help reduce the chance of memory leaks d...
This object provides a high-level interface for quickly writing a sequence of numeric values from a v...
Encapsulates the data from a DisplayRegion, pre-fetched for one stage of the pipeline.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
set_num_views
Sets the number of "views" within a texture.
StereoDisplayRegion * make_stereo_display_region()
Creates a new DisplayRegion that covers the entire window.
virtual GraphicsOutput * get_host()
This is normally called only from within make_texture_buffer().
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...
void set_side_by_side_stereo(bool side_by_side_stereo)
Enables side-by-side stereo mode on this particular window.
std::string get_word(size_t n) const
Returns the variable's nth value.
A base class for any number of different kinds of lenses, linear and otherwise.
const LColor & get_value() const
Returns the variable's value.
get_z_size
Returns the depth of the texture image in texels.
virtual void end_flip()
This function will be called within the draw thread after begin_flip() has been called on all windows...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
set_match_framebuffer_format
Sets the special flag that, if true, indicates to the GSG that the Texture's format should be chosen ...
void change_scenes(DisplayRegionPipelineReader *new_dr)
Called by the GraphicsEngine when the window is about to change to another DisplayRegion.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
set_wrap_v
This setting determines what happens when the texture is sampled with a V value outside the range 0....
This class is similar to CycleDataWriter, except it allows writing to a particular stage of the pipel...
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-...
int get_y_size() const
Returns the visible height of the window or buffer, if it is known.
get_texture_type
Returns the overall interpretation of the texture.
void add_data2(PN_stdfloat x, PN_stdfloat y)
Sets the write row to a particular 2-component value, and advances the write row.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void set_clear_color_active(bool clear_color_active)
Toggles the flag that indicates whether the color buffer should be cleared every frame.
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...
get_child_sort
Returns the sort value of future offscreen buffers created by make_texture_sort().
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
string downcase(const string &s)
Returns the input string with all uppercase letters converted to lowercase.
Defines a series of triangle strips.
A lightweight class that can be used to automatically start and stop a PStatCollector around a sectio...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
is_stereo
Returns true if this is a StereoDisplayRegion, false otherwise.
int get_fb_y_size() const
Returns the internal height of the window or buffer.
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.
void setup_cube_map()
Sets the texture as an empty cube map texture with no dimensions.
get_max_cube_map_dimension
Returns the largest possible texture size in any one dimension for a cube map texture,...
PT(DisplayRegion) GraphicsOutput
Returns the nth DisplayRegion of those that have been created within the window.
DisplayRegion * make_display_region()
Creates a new DisplayRegion that covers the entire window.
static WindowProperties size(const LVecBase2i &size)
Returns a WindowProperties structure with only the size specified.
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
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...
bool is_valid() const
Returns true if the output is fully created and ready for rendering, false otherwise.
void set_texture(Texture *tex, int priority=0)
Adds the indicated texture to the list of textures that will be rendered on the default texture stage...
An STL function object class, this is intended to be used on any ordered collection of pointers to cl...
set_render_to_texture
Sets a flag on the texture that indicates whether the texture is intended to be used as a direct-rend...
void set_size_padded(int x=1, int y=1, int z=1)
Changes the size of the texture, padding if necessary, and setting the pad region as well.
A lightweight class that represents a single element that may be timed and/or counted via stats.
static AutoTextureScale get_textures_power_2()
This flag returns ATS_none, ATS_up, or ATS_down and controls the scaling of textures in general.
get_format
Returns the format of the texture, which represents both the semantic meaning of the texels and,...
virtual void set_close_now()
This is called by the GraphicsEngine to insist that the output be closed immediately.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A container for the various kinds of properties we might ask to have on a graphics window before we o...
virtual void clear_pipe()
Sets the window's _pipe pointer to NULL; this is generally called only as a precursor to deleting the...
void set_clear_stencil_active(bool clear_stencil_active)
Toggles the flag that indicates whether the stencil buffer should be cleared every frame.
virtual void request_open()
This is called by the GraphicsEngine to request that the window (or whatever) open itself or,...
DisplayRegion * make_mono_display_region()
Creates a new DisplayRegion that covers the entire window.
set_sort
Adjusts the sorting order of this particular GraphicsOutput, relative to other GraphicsOutputs.
virtual void clear(Thread *current_thread)
Clears the entire framebuffer before rendering, according to the settings of get_color_clear_active()...
set_one_shot
Changes the current setting of the one-shot flag.
bool get_delete_flag() const
Returns the current setting of the delete flag.
get_frame_count
Returns the number of times tick() has been called since the ClockObject was created,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool setup_depth_texture(Texture *tex) const
Sets the texture up for render-to-texture matching these framebuffer properties.
NodePath attach_new_node(PandaNode *node, int sort=0, Thread *current_thread=Thread::get_current_thread()) const
Attaches a new node, with or without existing parents, to the scene graph below the referenced node o...
set_format
Changes the format value for the texture components.
Similar to MutexHolder, but for a light mutex.
get_pipe
Returns the GraphicsPipe that this window is associated with.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A perspective-type lens: a normal camera.
NodePath get_texture_card()
Returns a PandaNode containing a square polygon.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
void copy_clear_settings(const DrawableRegion ©)
Copies only the clear settings from the other drawable region.
An object to create GraphicsOutputs that share a particular 3-D API.
bool get_clear_depth_active() const
Returns the current setting of the flag that indicates whether the depth buffer should be cleared eve...
void set_clear_depth_active(bool clear_depth_active)
Toggles the flag that indicates whether the depth buffer should be cleared every frame.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A container for geometry primitives.
void add_data3(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)
Sets the write row to a particular 3-component value, and advances the write row.
int get_target_tex_page() const
Returns the target page number associated with this particular DisplayRegion, or -1 if it is not asso...
void set_effect(const RenderEffect *effect)
Adds the indicated render effect to the scene graph on this node.
bool get_clear_stencil_active() const
Returns the current setting of the flag that indicates whether the color buffer should be cleared eve...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void remove_all_display_regions()
Removes all display regions from the window, except the default one that is created with the window.
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
set_color_bits
Sets the number of requested color bits as a single number that represents the sum of the individual ...
get_right_eye
Returns a pointer to the right DisplayRegion managed by this stereo object.
get_supports_cube_map
Returns true if this GSG can render cube map textures.
set_wrap_u
This setting determines what happens when the texture is sampled with a U value outside the range 0....
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...
int get_x_size() const
Returns the visible width of the window or buffer, if it is known.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int get_draw_buffer_type() const
Returns the RenderBuffer into which the GSG should issue draw commands.
virtual void process_events()
Do whatever processing in the window thread is appropriate for this output object each frame.
void clear_ram_image()
Discards the current system-RAM image.
get_num_views
Returns the number of "views" in the texture.
set_target_tex_page
This is a special parameter that is only used when rendering the faces of a cube map or multipage and...
virtual void reset_window(bool swapchain)
Resets the window framebuffer from its derived children.
get_size
Returns size in pixels of the useful part of the window, not including decorations.
void clear_render_textures()
If the GraphicsOutput is currently rendering to a texture, then all textures are dissociated from the...
static void update_type(ReferenceCount *ptr, TypeHandle type)
Associates the indicated type with the given pointer.
bool is_stereo() const
Returns Returns true if this window can render stereo DisplayRegions, either through red-blue stereo ...
set_camera
Sets the camera that is associated with this DisplayRegion.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void tokenize(const string &str, vector_string &words, const string &delimiters, bool discard_repeated_delimiters)
Chops the source string up into pieces delimited by any of the characters specified in delimiters.
virtual void ready_flip()
This function will be called within the draw thread after end_frame() has been called on all windows,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int get_fb_x_size() const
Returns the internal width of the window or buffer.
virtual bool is_any_clear_active() const
Returns true if any of the clear types (so far there are just color or depth) have been set active,...
set_component_type
Changes the data value for the texture components.
set_compression
Requests that this particular Texture be compressed when it is loaded into texture memory.
static int up_to_power_2(int value)
Returns the smallest power of 2 greater than or equal to value.
get_name
Returns the name that was passed to the GraphicsOutput constructor.
PandaNode * node() const
Returns the referenced node of the path.
get_window
Returns the GraphicsOutput that this DisplayRegion is ultimately associated with, or NULL if no windo...
bool setup_color_texture(Texture *tex) const
Sets the texture up for render-to-texture matching these framebuffer properties.
A thread; that is, a lightweight process.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void begin_flip()
This function will be called within the draw thread after end_frame() has been called on all windows,...
get_supports_render_texture
Returns true if this particular GraphicsOutput can render directly into a texture,...
Encapsulates all the communication with a particular instance of a given rendering backend.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_left_eye
Returns a pointer to the left DisplayRegion managed by this stereo object.
set_active
Sets the active flag associated with the GraphicsOutput.
A rectangular subregion within a window for rendering into.
virtual bool flip_ready() const
Returns true if a frame has been rendered and needs to be flipped, false otherwise.
void set_overlay_display_region(DisplayRegion *display_region)
Replaces the special "overlay" DisplayRegion that is created for each window or buffer.
This class is the main interface to controlling the render process.
TypeHandle is the identifier used to differentiate C++ class types.
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_inverted
Changes the current setting of the inverted flag.
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
A node that can be positioned around in the scene graph to represent a point of view for rendering a ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void unshare_depth_buffer()
Discontinue sharing the depth buffer.
A RenderBuffer is an arbitrary subset of the various layers (depth buffer, color buffer,...
get_gsg
Returns the GSG that is associated with this window.
has_size
Returns true if the window size has been specified, false otherwise.
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.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool remove_display_region(DisplayRegion *display_region)
Removes the indicated DisplayRegion from the window, and destructs it if there are no other reference...
A node that holds Geom objects, renderable pieces of geometry.
virtual bool share_depth_buffer(GraphicsOutput *graphics_output)
Will attempt to use the depth buffer of the input graphics_output.
is_active
Returns the active flag associated with the DisplayRegion.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
const FrameBufferProperties & get_fb_properties() const
Returns the framebuffer properties of the window.
void look_at(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)
Sets the transform on this NodePath so that it rotates to face the indicated point in space.