From 177deb3d97dba6bbd58aaee57004bed48e1facca Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 12 Jul 2002 16:53:11 +0000 Subject: [PATCH] configurable clear color --- panda/src/chancfg/chancfg.cxx | 8 +++++ panda/src/display/graphicsWindow.I | 40 +++++++++++++++--------- panda/src/display/graphicsWindow.cxx | 37 +++++----------------- panda/src/display/graphicsWindow.h | 8 ++--- panda/src/framework/config_framework.cxx | 6 ++-- panda/src/framework/config_framework.h | 6 ++-- panda/src/framework/pandaFramework.cxx | 3 ++ panda/src/framework/windowFramework.cxx | 2 -- 8 files changed, 55 insertions(+), 55 deletions(-) diff --git a/panda/src/chancfg/chancfg.cxx b/panda/src/chancfg/chancfg.cxx index d7d395c78e..bab347b0a0 100644 --- a/panda/src/chancfg/chancfg.cxx +++ b/panda/src/chancfg/chancfg.cxx @@ -393,6 +393,10 @@ ChanConfig::ChanConfig(GraphicsPipe* pipe, std::string cfg, const NodePath &rend int want_depth_bits = chanconfig.GetInt("want-depth-bits", 1); int want_color_bits = chanconfig.GetInt("want-color-bits", 1); + float win_background_r = chanconfig.GetFloat("win-background-r", 0.41); + float win_background_g = chanconfig.GetFloat("win-background-g", 0.41); + float win_background_b = chanconfig.GetFloat("win-background-b", 0.41); + // visual? nope, that's handled with the mode. uint mask = 0x0; // ?! this really should come from the win config mask = overrides.defined(ChanCfgOverrides::Mask) ? @@ -414,6 +418,10 @@ ChanConfig::ChanConfig(GraphicsPipe* pipe, std::string cfg, const NodePath &rend props._want_color_bits = want_color_bits; props._bCursorIsVisible = use_cursor; + props.set_clear_color(Colorf(win_background_r, win_background_g, + win_background_b, 1.0f)); + + // stereo prep? // DVR prep? diff --git a/panda/src/display/graphicsWindow.I b/panda/src/display/graphicsWindow.I index f0c317c915..67d2d4d704 100644 --- a/panda/src/display/graphicsWindow.I +++ b/panda/src/display/graphicsWindow.I @@ -19,12 +19,34 @@ #include //////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::Properties::Destructor +// Function: GraphicsWindow::Properties::Copy Constructor // Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE GraphicsWindow::Properties:: -~Properties() { +Properties(const Properties ©) { + (*this) = copy; +} + +//////////////////////////////////////////////////////////////////// +// Function: GraphicsWindow::Properties::Copy Assignment Operator +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void GraphicsWindow::Properties:: +operator = (const Properties ©) { + ClearableRegion::operator = (copy); + _xorg = copy._xorg; + _yorg = copy._yorg; + _xsize = copy._xsize; + _ysize = copy._ysize; + _title = copy._title; + _border = copy._border; + _fullscreen = copy._fullscreen; + _mask = copy._mask; + _want_depth_bits = copy._want_depth_bits; + _want_color_bits = copy._want_color_bits; + _bCursorIsVisible = copy._bCursorIsVisible; } //////////////////////////////////////////////////////////////////// @@ -32,18 +54,8 @@ INLINE GraphicsWindow::Properties:: // Access: Published // Description: //////////////////////////////////////////////////////////////////// -INLINE GraphicsWindow::Properties::Properties(const Properties &InitProp) { - _xorg=InitProp._xorg; - _yorg=InitProp._yorg; - _xsize=InitProp._xsize; - _ysize=InitProp._ysize; - _title=InitProp._title; - _border=InitProp._border; - _fullscreen=InitProp._fullscreen; - _mask=InitProp._mask; - _want_depth_bits=InitProp._want_depth_bits; - _want_color_bits=InitProp._want_color_bits; - _bCursorIsVisible=InitProp._bCursorIsVisible; +INLINE GraphicsWindow::Properties:: +~Properties() { } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/display/graphicsWindow.cxx b/panda/src/display/graphicsWindow.cxx index aa610a8eba..3e6c1d2c89 100644 --- a/panda/src/display/graphicsWindow.cxx +++ b/panda/src/display/graphicsWindow.cxx @@ -66,6 +66,10 @@ Properties() { _want_depth_bits = 1; _want_color_bits = 1; _bCursorIsVisible=true; + + // By default, windows are set up to clear color and depth. + set_clear_color_active(true); + set_clear_depth_active(true); } //////////////////////////////////////////////////////////////////// @@ -132,30 +136,6 @@ TypeHandle GraphicsWindow::WindowPipe::force_init_type(void) { return get_class_type(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -GraphicsWindow:: -GraphicsWindow(GraphicsPipe *pipe) : Configurable() { -#ifdef DO_MEMORY_USAGE - MemoryUsage::update_type(this, this); -#endif - _pipe = 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); -} - //////////////////////////////////////////////////////////////////// // Function: GraphicsWindow::Constructor // Access: Public @@ -163,7 +143,10 @@ GraphicsWindow(GraphicsPipe *pipe) : Configurable() { //////////////////////////////////////////////////////////////////// GraphicsWindow:: GraphicsWindow(GraphicsPipe *pipe, - const GraphicsWindow::Properties &props) : Configurable() { + const GraphicsWindow::Properties &props) : + Configurable(), + ClearableRegion(props) +{ #ifdef DO_MEMORY_USAGE MemoryUsage::update_type(this, this); #endif @@ -176,10 +159,6 @@ GraphicsWindow(GraphicsPipe *pipe, _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); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/display/graphicsWindow.h b/panda/src/display/graphicsWindow.h index 356a14d962..1f624b897c 100644 --- a/panda/src/display/graphicsWindow.h +++ b/panda/src/display/graphicsWindow.h @@ -68,10 +68,11 @@ class CullHandler; //////////////////////////////////////////////////////////////////// class EXPCL_PANDA GraphicsWindow : public Configurable, public ReferenceCount, public ClearableRegion { PUBLISHED: - class EXPCL_PANDA Properties { + class EXPCL_PANDA Properties : public ClearableRegion { PUBLISHED: Properties(); - INLINE Properties(const Properties &); + INLINE Properties(const Properties ©); + INLINE void operator = (const Properties ©); INLINE ~Properties(); INLINE void set_origin(int xorg, int yorg); @@ -107,8 +108,7 @@ public: public: - GraphicsWindow(GraphicsPipe*); - GraphicsWindow(GraphicsPipe*, const Properties&); + GraphicsWindow(GraphicsPipe *pipe, const Properties &props = Properties()); virtual ~GraphicsWindow(); INLINE const Properties& get_properties() const; diff --git a/panda/src/framework/config_framework.cxx b/panda/src/framework/config_framework.cxx index d84c3fdb7e..bf46691701 100644 --- a/panda/src/framework/config_framework.cxx +++ b/panda/src/framework/config_framework.cxx @@ -31,6 +31,6 @@ const int win_height = config_framework.GetInt("win-height", 480); const bool fullscreen = config_framework.GetBool("fullscreen", false); // The default window background color. -const float background_r = config_framework.GetFloat("background-r", 0.41); -const float background_g = config_framework.GetFloat("background-g", 0.41); -const float background_b = config_framework.GetFloat("background-b", 0.41); +const float win_background_r = config_framework.GetFloat("win-background-r", 0.41); +const float win_background_g = config_framework.GetFloat("win-background-g", 0.41); +const float win_background_b = config_framework.GetFloat("win-background-b", 0.41); diff --git a/panda/src/framework/config_framework.h b/panda/src/framework/config_framework.h index 5f14a825ba..433959ca3d 100644 --- a/panda/src/framework/config_framework.h +++ b/panda/src/framework/config_framework.h @@ -29,8 +29,8 @@ extern const int win_width; extern const int win_height; extern const bool fullscreen; -extern const float background_r; -extern const float background_g; -extern const float background_b; +extern const float win_background_r; +extern const float win_background_g; +extern const float win_background_b; #endif diff --git a/panda/src/framework/pandaFramework.cxx b/panda/src/framework/pandaFramework.cxx index e1edab25e6..198505d5dc 100644 --- a/panda/src/framework/pandaFramework.cxx +++ b/panda/src/framework/pandaFramework.cxx @@ -151,6 +151,9 @@ get_default_window_props(GraphicsWindow::Properties &props) { props._ysize = win_height; props._fullscreen = fullscreen; props._title = _window_title; + + props.set_clear_color(Colorf(win_background_r, win_background_g, + win_background_b, 1.0f)); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/framework/windowFramework.cxx b/panda/src/framework/windowFramework.cxx index 6774ca2a10..65813ac674 100644 --- a/panda/src/framework/windowFramework.cxx +++ b/panda/src/framework/windowFramework.cxx @@ -83,8 +83,6 @@ open_window(const GraphicsWindow::Properties &props, GraphicsPipe *pipe) { _window = pipe->make_window(props); - _window->set_clear_color(Colorf(background_r, background_g, background_b, 1.0f)); - // Set up a 3-d camera for the window by default. make_camera(); return _window;