Browse Source

configurable clear color

David Rose 23 years ago
parent
commit
177deb3d97

+ 8 - 0
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?
 

+ 26 - 14
panda/src/display/graphicsWindow.I

@@ -19,12 +19,34 @@
 #include <notify.h>
 
 ////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::Properties::Destructor
+//     Function: GraphicsWindow::Properties::Copy Constructor
 //       Access: Published
 //  Description:
 ////////////////////////////////////////////////////////////////////
 INLINE GraphicsWindow::Properties::
-~Properties() {
+Properties(const Properties &copy) {
+  (*this) = copy;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsWindow::Properties::Copy Assignment Operator
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE void GraphicsWindow::Properties::
+operator = (const Properties &copy) {
+  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() {
 }
 
 ////////////////////////////////////////////////////////////////////

+ 8 - 29
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);
 }
 
 ////////////////////////////////////////////////////////////////////

+ 4 - 4
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 &copy);
+    INLINE void operator = (const Properties &copy);
     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;

+ 3 - 3
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);

+ 3 - 3
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

+ 3 - 0
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));
 }
 
 ////////////////////////////////////////////////////////////////////

+ 0 - 2
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;