configurable clear color

This commit is contained in:
David Rose 2002-07-12 16:53:11 +00:00
parent db7b164ced
commit 177deb3d97
8 changed files with 55 additions and 55 deletions

View File

@ -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_depth_bits = chanconfig.GetInt("want-depth-bits", 1);
int want_color_bits = chanconfig.GetInt("want-color-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. // visual? nope, that's handled with the mode.
uint mask = 0x0; // ?! this really should come from the win config uint mask = 0x0; // ?! this really should come from the win config
mask = overrides.defined(ChanCfgOverrides::Mask) ? 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._want_color_bits = want_color_bits;
props._bCursorIsVisible = use_cursor; props._bCursorIsVisible = use_cursor;
props.set_clear_color(Colorf(win_background_r, win_background_g,
win_background_b, 1.0f));
// stereo prep? // stereo prep?
// DVR prep? // DVR prep?

View File

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

View File

@ -66,6 +66,10 @@ Properties() {
_want_depth_bits = 1; _want_depth_bits = 1;
_want_color_bits = 1; _want_color_bits = 1;
_bCursorIsVisible=true; _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(); 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 // Function: GraphicsWindow::Constructor
// Access: Public // Access: Public
@ -163,7 +143,10 @@ GraphicsWindow(GraphicsPipe *pipe) : Configurable() {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
GraphicsWindow:: GraphicsWindow::
GraphicsWindow(GraphicsPipe *pipe, GraphicsWindow(GraphicsPipe *pipe,
const GraphicsWindow::Properties &props) : Configurable() { const GraphicsWindow::Properties &props) :
Configurable(),
ClearableRegion(props)
{
#ifdef DO_MEMORY_USAGE #ifdef DO_MEMORY_USAGE
MemoryUsage::update_type(this, this); MemoryUsage::update_type(this, this);
#endif #endif
@ -176,10 +159,6 @@ GraphicsWindow(GraphicsPipe *pipe,
_is_synced = false; _is_synced = false;
_window_active = true; _window_active = true;
_display_regions_stale = false; _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);
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////

View File

@ -68,10 +68,11 @@ class CullHandler;
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
class EXPCL_PANDA GraphicsWindow : public Configurable, public ReferenceCount, public ClearableRegion { class EXPCL_PANDA GraphicsWindow : public Configurable, public ReferenceCount, public ClearableRegion {
PUBLISHED: PUBLISHED:
class EXPCL_PANDA Properties { class EXPCL_PANDA Properties : public ClearableRegion {
PUBLISHED: PUBLISHED:
Properties(); Properties();
INLINE Properties(const Properties &); INLINE Properties(const Properties &copy);
INLINE void operator = (const Properties &copy);
INLINE ~Properties(); INLINE ~Properties();
INLINE void set_origin(int xorg, int yorg); INLINE void set_origin(int xorg, int yorg);
@ -107,8 +108,7 @@ public:
public: public:
GraphicsWindow(GraphicsPipe*); GraphicsWindow(GraphicsPipe *pipe, const Properties &props = Properties());
GraphicsWindow(GraphicsPipe*, const Properties&);
virtual ~GraphicsWindow(); virtual ~GraphicsWindow();
INLINE const Properties& get_properties() const; INLINE const Properties& get_properties() const;

View File

@ -31,6 +31,6 @@ const int win_height = config_framework.GetInt("win-height", 480);
const bool fullscreen = config_framework.GetBool("fullscreen", false); const bool fullscreen = config_framework.GetBool("fullscreen", false);
// The default window background color. // The default window background color.
const float background_r = config_framework.GetFloat("background-r", 0.41); const float win_background_r = config_framework.GetFloat("win-background-r", 0.41);
const float background_g = config_framework.GetFloat("background-g", 0.41); const float win_background_g = config_framework.GetFloat("win-background-g", 0.41);
const float background_b = config_framework.GetFloat("background-b", 0.41); const float win_background_b = config_framework.GetFloat("win-background-b", 0.41);

View File

@ -29,8 +29,8 @@ extern const int win_width;
extern const int win_height; extern const int win_height;
extern const bool fullscreen; extern const bool fullscreen;
extern const float background_r; extern const float win_background_r;
extern const float background_g; extern const float win_background_g;
extern const float background_b; extern const float win_background_b;
#endif #endif

View File

@ -151,6 +151,9 @@ get_default_window_props(GraphicsWindow::Properties &props) {
props._ysize = win_height; props._ysize = win_height;
props._fullscreen = fullscreen; props._fullscreen = fullscreen;
props._title = _window_title; props._title = _window_title;
props.set_clear_color(Colorf(win_background_r, win_background_g,
win_background_b, 1.0f));
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////

View File

@ -83,8 +83,6 @@ open_window(const GraphicsWindow::Properties &props, GraphicsPipe *pipe) {
_window = pipe->make_window(props); _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. // Set up a 3-d camera for the window by default.
make_camera(); make_camera();
return _window; return _window;