15 #include "graphicsOutput.h"
16 #include "graphicsPipe.h"
17 #include "graphicsEngine.h"
18 #include "graphicsWindow.h"
19 #include "config_display.h"
20 #include "lightMutexHolder.h"
21 #include "renderBuffer.h"
22 #include "indirectLess.h"
23 #include "pStatTimer.h"
24 #include "configVariableBool.h"
26 #include "displayRegion.h"
28 #include "perspectiveLens.h"
29 #include "pointerTo.h"
30 #include "compassEffect.h"
33 #include "geomTristrips.h"
34 #include "geomVertexWriter.h"
35 #include "throw_event.h"
36 #include "config_gobj.h"
40 PStatCollector GraphicsOutput::_make_current_pcollector(
"Draw:Make current");
41 PStatCollector GraphicsOutput::_copy_texture_pcollector(
"Draw:Copy texture");
47 _name(name), _look_at(look_at), _up(up) { }
78 bool default_stereo_flags) :
79 _lock(
"GraphicsOutput"),
80 _cull_window_pcollector(_cull_pcollector, name),
81 _draw_window_pcollector(_draw_pcollector, name),
84 #ifdef DO_MEMORY_USAGE
85 MemoryUsage::update_type(
this,
this);
91 _fb_properties = fb_prop;
93 _creation_flags = flags;
95 _is_nonzero_size =
false;
98 _is_nonzero_size = (_size[0] > 0 && _size[1] > 0);
100 if (_creation_flags & GraphicsPipe::BF_size_track_host) {
103 _is_nonzero_size =
true;
108 _target_tex_page = -1;
109 _prev_page_dr = NULL;
112 _got_child_sort =
false;
113 _internal_sort_index = 0;
114 _inverted = window_inverted;
115 _swap_eyes = swap_eyes;
116 _red_blue_stereo =
false;
117 _left_eye_color_mask = 0x0f;
118 _right_eye_color_mask = 0x0f;
119 _side_by_side_stereo =
false;
120 _sbs_left_dimensions.set(0.0f, 1.0f, 0.0f, 1.0f);
121 _sbs_right_dimensions.set(0.0f, 1.0f, 0.0f, 1.0f);
122 _delete_flag =
false;
123 _trigger_copy =
false;
125 if (_fb_properties.is_single_buffered()) {
126 _draw_buffer_type = RenderBuffer::T_front;
128 _draw_buffer_type = RenderBuffer::T_back;
131 if (default_stereo_flags) {
134 _red_blue_stereo = red_blue_stereo && !fb_prop.is_stereo();
135 if (_red_blue_stereo) {
136 _left_eye_color_mask = parse_color_mask(red_blue_stereo_colors.
get_word(0));
137 _right_eye_color_mask = parse_color_mask(red_blue_stereo_colors.
get_word(1));
139 _side_by_side_stereo = side_by_side_stereo && !fb_prop.is_stereo();
140 if (_side_by_side_stereo) {
141 _sbs_left_dimensions.set(sbs_left_dimensions[0], sbs_left_dimensions[1],
142 sbs_left_dimensions[2], sbs_left_dimensions[3]);
143 _sbs_right_dimensions.set(sbs_right_dimensions[0], sbs_right_dimensions[1],
144 sbs_right_dimensions[2], sbs_right_dimensions[3]);
151 _overlay_display_region = make_mono_display_region(0.0f, 1.0f, 0.0f, 1.0f);
152 _overlay_display_region->set_active(
false);
153 _overlay_display_region->set_scissor_enabled(
false);
157 CDWriter cdata(_cycler,
true);
158 cdata->_active =
true;
163 set_clear_color_active(
true);
164 set_clear_depth_active(
true);
165 set_clear_stencil_active(
true);
166 set_clear_color(background_color.
get_value());
176 _cull_window_pcollector(_cull_pcollector,
"Invalid"),
177 _draw_window_pcollector(_draw_pcollector,
"Invalid")
187 void GraphicsOutput::
209 TotalDisplayRegions::iterator dri;
210 for (dri = _total_display_regions.begin();
211 dri != _total_display_regions.end();
213 (*dri)->_window = NULL;
216 _total_display_regions.clear();
217 _overlay_display_region = NULL;
230 cdata->_textures.clear();
231 ++(cdata->_textures_seq);
232 throw_event(
"render-texture-targets-changed");
278 RenderTexturePlane plane) {
280 if (mode == RTM_none) {
301 if (plane == RTP_COUNT) {
302 if (tex->
get_format() == Texture::F_depth_stencil) {
303 plane = RTP_depth_stencil;
304 }
else if (tex->
get_format() == Texture::F_depth_component) {
314 if (plane == RTP_depth) {
317 }
else if (plane == RTP_depth_stencil) {
321 }
else if ((plane == RTP_color)||
322 (plane == RTP_aux_rgba_0)||
323 (plane == RTP_aux_rgba_1)||
324 (plane == RTP_aux_rgba_2)||
325 (plane == RTP_aux_rgba_3)) {
328 }
else if ((plane == RTP_aux_hrgba_0)||
329 (plane == RTP_aux_hrgba_1)||
330 (plane == RTP_aux_hrgba_2)||
331 (plane == RTP_aux_hrgba_3)) {
334 }
else if ((plane == RTP_aux_float_0)||
335 (plane == RTP_aux_float_1)||
336 (plane == RTP_aux_float_2)||
337 (plane == RTP_aux_float_3)) {
342 display_cat.error() <<
343 "add_render_texture: invalid bitplane specified.\n";
352 if (_fb_properties.is_stereo() && plane == RTP_color) {
361 if (mode == RTM_bind_or_copy) {
362 mode = RTM_copy_texture;
363 }
else if (mode == RTM_bind_layered) {
367 display_cat.error() <<
368 "add_render_texture: RTM_bind_layered was requested but "
369 "render-to-texture is not supported or has been disabled!\n";
373 if (mode == RTM_bind_layered && _gsg != NULL && !_gsg->get_supports_geometry_shaders()) {
376 display_cat.warning() <<
377 "add_render_texture: RTM_bind_layered was requested but "
378 "geometry shaders are not supported!\n";
381 if (mode == RTM_bind_or_copy || mode == RTM_bind_layered) {
388 RenderTexture result;
389 result._texture = tex;
390 result._plane = plane;
391 result._rtm_mode = mode;
392 cdata->_textures.push_back(result);
393 ++(cdata->_textures_seq);
395 throw_event(
"render-texture-targets-changed");
409 display_cat.warning() <<
410 "Using deprecated setup_render_texture interface.\n";
414 }
else if (allow_bind) {
431 if (cdata->_active != active) {
433 cdataw->_active = active;
450 if (cdata->_one_shot_frame != -1) {
457 return cdata->_active;
487 cdata->_one_shot_frame = -1;
523 if (_inverted != inverted) {
524 _inverted = inverted;
529 TotalDisplayRegions::iterator dri;
530 for (dri = _total_display_regions.begin();
531 dri != _total_display_regions.end();
559 left.set(sbs_left_dimensions[0], sbs_left_dimensions[1],
560 sbs_left_dimensions[2], sbs_left_dimensions[3]);
561 right.set(sbs_right_dimensions[0], sbs_right_dimensions[1],
562 sbs_right_dimensions[2], sbs_right_dimensions[3]);
587 _side_by_side_stereo = side_by_side_stereo;
588 if (_side_by_side_stereo) {
589 _sbs_left_dimensions = sbs_left_dimensions;
590 _sbs_right_dimensions = sbs_right_dimensions;
592 _sbs_left_dimensions.set(0.0f, 1.0f, 0.0f, 1.0f);
593 _sbs_right_dimensions.set(0.0f, 1.0f, 0.0f, 1.0f);
609 for (
int i = 0; i < (int)_hold_textures.size(); i++) {
610 if (_hold_textures[i].is_valid_pointer()) {
629 _gsg->get_engine()->set_window_sort(
this, sort);
650 if (
is_stereo() && default_stereo_camera) {
673 if (_side_by_side_stereo) {
697 if (_side_by_side_stereo) {
700 PN_stdfloat left_l = _sbs_left_dimensions[0];
701 PN_stdfloat left_b = _sbs_left_dimensions[2];
702 PN_stdfloat left_w = _sbs_left_dimensions[1] - _sbs_left_dimensions[0];
703 PN_stdfloat left_h = _sbs_left_dimensions[3] - _sbs_left_dimensions[2];
704 LVecBase4 left_dimensions(dimensions[0] * left_w + left_l,
705 dimensions[1] * left_w + left_l,
706 dimensions[2] * left_h + left_b,
707 dimensions[3] * left_h + left_b);
710 PN_stdfloat right_l = _sbs_right_dimensions[0];
711 PN_stdfloat right_b = _sbs_right_dimensions[2];
712 PN_stdfloat right_w = _sbs_right_dimensions[1] - _sbs_right_dimensions[0];
713 PN_stdfloat right_h = _sbs_right_dimensions[3] - _sbs_right_dimensions[2];
714 LVecBase4 right_dimensions(dimensions[0] * right_w + right_l,
715 dimensions[1] * right_w + right_l,
716 dimensions[2] * right_h + right_b,
717 dimensions[3] * right_h + right_b);
736 right->set_clear_depth_active(
true);
739 right->set_clear_stencil_active(
true);
762 nassertr(display_region != _overlay_display_region,
false);
766 DCAST_INTO_R(sdr, display_region,
false);
771 return do_remove_display_region(display_region);
785 cdata->_active_display_regions_stale =
true;
787 TotalDisplayRegions::iterator dri;
788 for (dri = _total_display_regions.begin();
789 dri != _total_display_regions.end();
792 if (display_region != _overlay_display_region) {
795 display_region->_window = NULL;
798 _total_display_regions.clear();
799 _total_display_regions.push_back(_overlay_display_region);
823 nassertv(display_region->
get_window() ==
this);
824 _overlay_display_region = display_region;
835 determine_display_regions();
839 result = _total_display_regions.size();
854 get_display_region(
int n)
const {
855 determine_display_regions();
859 if (n >= 0 && n < (
int)_total_display_regions.size()) {
860 result = _total_display_regions[n];
876 determine_display_regions();
878 return cdata->_active_display_regions.size();
891 get_active_display_region(
int n)
const {
892 determine_display_regions();
894 CDReader cdata(_cycler);
895 if (n >= 0 && n < (
int)cdata->_active_display_regions.size()) {
896 return cdata->_active_display_regions[n];
939 props.set_rgb_color(1);
941 props.set_alpha_bits(1);
942 props.set_depth_bits(1);
948 int flags = GraphicsPipe::BF_refuse_window;
949 if (textures_power_2 != ATS_none) {
950 flags |= GraphicsPipe::BF_size_power_2;
954 flags |= GraphicsPipe::BF_size_square;
1012 display_cat.warning()
1013 <<
"Cannot make dynamic cube map; GSG does not support cube maps.\n";
1016 if (max_dimension > 0) {
1017 size = min(max_dimension, size);
1029 tex->setup_cube_map();
1030 tex->set_wrap_u(SamplerState::WM_clamp);
1031 tex->set_wrap_v(SamplerState::WM_clamp);
1044 for (
int i = 0; i < 6; i++) {
1046 camera->set_lens(lens);
1047 camera->set_camera_mask(camera_mask);
1049 camera_np.
look_at(cube_faces[i]._look_at, cube_faces[i]._up);
1081 if (_texture_card == NULL) {
1084 strip->set_shade_model(Geom::SM_uniform);
1085 strip->add_next_vertices(4);
1086 strip->close_primitive();
1088 geom->add_primitive(strip);
1089 _texture_card =
new GeomNode(
"texture card");
1090 _texture_card->add_geom(geom);
1101 RenderTextures::const_iterator ri;
1102 for (ri = cdata->_textures.begin(); ri != cdata->_textures.end(); ++ri) {
1103 Texture *texture = (*ri)._texture;
1104 if ((texture->
get_format() != Texture::F_depth_stencil)) {
1217 <<
"Resetting " << get_type() <<
"\n";
1246 _is_nonzero_size = (x > 0 && y > 0);
1251 TotalDisplayRegions::iterator dri;
1252 for (dri = _total_display_regions.begin();
1253 dri != _total_display_regions.end();
1255 (*dri)->compute_pixels_all_stages(fb_x_size, fb_y_size);
1258 if (_texture_card != NULL && _texture_card->get_num_geoms() > 0) {
1259 _texture_card->modify_geom(0)->set_vertex_data(create_texture_card_vdata(x, y));
1276 if (display_cat.is_spam()) {
1278 <<
"clear(): " << get_type() <<
" "
1279 <<
get_name() <<
" " << (
void *)
this <<
"\n";
1285 _gsg->prepare_display_region(&dr_reader);
1328 if (new_target_tex_page != -1 && new_target_tex_page != _target_tex_page) {
1330 if (new_target_tex_page == -1) {
1331 new_target_tex_page = 0;
1333 int old_target_tex_page = _target_tex_page;
1335 _target_tex_page = new_target_tex_page;
1336 _prev_page_dr = new_dr->get_object();
1339 RenderTextures::const_iterator ri;
1340 for (ri = cdata->_textures.begin(); ri != cdata->_textures.end(); ++ri) {
1341 RenderTextureMode rtm_mode = (*ri)._rtm_mode;
1342 RenderTexturePlane plane = (*ri)._plane;
1343 Texture *texture = (*ri)._texture;
1344 if (rtm_mode != RTM_none) {
1345 if (rtm_mode == RTM_bind_or_copy || rtm_mode == RTM_bind_layered) {
1351 }
else if (old_target_tex_page != -1) {
1356 if (display_cat.is_debug()) {
1358 <<
"Copying texture for " <<
get_name() <<
" at scene change.\n";
1360 <<
"target_tex_page = " << old_target_tex_page <<
"\n";
1365 if (plane == RTP_color && _fb_properties.is_stereo()) {
1367 RenderBuffer left(_gsg, buffer._buffer_type & ~RenderBuffer::T_right);
1368 RenderBuffer right(_gsg, buffer._buffer_type & ~RenderBuffer::T_left);
1370 if (rtm_mode == RTM_copy_ram) {
1371 _gsg->framebuffer_copy_to_ram(texture, 0, old_target_tex_page,
1373 _gsg->framebuffer_copy_to_ram(texture, 1, old_target_tex_page,
1374 old_page_dr, right);
1376 _gsg->framebuffer_copy_to_texture(texture, 0, old_target_tex_page,
1378 _gsg->framebuffer_copy_to_texture(texture, 1, old_target_tex_page,
1379 old_page_dr, right);
1382 if (rtm_mode == RTM_copy_ram) {
1383 _gsg->framebuffer_copy_to_ram(texture, 0, old_target_tex_page,
1384 old_page_dr, buffer);
1386 _gsg->framebuffer_copy_to_texture(texture, 0, old_target_tex_page,
1387 old_page_dr, buffer);
1454 _flip_ready =
false;
1475 void GraphicsOutput::
1476 pixel_factor_changed() {
1488 void GraphicsOutput::
1489 prepare_for_deletion() {
1490 CDWriter cdata(_cycler,
true);
1491 cdata->_active =
false;
1495 RenderTextures::iterator ri;
1496 for (ri = cdata->_textures.begin(); ri != cdata->_textures.end(); ++ri) {
1497 if ((*ri)._rtm_mode == RTM_bind_or_copy || (*ri)._rtm_mode == RTM_bind_layered) {
1498 _hold_textures.push_back((*ri)._texture);
1501 cdata->_textures.clear();
1503 _delete_flag =
true;
1521 void GraphicsOutput::
1522 promote_to_copy_texture() {
1523 CDLockedReader cdata(_cycler);
1524 RenderTextures::const_iterator ri;
1526 bool any_bind =
false;
1527 for (ri = cdata->_textures.begin(); ri != cdata->_textures.end(); ++ri) {
1528 if ((*ri)._rtm_mode == RTM_bind_or_copy) {
1535 RenderTextures::iterator ri;
1536 for (ri = cdataw->_textures.begin(); ri != cdataw->_textures.end(); ++ri) {
1537 if ((*ri)._rtm_mode == RTM_bind_or_copy) {
1538 (*ri)._rtm_mode = RTM_copy_texture;
1554 bool GraphicsOutput::
1555 copy_to_textures() {
1558 CDReader cdata(_cycler);
1559 RenderTextures::const_iterator ri;
1560 for (ri = cdata->_textures.begin(); ri != cdata->_textures.end(); ++ri) {
1561 RenderTextureMode rtm_mode = (*ri)._rtm_mode;
1562 if ((rtm_mode == RTM_none) || (rtm_mode == RTM_bind_or_copy)) {
1566 Texture *texture = (*ri)._texture;
1569 if ((rtm_mode == RTM_copy_texture)||
1570 (rtm_mode == RTM_copy_ram)||
1571 ((rtm_mode == RTM_triggered_copy_texture)&&(_trigger_copy))||
1572 ((rtm_mode == RTM_triggered_copy_ram)&&(_trigger_copy))) {
1573 if (display_cat.is_debug()) {
1575 <<
"Copying texture for " <<
get_name() <<
" at frame end.\n";
1577 <<
"target_tex_page = " << _target_tex_page <<
"\n";
1579 RenderTexturePlane plane = (*ri)._plane;
1581 if (plane == RTP_color) {
1586 bool copied =
false;
1592 if (plane == RTP_color && _fb_properties.is_stereo()) {
1594 RenderBuffer left(_gsg, buffer._buffer_type & ~RenderBuffer::T_right);
1595 RenderBuffer right(_gsg, buffer._buffer_type & ~RenderBuffer::T_left);
1597 if ((rtm_mode == RTM_copy_ram)||(rtm_mode == RTM_triggered_copy_ram)) {
1598 copied = _gsg->framebuffer_copy_to_ram(texture, 0, _target_tex_page,
1600 copied = _gsg->framebuffer_copy_to_ram(texture, 1, _target_tex_page,
1601 dr, right) && copied;
1603 copied = _gsg->framebuffer_copy_to_texture(texture, 0, _target_tex_page,
1605 copied = _gsg->framebuffer_copy_to_texture(texture, 1, _target_tex_page,
1606 dr, right) && copied;
1609 if ((rtm_mode == RTM_copy_ram)||(rtm_mode == RTM_triggered_copy_ram)) {
1610 copied = _gsg->framebuffer_copy_to_ram(texture, 0, _target_tex_page,
1613 copied = _gsg->framebuffer_copy_to_texture(texture, 0, _target_tex_page,
1622 _trigger_copy =
false;
1633 create_texture_card_vdata(
int x,
int y) {
1634 PN_stdfloat xhi = 1.0;
1635 PN_stdfloat yhi = 1.0;
1640 xhi = (x * 1.0f) / xru;
1641 yhi = (y * 1.0f) / yru;
1644 CPT(GeomVertexFormat) format = GeomVertexFormat::get_v3n3t2();
1647 ("card", format,
Geom::UH_static);
1653 vertex.add_data3(LVertex::rfu(-1.0f, 0.0f, 1.0f));
1654 vertex.add_data3(LVertex::rfu(-1.0f, 0.0f, -1.0f));
1655 vertex.add_data3(LVertex::rfu( 1.0f, 0.0f, 1.0f));
1656 vertex.add_data3(LVertex::rfu( 1.0f, 0.0f, -1.0f));
1658 texcoord.add_data2( 0.0f, yhi);
1659 texcoord.add_data2( 0.0f, 0.0f);
1660 texcoord.add_data2( xhi, yhi);
1661 texcoord.add_data2( xhi, 0.0f);
1663 normal.add_data3(
LVector3::back());
1664 normal.add_data3(
LVector3::back());
1665 normal.add_data3(
LVector3::back());
1666 normal.add_data3(
LVector3::back());
1680 CDWriter cdata(_cycler,
true);
1681 cdata->_active_display_regions_stale =
true;
1683 _total_display_regions.push_back(display_region);
1685 return display_region;
1694 bool GraphicsOutput::
1696 nassertr(display_region != _overlay_display_region,
false);
1699 TotalDisplayRegions::iterator dri =
1700 find(_total_display_regions.begin(), _total_display_regions.end(), drp);
1701 if (dri != _total_display_regions.end()) {
1703 CDWriter cdata(_cycler,
true);
1704 display_region->cleanup();
1705 display_region->_window = NULL;
1706 _total_display_regions.erase(dri);
1708 cdata->_active_display_regions_stale =
true;
1722 void GraphicsOutput::
1723 do_determine_display_regions(GraphicsOutput::CData *cdata) {
1724 cdata->_active_display_regions_stale =
false;
1726 cdata->_active_display_regions.clear();
1727 cdata->_active_display_regions.reserve(_total_display_regions.size());
1730 TotalDisplayRegions::const_iterator dri;
1731 for (dri = _total_display_regions.begin();
1732 dri != _total_display_regions.end();
1736 cdata->_active_display_regions.push_back(display_region);
1737 display_region->set_active_index(index);
1740 display_region->set_active_index(-1);
1756 unsigned int GraphicsOutput::
1757 parse_color_mask(
const string &word) {
1758 unsigned int result = 0;
1759 vector_string components;
1760 tokenize(word, components,
"|");
1762 vector_string::const_iterator ci;
1763 for (ci = components.begin(); ci != components.end(); ++ci) {
1764 string w = downcase(*ci);
1765 if (w ==
"red" || w ==
"r") {
1768 }
else if (w ==
"green" || w ==
"g") {
1771 }
else if (w ==
"blue" || w ==
"b") {
1774 }
else if (w ==
"yellow" || w ==
"y") {
1777 }
else if (w ==
"magenta" || w ==
"m") {
1780 }
else if (w ==
"cyan" || w ==
"c") {
1783 }
else if (w ==
"alpha" || w ==
"a") {
1786 }
else if (w ==
"off") {
1789 display_cat.warning()
1790 <<
"Invalid color in red-blue-stereo-colors: " << (*ci) <<
"\n";
1802 GraphicsOutput::CData::
1808 _one_shot_frame = -1;
1809 _active_display_regions_stale =
false;
1817 GraphicsOutput::CData::
1818 CData(
const GraphicsOutput::CData ©) :
1819 _textures(copy._textures),
1820 _active(copy._active),
1821 _one_shot_frame(copy._one_shot_frame),
1822 _active_display_regions(copy._active_display_regions),
1823 _active_display_regions_stale(copy._active_display_regions_stale)
1834 return new CData(*
this);
1842 operator << (ostream &out, GraphicsOutput::FrameMode fm) {
1844 case GraphicsOutput::FM_render:
1845 return out <<
"render";
1846 case GraphicsOutput::FM_parasite:
1847 return out <<
"parasite";
1848 case GraphicsOutput::FM_refresh:
1849 return out <<
"refresh";
1852 return out <<
"(**invalid GraphicsOutput::FrameMode(" << (int)fm <<
")**)";
Format get_format() const
Returns the format of the texture, which represents both the semantic meaning of the texels and...
static ClockObject * get_global_clock()
Returns a pointer to the global ClockObject.
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.
virtual void set_sort(int sort)
Adjusts the sorting order of this particular GraphicsOutput, relative to other GraphicsOutputs.
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.
void set_one_shot(bool one_shot)
Changes the current setting of the one-shot flag.
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().
void set_side_by_side_stereo(bool side_by_side_stereo)
Enables side-by-side stereo mode on this particular window.
static WindowProperties size(int x_size, int y_size)
Returns a WindowProperties structure with only the size specified.
bool is_stereo() const
Returns Returns true if this window can render stereo DisplayRegions, either through red-blue stereo ...
A base class for any number of different kinds of lenses, linear and otherwise.
virtual void end_flip()
This function will be called within the draw thread after begin_flip() has been called on all windows...
virtual bool is_stereo() const
Returns true if this is a StereoDisplayRegion, false otherwise.
void change_scenes(DisplayRegionPipelineReader *new_dr)
Called by the GraphicsEngine when the window is about to change to another DisplayRegion.
bool is_active() const
Returns the active flag associated with the DisplayRegion.
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...
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-...
virtual void set_target_tex_page(int page)
This is a special parameter that is only used when rendering the faces of a cube map or multipage and...
void set_format(Format format)
Changes the format value for the texture components.
int get_max_cube_map_dimension() const
Returns the largest possible texture size in any one dimension for a cube map texture, or -1 if there is no particular limit.
void set_match_framebuffer_format(bool flag)
Sets the special flag that, if true, indicates to the GSG that the Texture's format should be chosen ...
int get_num_active_display_regions() const
Returns the number of active DisplayRegions that have been created within the window.
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...
PandaNode * node() const
Returns the referenced node of the path.
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Defines a series of triangle strips.
A lightweight class that can be used to automatically start and stop a PStatCollector around a sectio...
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
int get_y_size() const
Returns the visible height of the window or buffer, if it is known.
GraphicsOutput * make_cube_map(const string &name, int size, NodePath &camera_rig, DrawMask camera_mask=PandaNode::get_all_camera_mask(), bool to_ram=false, FrameBufferProperties *fbp=NULL)
This is similar to make_texture_buffer() in that it allocates a separate buffer suitable for renderin...
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...
DisplayRegion * make_display_region()
Creates a new DisplayRegion that covers the entire window.
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
GraphicsPipe * get_pipe() const
Returns the GraphicsPipe that this window is associated with.
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...
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...
bool is_valid() const
Returns true if the output is fully created and ready for rendering, false otherwise.
An STL function object class, this is intended to be used on any ordered collection of pointers to cl...
int get_child_sort() const
Returns the sort value of future offscreen buffers created by make_texture_sort().
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...
bool get_clear_stencil_active() const
Returns the current setting of the flag that indicates whether the color buffer should be cleared eve...
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...
virtual void set_close_now()
This is called by the GraphicsEngine to insist that the output be closed immediately.
DisplayRegion * get_right_eye()
Returns a pointer to the right DisplayRegion managed by this stereo object.
const LVector2i & get_size() const
Returns size in pixels of the useful part of the window, not including decorations.
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.
int get_draw_buffer_type() const
Returns the RenderBuffer into which the GSG should issue draw commands.
void clear(Thread *current_thread)
Clears the entire framebuffer before rendering, according to the settings of get_color_clear_active()...
int get_z_size() const
Returns the depth of the texture image in texels.
GraphicsOutput * get_window() const
Returns the GraphicsOutput that this DisplayRegion is ultimately associated with, or NULL if no windo...
int get_num_views() const
Returns the number of "views" in the texture.
void set_wrap_v(WrapMode wrap)
This setting determines what happens when the texture is sampled with a V value outside the range 0...
Similar to MutexHolder, but for a light mutex.
void set_active(bool active)
Sets the active flag associated with the GraphicsOutput.
virtual PreparedGraphicsObjects * get_prepared_objects()
Returns the set of texture and geom objects that have been prepared with this GSG (and possibly other...
void set_inverted(bool inverted)
Changes the current setting of the inverted flag.
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.
int get_frame_count(Thread *current_thread=Thread::get_current_thread()) const
Returns the number of times tick() has been called since the ClockObject was created, or since it was last reset.
This template class calls PipelineCycler::read() in the constructor and PipelineCycler::release_read(...
void set_clear_depth_active(bool clear_depth_active)
Toggles the flag that indicates whether the depth buffer should be cleared every frame.
A container for geometry primitives.
virtual void set_stereo_channel(Lens::StereoChannel stereo_channel)
Specifies whether the DisplayRegion represents the left or right channel of a stereo pair...
GraphicsStateGuardian * get_gsg() const
Returns the GSG that is associated with this window.
const LColor & get_value() const
Returns the variable's value.
void set_effect(const RenderEffect *effect)
Adds the indicated render effect to the scene graph on this node.
void set_render_to_texture(bool render_to_texture)
Sets a flag on the texture that indicates whether the texture is intended to be used as a direct-rend...
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...
TextureType get_texture_type() const
Returns the overall interpretation of the texture.
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...
void set_compression(CompressionMode compression)
Requests that this particular Texture be compressed when it is loaded into texture memory...
int get_num_display_regions() const
Returns the number of DisplayRegions that have been created within the window, active or otherwise...
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.
virtual void reset_window(bool swapchain)
Resets the window framebuffer from its derived children.
void clear_render_textures()
If the GraphicsOutput is currently rendering to a texture, then all textures are dissociated from the...
bool has_size() const
Returns true if the window size has been specified, false otherwise.
void set_num_views(int num_views)
Sets the number of "views" within a texture.
This is the base class for all three-component vectors and points.
virtual void ready_flip()
This function will be called within the draw thread after end_frame() has been called on all windows...
void set_wrap_u(WrapMode wrap)
This setting determines what happens when the texture is sampled with a U value outside the range 0...
int get_x_size() const
Returns the visible width of the window or buffer, if it is known.
void set_component_type(ComponentType component_type)
Changes the data value for the texture components.
bool get_delete_flag() const
Returns the current setting of the delete flag.
static int up_to_power_2(int value)
Returns the smallest power of 2 greater than or equal to value.
virtual void set_camera(const NodePath &camera)
Sets the camera that is associated with this DisplayRegion.
A thread; that is, a lightweight process.
virtual bool flip_ready() const
Returns true if a frame has been rendered and needs to be flipped, false otherwise.
int get_fb_x_size() const
Returns the internal width of the window or buffer.
GraphicsOutput * make_texture_buffer(const string &name, int x_size, int y_size, Texture *tex=NULL, bool to_ram=false, FrameBufferProperties *fbp=NULL)
Creates and returns an offscreen buffer for rendering into, the result of which will be a texture sui...
virtual void begin_flip()
This function will be called within the draw thread after end_frame() has been called on all windows...
bool get_clear_depth_active() const
Returns the current setting of the flag that indicates whether the depth buffer should be cleared eve...
Encapsulates all the communication with a particular instance of a given rendering backend...
bool get_supports_cube_map() const
Returns true if this GSG can render cube map textures.
virtual bool get_supports_render_texture() const
Returns true if this particular GraphicsOutput can render directly into a texture, or false if it must always copy-to-texture at the end of each frame to achieve this effect.
int get_target_tex_page() const
Returns the target page number associated with this particular DisplayRegion, or -1 if it is not asso...
int get_fb_y_size() const
Returns the internal height of the window or buffer.
A rectangular subregion within a window for rendering into.
GraphicsEngine * get_engine() const
Returns the graphics engine that created this GSG.
void set_color_bits(int n)
Sets the number of requested color bits as a single number that represents the sum of the individual ...
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.
const FrameBufferProperties & get_fb_properties() const
Returns the framebuffer properties of the window.
TypeHandle is the identifier used to differentiate C++ class types.
DisplayRegion * get_left_eye()
Returns a pointer to the left DisplayRegion managed by this stereo object.
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, and appends it to the list of render textures.
bool get_one_shot() const
Returns the current setting of the one-shot 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 ...
const string & get_name() const
Returns the name that was passed to the GraphicsOutput constructor.
void add_child(PandaNode *child_node, int sort=0, Thread *current_thread=Thread::get_current_thread())
Adds a new child to the node.
virtual void unshare_depth_buffer()
Discontinue sharing the depth buffer.
virtual bool is_active() const
Returns true if the window is ready to be rendered into, false otherwise.
A RenderBuffer is an arbitrary subset of the various layers (depth buffer, color buffer, etc.) of a drawing region.
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...
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.
string get_word(int n) const
Returns the variable's nth value.
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...
virtual bool share_depth_buffer(GraphicsOutput *graphics_output)
Will attempt to use the depth buffer of the input graphics_output.
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...