From 25a0389533899aa3216d7d89165bc2eba0c690c1 Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 13 Mar 2001 23:28:01 +0000 Subject: [PATCH] *** empty log message *** --- panda/src/display/graphicsStateGuardian.cxx | 23 +++++++++++++++++++++ panda/src/display/graphicsStateGuardian.h | 3 +++ panda/src/dxgsg/dxGraphicsStateGuardian.cxx | 12 ++++++----- panda/src/glgsg/glGraphicsStateGuardian.cxx | 20 ++++++++---------- 4 files changed, 42 insertions(+), 16 deletions(-) diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index 768e30ea20..95cf2cc4e6 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -94,6 +94,7 @@ reset() { _depth_clear_value = 1.0; _stencil_clear_value = 0.0; _accum_clear_value.set(0.0, 0.0, 0.0, 0.0); + _clear_buffer_type = RenderBuffer::T_back | RenderBuffer::T_depth; _normals_enabled = false; } @@ -330,6 +331,28 @@ set_accum_clear_value(const Colorf& value) { _accum_clear_value = value; } +//////////////////////////////////////////////////////////////////// +// Function: GraphicsStateGuardian::enable_frame_clear +// Access: Public +// Description: Activates or deactivates the automatic clearing of +// the frame buffer and/or depth buffer at the beginning +// of each frame. +// +// If clear_color is true, the color buffer will be +// cleared; if clear_depth is true, the depth buffer +// will be cleared. +//////////////////////////////////////////////////////////////////// +void GraphicsStateGuardian:: +enable_frame_clear(bool clear_color, bool clear_depth) { + _clear_buffer_type = 0; + if (clear_color) { + _clear_buffer_type |= RenderBuffer::T_back; + } + if (clear_depth) { + _clear_buffer_type |= RenderBuffer::T_depth; + } +} + //////////////////////////////////////////////////////////////////// // Function: GraphicsStateGuardian::wants_normals // Access: Public, Virtual diff --git a/panda/src/display/graphicsStateGuardian.h b/panda/src/display/graphicsStateGuardian.h index a12c049e89..7955af2b5b 100644 --- a/panda/src/display/graphicsStateGuardian.h +++ b/panda/src/display/graphicsStateGuardian.h @@ -62,6 +62,8 @@ PUBLISHED: return _accum_clear_value; } + void enable_frame_clear(bool clear_color, bool clear_depth); + public: void release_all_textures(); @@ -138,6 +140,7 @@ protected: float _depth_clear_value; bool _stencil_clear_value; Colorf _accum_clear_value; + int _clear_buffer_type; int _display_region_stack_level; int _frame_buffer_stack_level; diff --git a/panda/src/dxgsg/dxGraphicsStateGuardian.cxx b/panda/src/dxgsg/dxGraphicsStateGuardian.cxx index 5217de74d5..7bc3e5976b 100644 --- a/panda/src/dxgsg/dxGraphicsStateGuardian.cxx +++ b/panda/src/dxgsg/dxGraphicsStateGuardian.cxx @@ -639,11 +639,13 @@ render_frame(const AllAttributesWrapper &initial_state) { _decal_level = 0; - // First, clear the entire window. - PT(DisplayRegion) win_dr = - _win->make_scratch_display_region(_win->get_width(), _win->get_height()); - clear(get_render_buffer(RenderBuffer::T_back | RenderBuffer::T_depth), win_dr); - + if (_clear_buffer_type != 0) { + // First, clear the entire window. + PT(DisplayRegion) win_dr = + _win->make_scratch_display_region(_win->get_width(), _win->get_height()); + clear(get_render_buffer(_clear_buffer_type), win_dr); + } + // Now render each of our layers in order. int max_channel_index = _win->get_max_channel_index(); for (int c = 0; c < max_channel_index; c++) { diff --git a/panda/src/glgsg/glGraphicsStateGuardian.cxx b/panda/src/glgsg/glGraphicsStateGuardian.cxx index 76af81aed6..3ae9be9307 100644 --- a/panda/src/glgsg/glGraphicsStateGuardian.cxx +++ b/panda/src/glgsg/glGraphicsStateGuardian.cxx @@ -463,18 +463,16 @@ render_frame(const AllAttributesWrapper &initial_state) { _win->begin_frame(); _decal_level = 0; - // First, clear the entire window. - PT(DisplayRegion) win_dr = - _win->make_scratch_display_region(_win->get_width(), _win->get_height()); - if (win_dr == (DisplayRegion*)NULL) - { - cerr << "null scratch " << endl; - exit(0); + if (_clear_buffer_type != 0) { + // First, clear the entire window. + PT(DisplayRegion) win_dr = + _win->make_scratch_display_region(_win->get_width(), _win->get_height()); + nassertv(win_dr != (DisplayRegion*)NULL); + DisplayRegionStack old_dr = push_display_region(win_dr); + prepare_display_region(); + clear(get_render_buffer(_clear_buffer_type)); + pop_display_region(old_dr); } - DisplayRegionStack old_dr = push_display_region(win_dr); - prepare_display_region(); - clear(get_render_buffer(RenderBuffer::T_back | RenderBuffer::T_depth)); - pop_display_region(old_dr); // Now render each of our layers in order. int max_channel_index = _win->get_max_channel_index();