00001 // Filename: clearableRegion.I 00002 // Created by: drose (11Jul02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 00020 //////////////////////////////////////////////////////////////////// 00021 // Function: ClearableRegion::Constructor 00022 // Access: Public 00023 // Description: 00024 //////////////////////////////////////////////////////////////////// 00025 INLINE ClearableRegion:: 00026 ClearableRegion() : 00027 _flags(0), 00028 _clear_color(0.0f, 0.0f, 0.0f, 0.0f), 00029 _clear_depth(1.0f) 00030 { 00031 } 00032 00033 //////////////////////////////////////////////////////////////////// 00034 // Function: ClearableRegion::Copy Constructor 00035 // Access: Public 00036 // Description: 00037 //////////////////////////////////////////////////////////////////// 00038 INLINE ClearableRegion:: 00039 ClearableRegion(const ClearableRegion ©) : 00040 _flags(copy._flags), 00041 _clear_color(copy._clear_color), 00042 _clear_depth(copy._clear_depth) 00043 { 00044 } 00045 00046 //////////////////////////////////////////////////////////////////// 00047 // Function: ClearableRegion::Copy Assignment Operator 00048 // Access: Public 00049 // Description: 00050 //////////////////////////////////////////////////////////////////// 00051 INLINE void ClearableRegion:: 00052 operator = (const ClearableRegion ©) { 00053 _flags = copy._flags; 00054 _clear_color = copy._clear_color; 00055 _clear_depth = copy._clear_depth; 00056 } 00057 00058 //////////////////////////////////////////////////////////////////// 00059 // Function: ClearableRegion::copy_clear_settings 00060 // Access: Public 00061 // Description: A convenience function that does the same thing as 00062 // the assignment operator; this is just syntactically a 00063 // little nicer (and a little clearer) to call from a 00064 // derived class. 00065 //////////////////////////////////////////////////////////////////// 00066 INLINE void ClearableRegion:: 00067 copy_clear_settings(const ClearableRegion ©) { 00068 operator = (copy); 00069 } 00070 00071 //////////////////////////////////////////////////////////////////// 00072 // Function: ClearableRegion::set_clear_color_active 00073 // Access: Published 00074 // Description: Toggles the flag that indicates whether the color 00075 // buffer should be cleared every frame. If this is 00076 // true, the color buffer will be cleared to the color 00077 // indicated by set_clear_color(); otherwise, it will be 00078 // left alone. 00079 //////////////////////////////////////////////////////////////////// 00080 INLINE void ClearableRegion:: 00081 set_clear_color_active(bool clear_color_active) { 00082 if (clear_color_active) { 00083 _flags |= F_clear_color_active; 00084 } else { 00085 _flags &= ~F_clear_color_active; 00086 } 00087 } 00088 00089 //////////////////////////////////////////////////////////////////// 00090 // Function: ClearableRegion::get_clear_color_active 00091 // Access: Published 00092 // Description: Returns the current setting of the flag that 00093 // indicates whether the color buffer should be cleared 00094 // every frame. See set_clear_color_active(). 00095 //////////////////////////////////////////////////////////////////// 00096 INLINE bool ClearableRegion:: 00097 get_clear_color_active() const { 00098 return ((_flags & F_clear_color_active) != 0); 00099 } 00100 00101 //////////////////////////////////////////////////////////////////// 00102 // Function: ClearableRegion::set_clear_depth_active 00103 // Access: Published 00104 // Description: Toggles the flag that indicates whether the depth 00105 // buffer should be cleared every frame. If this is 00106 // true, the depth buffer will be cleared to the depth 00107 // value indicated by set_clear_depth(); otherwise, it 00108 // will be left alone. 00109 //////////////////////////////////////////////////////////////////// 00110 INLINE void ClearableRegion:: 00111 set_clear_depth_active(bool clear_depth_active) { 00112 if (clear_depth_active) { 00113 _flags |= F_clear_depth_active; 00114 } else { 00115 _flags &= ~F_clear_depth_active; 00116 } 00117 } 00118 00119 //////////////////////////////////////////////////////////////////// 00120 // Function: ClearableRegion::get_clear_depth_active 00121 // Access: Published 00122 // Description: Returns the current setting of the flag that 00123 // indicates whether the depth buffer should be cleared 00124 // every frame. See set_clear_depth_active(). 00125 //////////////////////////////////////////////////////////////////// 00126 INLINE bool ClearableRegion:: 00127 get_clear_depth_active() const { 00128 return ((_flags & F_clear_depth_active) != 0); 00129 } 00130 00131 //////////////////////////////////////////////////////////////////// 00132 // Function: ClearableRegion::set_clear_color 00133 // Access: Published 00134 // Description: Sets the clear color to the indicated value. This is 00135 // the value that will be used to clear the color buffer 00136 // every frame, but only if get_clear_color_active() 00137 // returns true. If get_clear_color_active() returns 00138 // false, this is meaningless. 00139 //////////////////////////////////////////////////////////////////// 00140 INLINE void ClearableRegion:: 00141 set_clear_color(const Colorf &color) { 00142 _clear_color = color; 00143 } 00144 00145 //////////////////////////////////////////////////////////////////// 00146 // Function: ClearableRegion::get_clear_color 00147 // Access: Published 00148 // Description: Returns the current clear color value. This is 00149 // the value that will be used to clear the color buffer 00150 // every frame, but only if get_clear_color_active() 00151 // returns true. If get_clear_color_active() returns 00152 // false, this is meaningless. 00153 //////////////////////////////////////////////////////////////////// 00154 INLINE const Colorf &ClearableRegion:: 00155 get_clear_color() const { 00156 return _clear_color; 00157 } 00158 00159 //////////////////////////////////////////////////////////////////// 00160 // Function: ClearableRegion::set_clear_depth 00161 // Access: Published 00162 // Description: Sets the clear depth to the indicated value. This is 00163 // the value that will be used to clear the depth buffer 00164 // every frame, but only if get_clear_depth_active() 00165 // returns true. If get_clear_depth_active() returns 00166 // false, this is meaningless. 00167 //////////////////////////////////////////////////////////////////// 00168 INLINE void ClearableRegion:: 00169 set_clear_depth(float depth) { 00170 _clear_depth = depth; 00171 } 00172 00173 //////////////////////////////////////////////////////////////////// 00174 // Function: ClearableRegion::get_clear_depth 00175 // Access: Published 00176 // Description: Returns the current clear depth value. This is 00177 // the value that will be used to clear the depth buffer 00178 // every frame, but only if get_clear_depth_active() 00179 // returns true. If get_clear_depth_active() returns 00180 // false, this is meaningless. 00181 //////////////////////////////////////////////////////////////////// 00182 INLINE float ClearableRegion:: 00183 get_clear_depth() const { 00184 return _clear_depth; 00185 } 00186 00187 //////////////////////////////////////////////////////////////////// 00188 // Function: ClearableRegion::is_any_clear_active 00189 // Access: Published 00190 // Description: Returns true if any of the clear types (so far there 00191 // are just color or depth) have been set active, or 00192 // false if none of them are active and there is no need 00193 // to clear. 00194 //////////////////////////////////////////////////////////////////// 00195 INLINE bool ClearableRegion:: 00196 is_any_clear_active() const { 00197 return (_flags != 0); 00198 }