Why no recti and rectf typedefs?
Posted: Sat Jan 03, 2009 2:37 am
I noticed there weren't any typedefs for rects like there are for other core tools (like vector3d - vector3df and vector3di), which I found a bit odd. I made a patch that added these typedefs along with a function for drawing the outline of a rectangle through the video driver (and also capitalized some d's and fixed some an's - because I'm pedantic):
Code: Select all
Index: include/IVideoDriver.h
===================================================================
--- include/IVideoDriver.h (revision 2023)
+++ include/IVideoDriver.h (working copy)
@@ -569,7 +569,7 @@
virtual void draw2DRectangle(SColor color, const core::rect<s32>& pos,
const core::rect<s32>* clip = 0) = 0;
- //! Draws an 2d rectangle with a gradient.
+ //! Draws a 2d rectangle with a gradient.
/** \param colorLeftUp Color of the upper left corner to draw.
The alpha component will not be ignored and specifies how
transparent the rectangle will be.
@@ -591,6 +591,15 @@
SColor colorLeftDown, SColor colorRightDown,
const core::rect<s32>* clip = 0) = 0;
+ //! Draws the outline of a 2D rectangle.
+ /** \param pos Position of the rectangle.
+ \param color Color of the rectangle to draw. The alpha
+ component will not be ignored and specifies how transparent the
+ rectangle outline will be.
+ */
+ virtual void draw2DRectangleOutline(const core::recti& pos,
+ SColor color=SColor(255,255,255,255)) = 0 ;
+
//! Draws a 2d line.
/** \param start: Screen coordinates of the start of the line
in pixels.
Index: include/rect.h
===================================================================
--- include/rect.h (revision 2023)
+++ include/rect.h (working copy)
@@ -252,6 +252,8 @@
position2d<T> LowerRightCorner;
};
+ typedef rect<f32> rectf;
+ typedef rect<s32> recti;
} // end namespace core
} // end namespace irr
Index: source/Irrlicht/CNullDriver.cpp
===================================================================
--- source/Irrlicht/CNullDriver.cpp (revision 2023)
+++ source/Irrlicht/CNullDriver.cpp (working copy)
@@ -669,7 +669,7 @@
}
-//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted.
+//! Draws a 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted.
void CNullDriver::draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,
const core::rect<s32>& sourceRect,
const core::rect<s32>* clipRect, SColor color,
@@ -678,8 +678,17 @@
}
+//! Draws the outline of a 2d rectangle
+void CNullDriver::draw2DRectangleOutline(const core::recti& pos, SColor color)
+{
+ draw2DLine( pos.UpperLeftCorner , core::position2di( pos.LowerRightCorner.X , pos.UpperLeftCorner.Y ) , color ) ;
+ draw2DLine( core::position2di( pos.LowerRightCorner.X , pos.UpperLeftCorner.Y ) , pos.LowerRightCorner , color ) ;
+ draw2DLine( pos.LowerRightCorner , core::position2di( pos.UpperLeftCorner.X , pos.LowerRightCorner.Y ) , color ) ;
+ draw2DLine( core::position2di( pos.UpperLeftCorner.X , pos.LowerRightCorner.Y ) , pos.UpperLeftCorner , color ) ;
+}
-//! draw an 2d rectangle
+
+//! Draw a 2d rectangle
void CNullDriver::draw2DRectangle(SColor color, const core::rect<s32>& pos, const core::rect<s32>* clip)
{
draw2DRectangle(pos, color, color, color, color, clip);
@@ -687,7 +696,7 @@
-//!Draws an 2d rectangle with a gradient.
+//! Draws a 2d rectangle with a gradient.
void CNullDriver::draw2DRectangle(const core::rect<s32>& pos,
SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown,
const core::rect<s32>* clip)
Index: source/Irrlicht/CNullDriver.h
===================================================================
--- source/Irrlicht/CNullDriver.h (revision 2023)
+++ source/Irrlicht/CNullDriver.h (working copy)
@@ -163,7 +163,7 @@
SColor color=SColor(255,255,255,255),
bool useAlphaChannelOfTexture=false);
- //! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted.
+ //! Draws a 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted.
virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false);
@@ -173,14 +173,17 @@
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
const video::SColor* const colors=0, bool useAlphaChannelOfTexture=false);
- //! draw an 2d rectangle
+ //! Draws a 2d rectangle
virtual void draw2DRectangle(SColor color, const core::rect<s32>& pos, const core::rect<s32>* clip = 0);
- //!Draws an 2d rectangle with a gradient.
+ //! Draws a 2d rectangle with a gradient.
virtual void draw2DRectangle(const core::rect<s32>& pos,
SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown,
const core::rect<s32>* clip = 0);
+ //! Draws the outline of a 2d rectangle
+ virtual void draw2DRectangleOutline(const core::recti& pos, SColor color=SColor(255,255,255,255));
+
//! Draws a 2d line.
virtual void draw2DLine(const core::position2d<s32>& start,
const core::position2d<s32>& end,