move clear() to DisplayRegion and GraphicsWindow objects instead of on GSG
This commit is contained in:
parent
95937ce7a2
commit
a52a3be557
|
|
@ -10,7 +10,9 @@
|
|||
#define COMBINED_SOURCES $[TARGET]_composite1.cxx $[TARGET]_composite2.cxx
|
||||
|
||||
#define SOURCES \
|
||||
config_display.h displayRegion.I displayRegion.h \
|
||||
config_display.h \
|
||||
clearableRegion.I clearableRegion.h \
|
||||
displayRegion.I displayRegion.h \
|
||||
displayRegionStack.I \
|
||||
displayRegionStack.h \
|
||||
frameBufferStack.I frameBufferStack.h \
|
||||
|
|
@ -31,7 +33,9 @@
|
|||
savedFrameBuffer.I savedFrameBuffer.h
|
||||
|
||||
#define INCLUDED_SOURCES \
|
||||
config_display.cxx displayRegion.cxx \
|
||||
config_display.cxx \
|
||||
clearableRegion.cxx \
|
||||
displayRegion.cxx \
|
||||
geomContext.cxx geomNodeContext.cxx graphicsChannel.cxx \
|
||||
graphicsEngine.cxx \
|
||||
graphicsLayer.cxx graphicsPipe.cxx graphicsStateGuardian.cxx \
|
||||
|
|
@ -42,6 +46,7 @@
|
|||
|
||||
#define INSTALL_HEADERS \
|
||||
config_display.h \
|
||||
clearableRegion.I clearableRegion.h \
|
||||
displayRegion.I displayRegion.h displayRegionStack.I \
|
||||
displayRegionStack.h \
|
||||
frameBufferStack.I frameBufferStack.h \
|
||||
|
|
|
|||
|
|
@ -0,0 +1,198 @@
|
|||
// Filename: clearableRegion.I
|
||||
// Created by: drose (11Jul02)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://www.panda3d.org/license.txt .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d@yahoogroups.com .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ClearableRegion::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE ClearableRegion::
|
||||
ClearableRegion() :
|
||||
_flags(0),
|
||||
_clear_color(0.0f, 0.0f, 0.0f, 0.0f),
|
||||
_clear_depth(1.0f)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ClearableRegion::Copy Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE ClearableRegion::
|
||||
ClearableRegion(const ClearableRegion ©) :
|
||||
_flags(copy._flags),
|
||||
_clear_color(copy._clear_color),
|
||||
_clear_depth(copy._clear_depth)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ClearableRegion::Copy Assignment Operator
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void ClearableRegion::
|
||||
operator = (const ClearableRegion ©) {
|
||||
_flags = copy._flags;
|
||||
_clear_color = copy._clear_color;
|
||||
_clear_depth = copy._clear_depth;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ClearableRegion::copy_clear_settings
|
||||
// Access: Public
|
||||
// Description: A convenience function that does the same thing as
|
||||
// the assignment operator; this is just syntactically a
|
||||
// little nicer (and a little clearer) to call from a
|
||||
// derived class.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void ClearableRegion::
|
||||
copy_clear_settings(const ClearableRegion ©) {
|
||||
operator = (copy);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ClearableRegion::set_clear_color_active
|
||||
// Access: Published
|
||||
// Description: Toggles the flag that indicates whether the color
|
||||
// buffer should be cleared every frame. If this is
|
||||
// true, the color buffer will be cleared to the color
|
||||
// indicated by set_clear_color(); otherwise, it will be
|
||||
// left alone.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void ClearableRegion::
|
||||
set_clear_color_active(bool clear_color_active) {
|
||||
if (clear_color_active) {
|
||||
_flags |= F_clear_color_active;
|
||||
} else {
|
||||
_flags &= ~F_clear_color_active;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ClearableRegion::get_clear_color_active
|
||||
// Access: Published
|
||||
// Description: Returns the current setting of the flag that
|
||||
// indicates whether the color buffer should be cleared
|
||||
// every frame. See set_clear_color_active().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool ClearableRegion::
|
||||
get_clear_color_active() const {
|
||||
return ((_flags & F_clear_color_active) != 0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ClearableRegion::set_clear_depth_active
|
||||
// Access: Published
|
||||
// Description: Toggles the flag that indicates whether the depth
|
||||
// buffer should be cleared every frame. If this is
|
||||
// true, the depth buffer will be cleared to the depth
|
||||
// value indicated by set_clear_depth(); otherwise, it
|
||||
// will be left alone.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void ClearableRegion::
|
||||
set_clear_depth_active(bool clear_depth_active) {
|
||||
if (clear_depth_active) {
|
||||
_flags |= F_clear_depth_active;
|
||||
} else {
|
||||
_flags &= ~F_clear_depth_active;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ClearableRegion::get_clear_depth_active
|
||||
// Access: Published
|
||||
// Description: Returns the current setting of the flag that
|
||||
// indicates whether the depth buffer should be cleared
|
||||
// every frame. See set_clear_depth_active().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool ClearableRegion::
|
||||
get_clear_depth_active() const {
|
||||
return ((_flags & F_clear_depth_active) != 0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ClearableRegion::set_clear_color
|
||||
// Access: Published
|
||||
// Description: Sets the clear color to the indicated value. This is
|
||||
// the value that will be used to clear the color buffer
|
||||
// every frame, but only if get_clear_color_active()
|
||||
// returns true. If get_clear_color_active() returns
|
||||
// false, this is meaningless.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void ClearableRegion::
|
||||
set_clear_color(const Colorf &color) {
|
||||
_clear_color = color;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ClearableRegion::get_clear_color
|
||||
// Access: Published
|
||||
// Description: Returns the current clear color value. This is
|
||||
// the value that will be used to clear the color buffer
|
||||
// every frame, but only if get_clear_color_active()
|
||||
// returns true. If get_clear_color_active() returns
|
||||
// false, this is meaningless.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const Colorf &ClearableRegion::
|
||||
get_clear_color() const {
|
||||
return _clear_color;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ClearableRegion::set_clear_depth
|
||||
// Access: Published
|
||||
// Description: Sets the clear depth to the indicated value. This is
|
||||
// the value that will be used to clear the depth buffer
|
||||
// every frame, but only if get_clear_depth_active()
|
||||
// returns true. If get_clear_depth_active() returns
|
||||
// false, this is meaningless.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void ClearableRegion::
|
||||
set_clear_depth(float depth) {
|
||||
_clear_depth = depth;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ClearableRegion::get_clear_depth
|
||||
// Access: Published
|
||||
// Description: Returns the current clear depth value. This is
|
||||
// the value that will be used to clear the depth buffer
|
||||
// every frame, but only if get_clear_depth_active()
|
||||
// returns true. If get_clear_depth_active() returns
|
||||
// false, this is meaningless.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE float ClearableRegion::
|
||||
get_clear_depth() const {
|
||||
return _clear_depth;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ClearableRegion::is_any_clear_active
|
||||
// Access: Published
|
||||
// Description: Returns true if any of the clear types (so far there
|
||||
// are just color or depth) have been set active, or
|
||||
// false if none of them are active and there is no need
|
||||
// to clear.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool ClearableRegion::
|
||||
is_any_clear_active() const {
|
||||
return (_flags != 0);
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
// Filename: clearableRegion.cxx
|
||||
// Created by: drose (11Jul02)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://www.panda3d.org/license.txt .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d@yahoogroups.com .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "clearableRegion.h"
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
// Filename: clearableRegion.h
|
||||
// Created by: drose (11Jul02)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://www.panda3d.org/license.txt .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d@yahoogroups.com .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef CLEARABLEREGION_H
|
||||
#define CLEARABLEREGION_H
|
||||
|
||||
#include "pandabase.h"
|
||||
#include "luse.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : ClearableRegion
|
||||
// Description : This is just an interface definition for a
|
||||
// rectangular region of the screen that might or might
|
||||
// not need to be cleared every frame before rendering.
|
||||
// This includes DisplayRegions and GraphicsWindows.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDA ClearableRegion {
|
||||
public:
|
||||
INLINE ClearableRegion();
|
||||
INLINE ClearableRegion(const ClearableRegion ©);
|
||||
INLINE void operator = (const ClearableRegion ©);
|
||||
|
||||
INLINE void copy_clear_settings(const ClearableRegion ©);
|
||||
|
||||
PUBLISHED:
|
||||
INLINE void set_clear_color_active(bool clear_color_active);
|
||||
INLINE bool get_clear_color_active() const;
|
||||
|
||||
INLINE void set_clear_depth_active(bool clear_depth_active);
|
||||
INLINE bool get_clear_depth_active() const;
|
||||
|
||||
INLINE void set_clear_color(const Colorf &color);
|
||||
INLINE const Colorf &get_clear_color() const;
|
||||
|
||||
INLINE void set_clear_depth(float depth);
|
||||
INLINE float get_clear_depth() const;
|
||||
|
||||
INLINE bool is_any_clear_active() const;
|
||||
|
||||
private:
|
||||
enum Flags {
|
||||
F_clear_color_active = 0x0001,
|
||||
F_clear_depth_active = 0x0002,
|
||||
};
|
||||
int _flags;
|
||||
|
||||
Colorf _clear_color;
|
||||
float _clear_depth;
|
||||
};
|
||||
|
||||
#include "clearableRegion.I"
|
||||
|
||||
#endif
|
||||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "pandabase.h"
|
||||
|
||||
#include "clearableRegion.h"
|
||||
#include "referenceCount.h"
|
||||
#include "nodePath.h"
|
||||
#include "cullResult.h"
|
||||
|
|
@ -38,7 +39,7 @@ class Camera;
|
|||
// Class : DisplayRegion
|
||||
// Description :
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDA DisplayRegion : public ReferenceCount {
|
||||
class EXPCL_PANDA DisplayRegion : public ReferenceCount, public ClearableRegion {
|
||||
public:
|
||||
DisplayRegion(GraphicsLayer *);
|
||||
DisplayRegion(GraphicsLayer *,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
|
||||
#include "clearableRegion.cxx"
|
||||
#include "displayRegion.cxx"
|
||||
#include "geomContext.cxx"
|
||||
#include "geomNodeContext.cxx"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
#include "config_display.cxx"
|
||||
#include "hardwareChannel.cxx"
|
||||
#include "interactiveGraphicsPipe.cxx"
|
||||
|
|
|
|||
|
|
@ -159,6 +159,9 @@ cull_and_draw_together(GraphicsStateGuardian *gsg, DisplayRegion *dr) {
|
|||
if (setup_gsg(gsg, scene_setup)) {
|
||||
DisplayRegionStack old_dr = gsg->push_display_region(dr);
|
||||
gsg->prepare_display_region();
|
||||
if (dr->is_any_clear_active()) {
|
||||
gsg->clear(dr);
|
||||
}
|
||||
|
||||
DrawCullHandler cull_handler(gsg);
|
||||
do_cull(&cull_handler, scene_setup, gsg);
|
||||
|
|
@ -346,6 +349,9 @@ do_draw(CullResult *cull_result, SceneSetup *scene_setup,
|
|||
if (setup_gsg(gsg, scene_setup)) {
|
||||
DisplayRegionStack old_dr = gsg->push_display_region(dr);
|
||||
gsg->prepare_display_region();
|
||||
if (dr->is_any_clear_active()) {
|
||||
gsg->clear(dr);
|
||||
}
|
||||
cull_result->draw();
|
||||
gsg->pop_display_region(old_dr);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,6 +63,24 @@ get_scene() const {
|
|||
return _scene_setup;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsStateGuardian::clear
|
||||
// Access: Public
|
||||
// Description: Clears the framebuffer within the indicated
|
||||
// DisplayRegion, according to the flags indicated by
|
||||
// the DisplayRegion object (inheriting from
|
||||
// ClearableRegion). Note that by default, a
|
||||
// DisplayRegion does not have any clear flags set, in
|
||||
// which case this function will do nothing.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void GraphicsStateGuardian::
|
||||
clear(DisplayRegion *dr) {
|
||||
DisplayRegionStack old_dr = push_display_region(dr);
|
||||
prepare_display_region();
|
||||
clear((ClearableRegion *)dr);
|
||||
pop_display_region(old_dr);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsStateGuardian::modify_state
|
||||
// Access: Public
|
||||
|
|
|
|||
|
|
@ -173,72 +173,6 @@ get_render_buffer(int buffer_type) {
|
|||
return RenderBuffer(this, buffer_type & _buffer_mask);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsStateGuardian::set_color_clear_value
|
||||
// Access: Public
|
||||
// Description: Sets the color that the next clear() command will set
|
||||
// the color buffer to
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void GraphicsStateGuardian::
|
||||
set_color_clear_value(const Colorf& value) {
|
||||
_color_clear_value = value;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsStateGuardian::set_depth_clear_value
|
||||
// Access: Public
|
||||
// Description: Sets the depth that the next clear() command will set
|
||||
// the depth buffer to
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void GraphicsStateGuardian::
|
||||
set_depth_clear_value(const float value) {
|
||||
_depth_clear_value = value;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsStateGuardian::set_stencil_clear_value
|
||||
// Access: Public
|
||||
// Description: Sets the value that the next clear() command will set
|
||||
// the stencil buffer to
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void GraphicsStateGuardian::
|
||||
set_stencil_clear_value(const bool value) {
|
||||
_stencil_clear_value = value;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsStateGuardian::set_accum_clear_value
|
||||
// Access: Public
|
||||
// Description: Sets the color that the next clear() command will set
|
||||
// the accumulation buffer to
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void GraphicsStateGuardian::
|
||||
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::release_all_textures
|
||||
// Access: Public
|
||||
|
|
@ -410,25 +344,49 @@ set_state_and_transform(const RenderState *state,
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsStateGuardian::clear_framebuffer
|
||||
// Access: Public, Virtual
|
||||
// Description: Erases the contents of the framebuffer, according to
|
||||
// _clear_buffer_type, which is set by
|
||||
// enable_frame_clear().
|
||||
//
|
||||
// This is used to prepare the framebuffer for drawing
|
||||
// a new frame.
|
||||
// Function: GraphicsStateGuardian::set_color_clear_value
|
||||
// Access: Public
|
||||
// Description: Sets the color that the next do_clear() command will set
|
||||
// the color buffer to
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void GraphicsStateGuardian::
|
||||
clear_framebuffer() {
|
||||
if (_clear_buffer_type != 0) {
|
||||
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);
|
||||
set_color_clear_value(const Colorf& value) {
|
||||
_color_clear_value = value;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsStateGuardian::set_depth_clear_value
|
||||
// Access: Public
|
||||
// Description: Sets the depth that the next do_clear() command will set
|
||||
// the depth buffer to
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void GraphicsStateGuardian::
|
||||
set_depth_clear_value(const float value) {
|
||||
_depth_clear_value = value;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsStateGuardian::clear
|
||||
// Access: Public
|
||||
// Description: Clears the framebuffer within the current
|
||||
// DisplayRegion, according to the flags indicated by
|
||||
// the given ClearableRegion object.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void GraphicsStateGuardian::
|
||||
clear(ClearableRegion *clearable) {
|
||||
int clear_buffer_type = 0;
|
||||
if (clearable->get_clear_color_active()) {
|
||||
clear_buffer_type |= RenderBuffer::T_back;
|
||||
set_color_clear_value(clearable->get_clear_color());
|
||||
}
|
||||
if (clearable->get_clear_depth_active()) {
|
||||
clear_buffer_type |= RenderBuffer::T_depth;
|
||||
set_depth_clear_value(clearable->get_clear_depth());
|
||||
}
|
||||
|
||||
if (clear_buffer_type != 0) {
|
||||
prepare_display_region();
|
||||
clear(get_render_buffer(_clear_buffer_type));
|
||||
pop_display_region(old_dr);
|
||||
do_clear(get_render_buffer(clear_buffer_type));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,8 @@
|
|||
#include "notify.h"
|
||||
#include "pvector.h"
|
||||
|
||||
class ClearableRegion;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : GraphicsStateGuardian
|
||||
// Description : Encapsulates all the communication with a particular
|
||||
|
|
@ -62,24 +64,6 @@ public:
|
|||
virtual ~GraphicsStateGuardian();
|
||||
|
||||
PUBLISHED:
|
||||
virtual void set_color_clear_value(const Colorf& value);
|
||||
virtual void set_depth_clear_value(const float value);
|
||||
virtual void set_stencil_clear_value(const bool value);
|
||||
virtual void set_accum_clear_value(const Colorf& value);
|
||||
INLINE Colorf get_color_clear_value(void) const {
|
||||
return _color_clear_value;
|
||||
}
|
||||
INLINE float get_depth_clear_value(void) const {
|
||||
return _depth_clear_value;
|
||||
}
|
||||
INLINE bool get_stencil_clear_value(void) const {
|
||||
return _stencil_clear_value;
|
||||
}
|
||||
INLINE Colorf get_accum_clear_value(void) const {
|
||||
return _accum_clear_value;
|
||||
}
|
||||
|
||||
void enable_frame_clear(bool clear_color, bool clear_depth);
|
||||
void release_all_textures();
|
||||
void release_all_geoms();
|
||||
|
||||
|
|
@ -104,9 +88,12 @@ public:
|
|||
virtual void set_state_and_transform(const RenderState *state,
|
||||
const TransformState *transform);
|
||||
|
||||
virtual void clear(const RenderBuffer &buffer)=0;
|
||||
virtual void clear(const RenderBuffer &buffer, const DisplayRegion* region)=0;
|
||||
virtual void clear_framebuffer();
|
||||
virtual void set_color_clear_value(const Colorf &value);
|
||||
virtual void set_depth_clear_value(const float value);
|
||||
virtual void do_clear(const RenderBuffer &buffer)=0;
|
||||
|
||||
void clear(ClearableRegion *clearable);
|
||||
INLINE void clear(DisplayRegion *dr);
|
||||
|
||||
virtual void prepare_display_region()=0;
|
||||
virtual bool prepare_lens();
|
||||
|
|
|
|||
|
|
@ -150,6 +150,10 @@ GraphicsWindow(GraphicsPipe *pipe) : Configurable() {
|
|||
_is_synced = false;
|
||||
_window_active = true;
|
||||
_display_regions_stale = false;
|
||||
|
||||
// By default, windows are set up to clear color and depth.
|
||||
set_clear_color_active(true);
|
||||
set_clear_depth_active(true);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -159,7 +163,7 @@ GraphicsWindow(GraphicsPipe *pipe) : Configurable() {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
GraphicsWindow::
|
||||
GraphicsWindow(GraphicsPipe *pipe,
|
||||
const GraphicsWindow::Properties& props) : Configurable() {
|
||||
const GraphicsWindow::Properties &props) : Configurable() {
|
||||
#ifdef DO_MEMORY_USAGE
|
||||
MemoryUsage::update_type(this, this);
|
||||
#endif
|
||||
|
|
@ -168,8 +172,14 @@ GraphicsWindow(GraphicsPipe *pipe,
|
|||
|
||||
_draw_callback = NULL;
|
||||
_idle_callback = NULL;
|
||||
_frame_number = 0;
|
||||
_is_synced = false;
|
||||
_window_active = true;
|
||||
_display_regions_stale = false;
|
||||
|
||||
// By default, windows are set up to clear color and depth.
|
||||
set_clear_color_active(true);
|
||||
set_clear_depth_active(true);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -408,7 +418,7 @@ resized(const unsigned int x, const unsigned int y) {
|
|||
// DisplayRegion is not associated with any layer.
|
||||
//
|
||||
// To allocate a normal DisplayRegion for rendering, use
|
||||
// the interface provded in GraphicsLayer.
|
||||
// the interface provided in GraphicsLayer.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PT(DisplayRegion) GraphicsWindow::
|
||||
make_scratch_display_region(int xsize, int ysize) const {
|
||||
|
|
@ -425,7 +435,9 @@ make_scratch_display_region(int xsize, int ysize) const {
|
|||
ysize = _props._ysize;
|
||||
}
|
||||
|
||||
return new DisplayRegion(xsize, ysize);
|
||||
PT(DisplayRegion) region = new DisplayRegion(xsize, ysize);
|
||||
region->copy_clear_settings(*this);
|
||||
return region;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -493,14 +505,22 @@ begin_frame() {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsWindow::clear
|
||||
// Access: Public
|
||||
// Description: Invokes the GSG to clear the entire contents of the
|
||||
// window prior to drawing into it. This is normally
|
||||
// called only by the draw process at the beginning of
|
||||
// the frame.
|
||||
// Description: Clears the entire framebuffer before rendering,
|
||||
// according to the settings of get_color_clear_active()
|
||||
// and get_depth_clear_active() (inherited from
|
||||
// ClearableRegion).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void GraphicsWindow::
|
||||
clear() {
|
||||
_gsg->clear_framebuffer();
|
||||
if (is_any_clear_active()) {
|
||||
nassertv(_gsg != (GraphicsStateGuardian *)NULL);
|
||||
|
||||
PT(DisplayRegion) win_dr =
|
||||
make_scratch_display_region(get_width(), get_height());
|
||||
DisplayRegionStack old_dr = _gsg->push_display_region(win_dr);
|
||||
_gsg->clear(this);
|
||||
_gsg->pop_display_region(old_dr);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -17,28 +17,25 @@
|
|||
////////////////////////////////////////////////////////////////////
|
||||
#ifndef GRAPHICSWINDOW_H
|
||||
#define GRAPHICSWINDOW_H
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Includes
|
||||
////////////////////////////////////////////////////////////////////
|
||||
#include <pandabase.h>
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#include "graphicsWindowInputDevice.h"
|
||||
#include "graphicsChannel.h"
|
||||
#include "displayRegion.h"
|
||||
#include "graphicsStateGuardian.h"
|
||||
#include "clearableRegion.h"
|
||||
|
||||
#include <typedef.h>
|
||||
#include <configurable.h>
|
||||
#include <referenceCount.h>
|
||||
#include <mouseData.h>
|
||||
#include <modifierButtons.h>
|
||||
#include <buttonEvent.h>
|
||||
#include <iterator_types.h>
|
||||
#include <factory.h>
|
||||
#include <pStatCollector.h>
|
||||
#include "typedef.h"
|
||||
#include "configurable.h"
|
||||
#include "referenceCount.h"
|
||||
#include "mouseData.h"
|
||||
#include "modifierButtons.h"
|
||||
#include "buttonEvent.h"
|
||||
#include "iterator_types.h"
|
||||
#include "factory.h"
|
||||
#include "pStatCollector.h"
|
||||
|
||||
#include <string>
|
||||
#include "pvector.h"
|
||||
#include "pdeque.h"
|
||||
|
||||
|
|
@ -69,7 +66,7 @@ class CullHandler;
|
|||
// Class : GraphicsWindow
|
||||
// Description :
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDA GraphicsWindow : public Configurable, public ReferenceCount {
|
||||
class EXPCL_PANDA GraphicsWindow : public Configurable, public ReferenceCount, public ClearableRegion {
|
||||
PUBLISHED:
|
||||
class EXPCL_PANDA Properties {
|
||||
PUBLISHED:
|
||||
|
|
|
|||
|
|
@ -601,10 +601,6 @@ render_screen(GraphicsEngine *engine, NonlinearImager::Screen &screen) {
|
|||
PT(DisplayRegion) scratch_region =
|
||||
_gsg->get_window()->make_scratch_display_region(screen._tex_width, screen._tex_height);
|
||||
scratch_region->set_camera(screen._source_camera);
|
||||
|
||||
_gsg->clear(_gsg->get_render_buffer(RenderBuffer::T_back |
|
||||
RenderBuffer::T_depth),
|
||||
scratch_region);
|
||||
engine->render_subframe(_gsg, scratch_region);
|
||||
|
||||
// Copy the results of the render from the frame buffer into the
|
||||
|
|
|
|||
|
|
@ -928,13 +928,13 @@ dx_init( void) {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DXGraphicsStateGuardian::clear
|
||||
// Function: DXGraphicsStateGuardian::do_clear
|
||||
// Access: Public, Virtual
|
||||
// Description: Clears all of the indicated buffers to their assigned
|
||||
// colors.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void DXGraphicsStateGuardian::
|
||||
clear(const RenderBuffer &buffer) {
|
||||
do_clear(const RenderBuffer &buffer) {
|
||||
DO_PSTATS_STUFF(PStatTimer timer(_win->_clear_pcollector));
|
||||
|
||||
nassertv(buffer._gsg == this);
|
||||
|
|
@ -963,20 +963,6 @@ clear(const RenderBuffer &buffer) {
|
|||
*/
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DXGraphicsStateGuardian::clear
|
||||
// Access: Public, Virtual
|
||||
// Description: Clears all of the indicated buffers to their assigned
|
||||
// colors.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void DXGraphicsStateGuardian::
|
||||
clear(const RenderBuffer &buffer, const DisplayRegion *region) {
|
||||
DisplayRegionStack old_dr = push_display_region(region);
|
||||
prepare_display_region();
|
||||
clear(buffer);
|
||||
pop_display_region(old_dr);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DXGraphicsStateGuardian::prepare_display_region
|
||||
// Access: Public, Virtual
|
||||
|
|
|
|||
|
|
@ -68,8 +68,7 @@ public:
|
|||
|
||||
virtual void reset();
|
||||
|
||||
virtual void clear(const RenderBuffer &buffer);
|
||||
virtual void clear(const RenderBuffer &buffer, const DisplayRegion* region);
|
||||
virtual void do_clear(const RenderBuffer &buffer);
|
||||
|
||||
virtual void prepare_display_region();
|
||||
virtual bool prepare_lens();
|
||||
|
|
|
|||
|
|
@ -1028,13 +1028,13 @@ support_overlay_window(bool flag) {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DXGraphicsStateGuardian::clear
|
||||
// Function: DXGraphicsStateGuardian::do_clear
|
||||
// Access: Public, Virtual
|
||||
// Description: Clears all of the indicated buffers to their assigned
|
||||
// colors.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void DXGraphicsStateGuardian::
|
||||
clear(const RenderBuffer &buffer) {
|
||||
do_clear(const RenderBuffer &buffer) {
|
||||
DO_PSTATS_STUFF(PStatTimer timer(_win->_clear_pcollector));
|
||||
|
||||
nassertv(buffer._gsg == this);
|
||||
|
|
@ -1067,20 +1067,6 @@ clear(const RenderBuffer &buffer) {
|
|||
*/
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DXGraphicsStateGuardian::clear
|
||||
// Access: Public, Virtual
|
||||
// Description: Clears all of the indicated buffers to their assigned
|
||||
// colors.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void DXGraphicsStateGuardian::
|
||||
clear(const RenderBuffer &buffer, const DisplayRegion *region) {
|
||||
DisplayRegionStack old_dr = push_display_region(region);
|
||||
prepare_display_region();
|
||||
clear(buffer);
|
||||
pop_display_region(old_dr);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DXGraphicsStateGuardian::prepare_display_region
|
||||
// Access: Public, Virtual
|
||||
|
|
|
|||
|
|
@ -75,8 +75,7 @@ public:
|
|||
|
||||
virtual void reset();
|
||||
|
||||
virtual void clear(const RenderBuffer &buffer);
|
||||
virtual void clear(const RenderBuffer &buffer, const DisplayRegion* region);
|
||||
virtual void do_clear(const RenderBuffer &buffer);
|
||||
|
||||
virtual void prepare_display_region();
|
||||
virtual bool prepare_lens();
|
||||
|
|
|
|||
|
|
@ -316,7 +316,7 @@ reset() {
|
|||
// colors.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void GLGraphicsStateGuardian::
|
||||
clear(const RenderBuffer &buffer) {
|
||||
do_clear(const RenderBuffer &buffer) {
|
||||
DO_PSTATS_STUFF(PStatTimer timer(_win->_clear_pcollector);)
|
||||
// activate();
|
||||
|
||||
|
|
@ -381,20 +381,6 @@ clear(const RenderBuffer &buffer) {
|
|||
glClear(mask);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GLGraphicsStateGuardian::clear
|
||||
// Access: Public, Virtual
|
||||
// Description: Clears all of the indicated buffers to their assigned
|
||||
// colors.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void GLGraphicsStateGuardian::
|
||||
clear(const RenderBuffer &buffer, const DisplayRegion *region) {
|
||||
DisplayRegionStack old_dr = push_display_region(region);
|
||||
prepare_display_region();
|
||||
clear(buffer);
|
||||
pop_display_region(old_dr);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GLGraphicsStateGuardian::prepare_display_region
|
||||
// Access: Public, Virtual
|
||||
|
|
|
|||
|
|
@ -68,8 +68,7 @@ public:
|
|||
|
||||
virtual void reset();
|
||||
|
||||
virtual void clear(const RenderBuffer &buffer);
|
||||
virtual void clear(const RenderBuffer &buffer, const DisplayRegion* region);
|
||||
virtual void do_clear(const RenderBuffer &buffer);
|
||||
|
||||
virtual void prepare_display_region();
|
||||
virtual bool prepare_lens();
|
||||
|
|
|
|||
Loading…
Reference in New Issue