Let SM play nice with OS X's headers.

This commit is contained in:
Steve Checkoway
2005-10-31 01:56:15 +00:00
parent f89319f256
commit 8221c2f20d
+27 -26
View File
@@ -202,36 +202,37 @@ public:
} }
}; };
namespace SM
template <class T>
class Rect
{ {
public: template <class T>
Rect() {}; class Rect
Rect(T l, T t, T r, T b) { left = l, top = t, right = r, bottom = b; };
T GetWidth() const { return right-left; };
T GetHeight() const { return bottom-top; };
T GetCenterX() const { return (left+right)/2; };
T GetCenterY() const { return (top+bottom)/2; };
bool operator==( const Rect &other ) const
{ {
public:
Rect() {};
Rect(T l, T t, T r, T b) { left = l, top = t, right = r, bottom = b; };
T GetWidth() const { return right-left; };
T GetHeight() const { return bottom-top; };
T GetCenterX() const { return (left+right)/2; };
T GetCenterY() const { return (top+bottom)/2; };
bool operator==( const Rect &other ) const
{
#define COMPARE( x ) if( x != other.x ) return false; #define COMPARE( x ) if( x != other.x ) return false;
COMPARE( left ); COMPARE( left );
COMPARE( top ); COMPARE( top );
COMPARE( right ); COMPARE( right );
COMPARE( bottom ); COMPARE( bottom );
#undef COMPARE #undef COMPARE
return true; return true;
} }
bool operator!=( const Rect &other ) const { return !operator==(other); } bool operator!=( const Rect &other ) const { return !operator==(other); }
T left, top, right, bottom; T left, top, right, bottom;
}; };
}
typedef Rect<int> RectI; typedef SM::Rect<int> RectI;
typedef Rect<float> RectF; typedef SM::Rect<float> RectF;
/* Structure for our custom vertex type. Note that these data structes /* Structure for our custom vertex type. Note that these data structes
* have the same layout that D3D expects. */ * have the same layout that D3D expects. */